From dc0db358abe19481e475e10c32149b53370f1a1c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:31 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/abi/foreign/foreign-fn-with-byval.rs | 2 +- tests/ui/abi/issue-94223.rs | 8 + tests/ui/argument-suggestions/issue-112507.rs | 12 + tests/ui/argument-suggestions/issue-112507.stderr | 27 + tests/ui/asm/aarch64/may_unwind.rs | 1 + tests/ui/asm/parse-error.rs | 144 ++ tests/ui/asm/parse-error.stderr | 412 +++++ tests/ui/asm/x86_64/parse-error.rs | 130 -- tests/ui/asm/x86_64/parse-error.stderr | 399 ---- tests/ui/asm/x86_64/x86_64_parse_error.rs | 21 + tests/ui/asm/x86_64/x86_64_parse_error.stderr | 44 + tests/ui/assign-assign.rs | 4 +- .../infer-placeholder-in-non-suggestable-pos.rs | 10 + ...infer-placeholder-in-non-suggestable-pos.stderr | 9 + tests/ui/associated-consts/issue-110933.rs | 20 + .../assoc-inherent-unstable.rs | 3 + .../assoc-inherent-unstable.stderr | 2 +- .../bugs/cycle-iat-inside-of-adt.rs | 4 + .../bugs/cycle-iat-inside-of-adt.stderr | 40 +- .../dont-select-if-disabled.rs | 17 + .../dont-select-if-disabled.stderr | 24 + .../issue-109071.no_gate.stderr | 41 + tests/ui/associated-inherent-types/issue-109071.rs | 19 + .../issue-109071.with_gate.stderr | 26 + .../associated-inherent-types/issue-109789.stderr | 4 +- .../ui/associated-inherent-types/issue-111404-0.rs | 14 + .../ui/associated-inherent-types/issue-111404-1.rs | 13 + .../issue-111404-1.stderr | 8 + .../associated-inherent-types/private-in-public.rs | 10 +- .../private-in-public.stderr | 49 +- .../associated-type-bounds/dyn-impl-trait-type.rs | 8 +- .../ui/associated-type-bounds/dyn-rpit-and-let.rs | 8 +- .../implied-in-supertrait.rs | 19 + .../bad-inputs-and-output.current.stderr | 48 + .../bad-inputs-and-output.next.stderr | 48 + .../return-type-notation/bad-inputs-and-output.rs | 2 + .../bad-inputs-and-output.stderr | 48 - .../return-type-notation/basic.current_with.stderr | 11 + .../basic.current_without.stderr | 29 + .../return-type-notation/basic.next_with.stderr | 11 + .../return-type-notation/basic.next_without.stderr | 29 + .../return-type-notation/basic.rs | 14 +- .../return-type-notation/equality.current.stderr | 17 + .../return-type-notation/equality.next.stderr | 17 + .../return-type-notation/equality.rs | 2 + .../return-type-notation/equality.stderr | 17 - tests/ui/associated-type-bounds/rpit.rs | 8 +- .../trait-alias-impl-trait.rs | 8 +- .../dont-suggest-cyclic-constraint.rs | 11 + .../dont-suggest-cyclic-constraint.stderr | 12 + .../associated-types/normalization-debruijn-3.rs | 4 +- tests/ui/async-await/deep-futures-are-freeze.rs | 179 ++ .../async-await/drop-track-bad-field-in-fru.stderr | 2 + tests/ui/async-await/drop-track-field-assign.rs | 2 +- tests/ui/async-await/field-assign.rs | 2 +- .../in-trait/async-associated-types2.rs | 30 - .../in-trait/async-lifetimes-and-bounds.rs | 2 + tests/ui/async-await/in-trait/async-lifetimes.rs | 2 + .../in-trait/missing-feature-flag.current.stderr | 30 + .../in-trait/missing-feature-flag.next.stderr | 30 + .../async-await/in-trait/missing-feature-flag.rs | 23 + .../in-trait/normalize-opaque-with-bound-vars.rs | 64 + .../return-not-existing-pair.current.stderr | 39 + .../in-trait/return-not-existing-pair.next.stderr | 39 + .../in-trait/return-not-existing-pair.rs | 19 + ...ot-existing-type-wrapping-rpitit.current.stderr | 9 + ...n-not-existing-type-wrapping-rpitit.next.stderr | 9 + .../return-not-existing-type-wrapping-rpitit.rs | 20 + ...ssue-64130-4-async-move.no_drop_tracking.stderr | 6 +- tests/ui/async-await/issue-64130-4-async-move.rs | 2 +- .../issue-70935-complex-spans.drop_tracking.stderr | 31 +- ...ue-70935-complex-spans.drop_tracking_mir.stderr | 31 +- ...sue-70935-complex-spans.no_drop_tracking.stderr | 16 +- tests/ui/async-await/issue-70935-complex-spans.rs | 17 +- tests/ui/async-await/issue-78115.rs | 19 + tests/ui/async-await/non-trivial-drop.rs | 2 +- .../issue-110963-early.current.stderr | 37 + .../issue-110963-early.next.stderr | 37 + .../return-type-notation/issue-110963-early.rs | 2 + .../return-type-notation/issue-110963-early.stderr | 37 - .../issue-110963-late.current.stderr | 11 + .../issue-110963-late.next.stderr | 11 + .../return-type-notation/issue-110963-late.rs | 2 + .../return-type-notation/issue-110963-late.stderr | 11 - .../rtn-implied-in-supertrait.rs | 28 + .../rtn-implied-in-supertrait.stderr | 11 + .../return-type-notation/rtn-in-impl-signature.rs | 13 + .../rtn-in-impl-signature.stderr | 18 + .../super-method-bound.current.stderr | 11 + .../super-method-bound.next.stderr | 11 + .../return-type-notation/super-method-bound.rs | 2 + .../return-type-notation/super-method-bound.stderr | 11 - .../supertrait-bound.current.stderr | 11 + .../supertrait-bound.next.stderr | 11 + .../return-type-notation/supertrait-bound.rs | 2 + .../return-type-notation/supertrait-bound.stderr | 11 - .../ty-or-ct-params.current.stderr | 29 + .../ty-or-ct-params.next.stderr | 29 + .../return-type-notation/ty-or-ct-params.rs | 22 + tests/ui/attributes/doc-test-literal.rs | 7 + tests/ui/attributes/doc-test-literal.stderr | 17 + tests/ui/auto-traits/issue-23080-2.current.stderr | 11 + tests/ui/auto-traits/issue-23080-2.next.stderr | 11 + tests/ui/auto-traits/issue-23080-2.rs | 3 + tests/ui/auto-traits/issue-23080-2.stderr | 11 - .../deref-ambiguity-becomes-nonambiguous.rs | 40 + .../deref-ambiguity-becomes-nonambiguous.stderr | 17 + tests/ui/binop/binop-mul-i32-f32.stderr | 4 +- tests/ui/binop/shift-various-bad-types.stderr | 48 +- ...k-thread-local-static-borrow-outlives-fn.stderr | 2 +- tests/ui/borrowck/issue-111554.rs | 28 + tests/ui/borrowck/issue-111554.stderr | 29 + tests/ui/cfg/auxiliary/cfg_false_lib.rs | 6 +- .../ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs | 5 + .../cfg/auxiliary/cfg_false_lib_no_std_before.rs | 8 + tests/ui/cfg/auxiliary/cfged_out.rs | 22 + tests/ui/cfg/cfg-false-feature.rs | 6 +- tests/ui/cfg/cfg-false-feature.stderr | 17 +- tests/ui/cfg/cfg_false_no_std-1.rs | 10 + tests/ui/cfg/cfg_false_no_std-2.rs | 11 + tests/ui/cfg/cfg_false_no_std.rs | 3 +- tests/ui/cfg/cfg_stmt_expr.rs | 2 +- tests/ui/cfg/diagnostics-cross-crate.rs | 31 + tests/ui/cfg/diagnostics-cross-crate.stderr | 53 + tests/ui/cfg/diagnostics-not-a-def.rs | 12 + tests/ui/cfg/diagnostics-not-a-def.stderr | 9 + tests/ui/cfg/diagnostics-reexport.rs | 40 + tests/ui/cfg/diagnostics-reexport.stderr | 47 + tests/ui/cfg/diagnostics-same-crate.rs | 51 + tests/ui/cfg/diagnostics-same-crate.stderr | 47 + tests/ui/chalkify/arithmetic.rs | 20 - tests/ui/chalkify/assert.rs | 6 - tests/ui/chalkify/basic.rs | 12 - tests/ui/chalkify/bugs/async.rs | 25 - tests/ui/chalkify/bugs/async.stderr | 29 - tests/ui/chalkify/builtin-copy-clone.rs | 45 - tests/ui/chalkify/chalk_initial_program.rs | 16 - tests/ui/chalkify/chalk_initial_program.stderr | 18 - tests/ui/chalkify/closure.rs | 38 - tests/ui/chalkify/closure.stderr | 22 - tests/ui/chalkify/generic_impls.rs | 18 - tests/ui/chalkify/generic_impls.stderr | 29 - tests/ui/chalkify/impl_wf.rs | 26 - tests/ui/chalkify/impl_wf.stderr | 29 - tests/ui/chalkify/impl_wf_2.rs | 33 - tests/ui/chalkify/impl_wf_2.stderr | 16 - tests/ui/chalkify/inherent_impl.rs | 42 - tests/ui/chalkify/inherent_impl_min.rs | 27 - tests/ui/chalkify/lower_env1.rs | 14 - tests/ui/chalkify/lower_env2.rs | 16 - tests/ui/chalkify/lower_env3.rs | 16 - tests/ui/chalkify/lower_impl.rs | 17 - tests/ui/chalkify/lower_struct.rs | 8 - tests/ui/chalkify/lower_trait.rs | 11 - tests/ui/chalkify/lower_trait_higher_rank.rs | 9 - tests/ui/chalkify/lower_trait_where_clause.rs | 16 - tests/ui/chalkify/println.rs | 6 - tests/ui/chalkify/projection.rs | 25 - .../ui/chalkify/recursive_where_clause_on_type.rs | 30 - .../chalkify/recursive_where_clause_on_type.stderr | 14 - tests/ui/chalkify/super_trait.rs | 19 - tests/ui/chalkify/trait-objects.rs | 12 - tests/ui/chalkify/trait_implied_bound.rs | 18 - tests/ui/chalkify/type_implied_bound.rs | 29 - tests/ui/chalkify/type_inference.rs | 28 - tests/ui/chalkify/type_inference.stderr | 20 - tests/ui/chalkify/type_wf.rs | 25 - tests/ui/chalkify/type_wf.stderr | 16 - .../match/patterns-capture-analysis.rs | 25 + .../match/patterns-capture-analysis.stderr | 58 +- .../run_pass/disjoint-capture-in-same-closure.rs | 2 +- .../run_pass/lit-pattern-matching-with-methods.rs | 6 +- tests/ui/closures/cannot-call-unsized-via-ptr-2.rs | 11 + .../closures/cannot-call-unsized-via-ptr-2.stderr | 21 + tests/ui/closures/cannot-call-unsized-via-ptr.rs | 10 + .../ui/closures/cannot-call-unsized-via-ptr.stderr | 12 + tests/ui/closures/closure-move-sync.rs | 6 - tests/ui/closures/closure-move-sync.stderr | 20 +- tests/ui/closures/issue-111932.rs | 9 + tests/ui/closures/issue-111932.stderr | 26 + tests/ui/closures/issue-113087.rs | 11 + tests/ui/closures/issue-113087.stderr | 16 + .../issue-72408-nested-closures-exponential.rs | 1 + .../ui/codegen/subtyping-enforces-type-equality.rs | 48 + .../subtyping-enforces-type-equality.stderr | 1 + tests/ui/codegen/subtyping-impacts-selection-1.rs | 44 + tests/ui/codegen/subtyping-impacts-selection-2.rs | 12 + tests/ui/coercion/issue-3794.rs | 32 + .../coherence-inherited-subtyping.old.stderr | 14 - .../coherence-inherited-subtyping.re.stderr | 14 - .../ui/coherence/coherence-inherited-subtyping.rs | 2 - .../coherence/coherence-inherited-subtyping.stderr | 14 + tests/ui/coinduction/canonicalization-rerun.rs | 4 +- .../adt_const_params/const_param_ty_bad.stderr | 20 + .../adt_const_params/const_param_ty_good.rs | 4 +- .../const_param_ty_impl_no_structural_eq.rs | 2 + .../const_param_ty_impl_no_structural_eq.stderr | 23 +- .../adt_const_params/const_param_ty_impl_union.rs | 1 + .../const_param_ty_impl_union.stderr | 14 +- .../const-argument-if-length.full.stderr | 2 +- .../const-argument-if-length.min.stderr | 2 +- ...st-param-type-depends-on-type-param.full.stderr | 14 +- ...nst-param-type-depends-on-type-param.min.stderr | 14 +- .../const-param-type-depends-on-type-param.rs | 1 - .../const-param-with-additional-obligations.rs | 17 + .../const-param-with-additional-obligations.stderr | 11 + .../defaults/default-param-wf-concrete.next.stderr | 9 + .../defaults/default-param-wf-concrete.old.stderr | 9 + .../defaults/default-param-wf-concrete.rs | 3 + .../defaults/default-param-wf-concrete.stderr | 9 - tests/ui/const-generics/exhaustive-value.stderr | 14 +- .../float-generic.adt_const_params.stderr | 2 - .../forbid-non-structural_match-types.rs | 6 +- .../forbid-non-structural_match-types.stderr | 12 +- .../generic_arg_infer/in-signature.rs | 6 +- .../generic_arg_infer/in-signature.stderr | 6 +- .../generic_arg_infer/issue-91614.stderr | 4 +- .../array-size-in-generic-struct-param.full.stderr | 2 +- .../array-size-in-generic-struct-param.min.stderr | 4 +- .../array-size-in-generic-struct-param.rs | 4 + .../generic_const_exprs/eval-privacy.rs | 7 + .../generic_const_exprs/eval-privacy.stderr | 21 +- .../inline-const-in-const-generic-defaults.rs | 9 + .../generic_const_exprs/issue-109141.rs | 13 + .../generic_const_exprs/issue-109141.stderr | 26 + .../generic_const_exprs/issue-80742.stderr | 4 +- .../generic_const_exprs/issue-86710.rs | 2 +- .../generic_const_exprs/issue-96699.rs | 87 + tests/ui/const-generics/invalid-enum.rs | 4 +- tests/ui/const-generics/invalid-enum.stderr | 14 +- tests/ui/const-generics/issue-112505-overflow.rs | 7 + .../ui/const-generics/issue-112505-overflow.stderr | 12 + tests/ui/const-generics/issue-66451.rs | 6 +- tests/ui/const-generics/issue-66451.stderr | 2 +- tests/ui/const-generics/issue-80471.rs | 2 +- tests/ui/const-generics/issue-80471.stderr | 8 +- .../issues/issue-63322-forbid-dyn.full.stderr | 4 +- .../issues/issue-63322-forbid-dyn.rs | 2 +- .../ui/const-generics/issues/issue-67185-2.stderr | 12 +- .../const-generics/issues/issue-70273-assoc-fn.rs | 2 +- .../const-generics/issues/issue-71381.full.stderr | 17 +- tests/ui/const-generics/issues/issue-71381.rs | 10 +- .../const-generics/issues/issue-71611.full.stderr | 11 +- tests/ui/const-generics/issues/issue-71611.rs | 4 +- .../const-generics/issues/issue-74255.min.stderr | 2 +- tests/ui/const-generics/issues/issue-74255.rs | 4 + .../const-generics/issues/issue-74950.min.stderr | 10 +- tests/ui/const-generics/issues/issue-74950.rs | 3 + tests/ui/const-generics/issues/issue-87076.rs | 4 +- tests/ui/const-generics/issues/issue-97278.rs | 2 +- tests/ui/const-generics/issues/issue-97278.stderr | 8 +- tests/ui/const-generics/issues/issue-99641.rs | 4 +- tests/ui/const-generics/issues/issue-99641.stderr | 8 +- tests/ui/const-generics/overlapping_impls.rs | 5 +- .../std/const-generics-range.full.stderr | 39 + .../std/const-generics-range.min.stderr | 12 +- .../ui/const-generics/std/const-generics-range.rs | 3 +- tests/ui/const-generics/transmute-fail.stderr | 4 +- tests/ui/const-ptr/forbidden_slices.stderr | 10 +- tests/ui/consts/assoc_const_generic_impl.rs | 2 +- .../const-eval/const-eval-overflow-3b.stderr | 4 +- .../const-eval/const-eval-overflow-4b.stderr | 4 +- tests/ui/consts/const-eval/erroneous-const.rs | 2 +- tests/ui/consts/const-eval/erroneous-const.stderr | 6 +- tests/ui/consts/const-eval/erroneous-const2.rs | 2 +- tests/ui/consts/const-eval/erroneous-const2.stderr | 6 +- .../const-eval/heap/alloc_intrinsic_errors.stderr | 2 +- .../heap/alloc_intrinsic_nontransient_fail.rs | 4 +- .../heap/alloc_intrinsic_nontransient_fail.stderr | 4 +- .../const-eval/heap/alloc_intrinsic_untyped.rs | 4 +- .../const-eval/heap/alloc_intrinsic_untyped.stderr | 6 +- .../heap/dealloc_intrinsic_incorrect_layout.stderr | 2 +- tests/ui/consts/const-eval/infinite_loop.rs | 4 +- tests/ui/consts/const-eval/infinite_loop.stderr | 23 +- tests/ui/consts/const-eval/issue-52475.rs | 3 +- tests/ui/consts/const-eval/issue-52475.stderr | 22 +- tests/ui/consts/const-eval/issue-70723.rs | 2 +- tests/ui/consts/const-eval/issue-70723.stderr | 14 +- tests/ui/consts/const-eval/promoted_errors.rs | 2 +- tests/ui/consts/const-eval/raw-bytes.32bit.stderr | 14 +- tests/ui/consts/const-eval/raw-bytes.64bit.stderr | 14 +- .../const-eval/stable-metric/ctfe-fn-call.rs | 2 +- .../const-eval/stable-metric/ctfe-fn-call.stderr | 19 +- .../const-eval/stable-metric/ctfe-labelled-loop.rs | 5 +- .../stable-metric/ctfe-labelled-loop.stderr | 27 +- .../const-eval/stable-metric/ctfe-recursion.rs | 3 +- .../const-eval/stable-metric/ctfe-recursion.stderr | 24 +- .../stable-metric/ctfe-simple-loop.allow.stderr | 19 + .../const-eval/stable-metric/ctfe-simple-loop.rs | 12 +- .../stable-metric/ctfe-simple-loop.stderr | 24 - .../stable-metric/ctfe-simple-loop.warn.stderr | 62 + tests/ui/consts/const-eval/ub-enum.32bit.stderr | 4 +- tests/ui/consts/const-eval/ub-enum.64bit.stderr | 4 +- tests/ui/consts/const-eval/ub-uninhabit.stderr | 4 +- tests/ui/consts/const-eval/unwind-abort.rs | 2 +- .../validate_uninhabited_zsts.32bit.stderr | 2 +- .../validate_uninhabited_zsts.64bit.stderr | 2 +- .../const-len-underflow-separate-spans.next.stderr | 15 + .../const-len-underflow-separate-spans.old.stderr | 15 + .../consts/const-len-underflow-separate-spans.rs | 3 + .../const-len-underflow-separate-spans.stderr | 15 - tests/ui/consts/const_in_pattern/issue-73431.rs | 1 + .../const_limit/const_eval_limit_not_reached.rs | 20 - .../const_limit/const_eval_limit_overflow.rs | 15 - .../const_limit/const_eval_limit_overflow.stderr | 10 - .../consts/const_limit/const_eval_limit_reached.rs | 16 - .../const_limit/const_eval_limit_reached.stderr | 12 - .../const_limit/feature-gate-const_eval_limit.rs | 14 - .../feature-gate-const_eval_limit.stderr | 12 - tests/ui/consts/issue-16538.mir.stderr | 29 + tests/ui/consts/issue-16538.rs | 19 + tests/ui/consts/issue-16538.thir.stderr | 29 + tests/ui/consts/issue-28822.rs | 7 + tests/ui/consts/issue-29798.rs | 11 + tests/ui/consts/issue-64506.stderr | 2 +- tests/ui/consts/issue-83182.stderr | 4 +- tests/ui/consts/issue-miri-1910.stderr | 4 +- tests/ui/consts/large_const_alloc.rs | 4 +- tests/ui/consts/miri_unleashed/assoc_const.stderr | 2 +- .../ui/consts/miri_unleashed/raw_mutable_const.rs | 2 +- .../consts/miri_unleashed/raw_mutable_const.stderr | 4 +- tests/ui/consts/missing-larger-array-impl.rs | 9 + tests/ui/consts/missing-larger-array-impl.stderr | 20 + tests/ui/consts/missing_span_in_backtrace.stderr | 4 +- tests/ui/consts/offset_from_ub.stderr | 14 +- tests/ui/consts/raw-ptr-const.rs | 2 +- tests/ui/consts/raw-ptr-const.stderr | 4 +- tests/ui/consts/refs_check_const_eq-issue-88384.rs | 4 +- .../consts/refs_check_const_eq-issue-88384.stderr | 16 +- tests/ui/consts/timeout.rs | 25 + tests/ui/consts/timeout.stderr | 15 + tests/ui/consts/too_generic_eval_ice.stderr | 12 +- tests/ui/deriving/deriving-all-codegen.stdout | 15 + tests/ui/deriving/issue-103157.stderr | 10 +- .../issue-21659-show-relevant-trait-impls-2.stderr | 4 +- .../issue-39802-show-5-trait-impls.stderr | 4 +- .../issue-42599_available_fields_note.stderr | 2 +- ...unicode-confusable-in-float-literal-expt.stderr | 16 +- tests/ui/discrim/discrim-ill-typed.rs | 114 -- tests/ui/discrim/discrim-ill-typed.stderr | 91 - tests/ui/discrim/discrim-overflow-2.rs | 80 - tests/ui/discrim/discrim-overflow-2.stderr | 67 - tests/ui/discrim/discrim-overflow.rs | 99 - tests/ui/discrim/discrim-overflow.stderr | 67 - tests/ui/dst/dst-object-from-unsized-type.stderr | 4 +- tests/ui/duplicate/dupe-symbols-7.rs | 3 - tests/ui/duplicate/dupe-symbols-7.stderr | 2 +- tests/ui/dyn-star/box.rs | 4 +- tests/ui/dyn-star/param-env-infer.current.stderr | 18 - tests/ui/dyn-star/param-env-infer.next.stderr | 73 - tests/ui/dyn-star/param-env-infer.rs | 17 - .../dyn-star/param-env-region-infer.current.stderr | 9 + .../ui/dyn-star/param-env-region-infer.next.stderr | 29 + tests/ui/dyn-star/param-env-region-infer.rs | 22 + tests/ui/empty-allocation-rvalue-non-null.rs | 2 +- tests/ui/empty/empty-macro-use.stderr | 6 +- .../ui/enum-discriminant/discriminant-ill-typed.rs | 114 ++ .../discriminant-ill-typed.stderr | 91 + .../enum-discriminant/discriminant-overflow-2.rs | 80 + .../discriminant-overflow-2.stderr | 67 + .../ui/enum-discriminant/discriminant-overflow.rs | 99 + .../enum-discriminant/discriminant-overflow.stderr | 67 + tests/ui/enum-discriminant/issue-50689.rs | 9 + tests/ui/enum/suggest-default-attribute.stderr | 2 +- tests/ui/error-codes/E0283.stderr | 4 +- tests/ui/error-codes/E0445.rs | 11 + tests/ui/error-codes/E0445.stderr | 49 +- tests/ui/error-codes/E0560.stderr | 2 +- tests/ui/error-codes/E0637.stderr | 7 +- tests/ui/error-codes/E0790.stderr | 4 +- .../become-outside.array.stderr | 9 + .../become-outside.constant.stderr | 9 + tests/ui/explicit-tail-calls/become-outside.rs | 15 + .../ui/explicit-tail-calls/return-lifetime-sub.rs | 13 + tests/ui/explicit-tail-calls/return-mismatches.rs | 28 + .../explicit-tail-calls/return-mismatches.stderr | 27 + tests/ui/extern/extern-crate-visibility.stderr | 8 + ...e-112363-extern-item-where-clauses-debug-ice.rs | 10 + ...2363-extern-item-where-clauses-debug-ice.stderr | 47 + tests/ui/extern/issue-1251.rs | 16 + .../feature-gate-explicit_tail_calls.rs | 9 + .../feature-gate-explicit_tail_calls.stderr | 21 + .../feature-gate-generic_arg_infer.rs | 2 +- ...re-gate-return_type_notation.cfg_current.stderr | 27 + ...ature-gate-return_type_notation.cfg_next.stderr | 27 + ...ure-gate-return_type_notation.no_current.stderr | 13 + ...eature-gate-return_type_notation.no_next.stderr | 13 + .../feature-gate-return_type_notation.rs | 24 +- .../feature-gate-type_alias_impl_trait.rs | 7 +- .../feature-gate-type_privacy_lints.rs | 12 + .../feature-gate-type_privacy_lints.stderr | 93 + tests/ui/fmt/ifmt-unimpl.stderr | 16 +- tests/ui/for-loop-while/issue-1257.rs | 11 + tests/ui/for-loop-while/loop-break-value.rs | 10 +- tests/ui/for/issue-20605.current.stderr | 16 + tests/ui/for/issue-20605.next.stderr | 72 + tests/ui/for/issue-20605.rs | 20 + tests/ui/generator/layout-error.rs | 1 + tests/ui/generator/layout-error.stderr | 20 +- ...-bounds-not-checked-with-right-substitutions.rs | 29 + ...nds-not-checked-with-right-substitutions.stderr | 11 + .../ui/generic-associated-types/issue-88287.stderr | 2 +- tests/ui/generic-associated-types/issue-88595.rs | 1 - .../ui/generic-associated-types/issue-88595.stderr | 26 +- .../generic-associated-types/issue-90014-tait.rs | 23 + .../issue-90014-tait.stderr | 22 + .../generic-associated-types/issue-90014-tait2.rs | 46 + .../issue-90014-tait2.stderr | 12 + ...-incorrect-explicit-lifetime-name-needed.stderr | 7 +- .../post_monomorphization_error_backtrace.rs | 2 +- tests/ui/hashmap/hashmap-memory.rs | 1 + tests/ui/higher-lifetime-bounds.rs | 69 - tests/ui/higher-lifetime-bounds.stderr | 68 - tests/ui/higher-rank-trait-bounds/complex.rs | 28 - .../due-to-where-clause.rs | 13 - .../due-to-where-clause.stderr | 11 - .../higher-rank-trait-bounds/fn-ptr.classic.stderr | 19 - tests/ui/higher-rank-trait-bounds/fn-ptr.rs | 14 - .../hang-on-deeply-nested-dyn.rs | 16 - .../hang-on-deeply-nested-dyn.stderr | 22 - .../hrtb-binder-levels-in-object-types.rs | 29 - .../hrtb-cache-issue-54302.rs | 24 - .../hrtb-cache-issue-54302.stderr | 11 - .../hrtb-conflate-regions.rs | 31 - .../hrtb-conflate-regions.stderr | 20 - .../hrtb-debruijn-in-receiver.rs | 18 - .../hrtb-debruijn-in-receiver.stderr | 14 - .../hrtb-debruijn-object-types-in-closures.rs | 16 - .../hrtb-exists-forall-fn.rs | 18 - .../hrtb-exists-forall-fn.stderr | 12 - .../hrtb-exists-forall-trait-contravariant.rs | 36 - .../hrtb-exists-forall-trait-contravariant.stderr | 11 - .../hrtb-exists-forall-trait-covariant.rs | 37 - .../hrtb-exists-forall-trait-invariant.rs | 29 - .../hrtb-exists-forall-trait-invariant.stderr | 11 - .../hrtb-fn-like-trait-object.rs | 27 - .../higher-rank-trait-bounds/hrtb-fn-like-trait.rs | 27 - .../hrtb-higher-ranker-supertraits-transitive.rs | 50 - ...rtb-higher-ranker-supertraits-transitive.stderr | 23 - .../hrtb-higher-ranker-supertraits.rs | 48 - .../hrtb-higher-ranker-supertraits.stderr | 43 - .../hrtb-identity-fn-borrows.rs | 26 - .../hrtb-identity-fn-borrows.stderr | 14 - .../hrtb-just-for-static.rs | 35 - .../hrtb-just-for-static.stderr | 34 - .../hrtb-malformed-lifetime-generics.rs | 20 - .../hrtb-malformed-lifetime-generics.stderr | 62 - .../higher-rank-trait-bounds/hrtb-opt-in-copy.rs | 28 - tests/ui/higher-rank-trait-bounds/hrtb-parse.rs | 36 - .../hrtb-perfect-forwarding.polonius.stderr | 71 - .../hrtb-perfect-forwarding.rs | 56 - .../hrtb-perfect-forwarding.stderr | 79 - .../hrtb-precedence-of-plus-where-clause.rs | 25 - .../hrtb-precedence-of-plus.rs | 13 - .../hrtb-resolve-lifetime.rs | 14 - .../hrtb-trait-object-paren-notation.rs | 26 - .../hrtb-trait-object-passed-to-closure.rs | 25 - .../higher-rank-trait-bounds/hrtb-type-outlives.rs | 46 - .../hrtb-unboxed-closure-trait.rs | 11 - .../ui/higher-rank-trait-bounds/hrtb-wrong-kind.rs | 7 - .../hrtb-wrong-kind.stderr | 21 - tests/ui/higher-rank-trait-bounds/issue-100689.rs | 29 - tests/ui/higher-rank-trait-bounds/issue-102899.rs | 32 - tests/ui/higher-rank-trait-bounds/issue-30786.rs | 136 -- .../ui/higher-rank-trait-bounds/issue-30786.stderr | 46 - .../issue-36139-normalize-closure-sig.rs | 19 - tests/ui/higher-rank-trait-bounds/issue-39292.rs | 17 - tests/ui/higher-rank-trait-bounds/issue-42114.rs | 20 - tests/ui/higher-rank-trait-bounds/issue-43623.rs | 21 - tests/ui/higher-rank-trait-bounds/issue-46989.rs | 40 - .../ui/higher-rank-trait-bounds/issue-46989.stderr | 11 - tests/ui/higher-rank-trait-bounds/issue-57639.rs | 29 - tests/ui/higher-rank-trait-bounds/issue-58451.rs | 13 - .../ui/higher-rank-trait-bounds/issue-58451.stderr | 19 - tests/ui/higher-rank-trait-bounds/issue-59311.rs | 22 - .../ui/higher-rank-trait-bounds/issue-59311.stderr | 18 - tests/ui/higher-rank-trait-bounds/issue-60283.rs | 20 - .../issue-62203-hrtb-ice.rs | 54 - .../issue-62203-hrtb-ice.stderr | 66 - tests/ui/higher-rank-trait-bounds/issue-88446.rs | 35 - .../issue-88586-hr-self-outlives-in-trait-def.rs | 13 - tests/ui/higher-rank-trait-bounds/issue-90177.rs | 32 - tests/ui/higher-rank-trait-bounds/issue-95034.rs | 80 - .../issue-95230.new.stderr | 19 - tests/ui/higher-rank-trait-bounds/issue-95230.rs | 11 - .../normalize-under-binder/issue-44005.rs | 31 - .../normalize-under-binder/issue-56556.rs | 30 - .../normalize-under-binder/issue-62529-1.rs | 88 - .../normalize-under-binder/issue-62529-2.rs | 33 - .../normalize-under-binder/issue-62529-3.rs | 32 - .../normalize-under-binder/issue-62529-3.stderr | 19 - .../normalize-under-binder/issue-62529-4.rs | 39 - .../normalize-under-binder/issue-62529-5.rs | 27 - .../normalize-under-binder/issue-62529-6.rs | 77 - .../normalize-under-binder/issue-70120.rs | 31 - .../issue-71955.migrate.stderr | 79 - .../normalize-under-binder/issue-71955.rs | 51 - .../normalize-under-binder/issue-71955.stderr | 79 - .../normalize-under-binder/issue-74261.rs | 30 - .../normalize-under-binder/issue-76956.rs | 15 - .../normalize-under-binder/issue-80706.rs | 71 - .../normalize-under-binder/issue-80956.rs | 21 - .../normalize-under-binder/issue-81809.rs | 21 - .../normalize-under-binder/issue-85455.rs | 19 - .../normalize-under-binder/issue-85455.stderr | 25 - .../normalize-under-binder/issue-89118.rs | 32 - .../normalize-under-binder/issue-89118.stderr | 69 - .../normalize-under-binder/issue-89436.rs | 44 - .../normalize-under-binder/issue-90612.rs | 41 - .../normalize-under-binder/issue-90638.rs | 35 - .../normalize-under-binder/issue-90875.rs | 31 - .../normalize-under-binder/issue-90950.rs | 53 - .../normalize-under-binder/issue-90950.stderr | 21 - .../norm-before-method-resolution.rs | 23 - .../norm-before-method-resolution.stderr | 18 - tests/ui/higher-ranked/higher-lifetime-bounds.rs | 69 + .../ui/higher-ranked/higher-lifetime-bounds.stderr | 68 + tests/ui/higher-ranked/leak-check-in-selection.rs | 24 + ...subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr | 17 + .../subtype/hr-subtype.bound_a_vs_free_x.stderr | 17 + .../hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr | 31 + .../hr-subtype.free_inv_x_vs_free_inv_y.stderr | 42 + .../subtype/hr-subtype.free_x_vs_free_y.stderr | 19 + tests/ui/higher-ranked/subtype/hr-subtype.rs | 111 ++ .../subtype/placeholder-pattern-fail.rs | 25 + .../subtype/placeholder-pattern-fail.stderr | 12 + .../higher-ranked/subtype/placeholder-pattern.rs | 18 + tests/ui/higher-ranked/subtype/return-static.rs | 13 + tests/ui/higher-ranked/trait-bounds/complex.rs | 28 + .../trait-bounds/due-to-where-clause.rs | 13 + .../trait-bounds/due-to-where-clause.stderr | 11 + .../trait-bounds/fn-ptr.classic.stderr | 19 + tests/ui/higher-ranked/trait-bounds/fn-ptr.rs | 14 + .../trait-bounds/future.classic.stderr | 6 + tests/ui/higher-ranked/trait-bounds/future.rs | 38 + .../trait-bounds/hang-on-deeply-nested-dyn.rs | 16 + .../trait-bounds/hang-on-deeply-nested-dyn.stderr | 22 + .../hrtb-binder-levels-in-object-types.rs | 29 + .../trait-bounds/hrtb-cache-issue-54302.rs | 24 + .../trait-bounds/hrtb-cache-issue-54302.stderr | 11 + .../trait-bounds/hrtb-conflate-regions.rs | 31 + .../trait-bounds/hrtb-conflate-regions.stderr | 20 + .../trait-bounds/hrtb-debruijn-in-receiver.rs | 18 + .../trait-bounds/hrtb-debruijn-in-receiver.stderr | 14 + .../hrtb-debruijn-object-types-in-closures.rs | 16 + .../trait-bounds/hrtb-exists-forall-fn.rs | 18 + .../trait-bounds/hrtb-exists-forall-fn.stderr | 12 + .../hrtb-exists-forall-trait-contravariant.rs | 36 + .../hrtb-exists-forall-trait-contravariant.stderr | 11 + .../hrtb-exists-forall-trait-covariant.rs | 37 + .../hrtb-exists-forall-trait-invariant.rs | 29 + .../hrtb-exists-forall-trait-invariant.stderr | 11 + .../trait-bounds/hrtb-fn-like-trait-object.rs | 27 + .../trait-bounds/hrtb-fn-like-trait.rs | 27 + .../hrtb-higher-ranker-supertraits-transitive.rs | 50 + ...rtb-higher-ranker-supertraits-transitive.stderr | 23 + .../trait-bounds/hrtb-higher-ranker-supertraits.rs | 48 + .../hrtb-higher-ranker-supertraits.stderr | 43 + .../trait-bounds/hrtb-identity-fn-borrows.rs | 26 + .../trait-bounds/hrtb-identity-fn-borrows.stderr | 14 + .../trait-bounds/hrtb-just-for-static.rs | 35 + .../trait-bounds/hrtb-just-for-static.stderr | 34 + .../hrtb-malformed-lifetime-generics.rs | 20 + .../hrtb-malformed-lifetime-generics.stderr | 62 + .../higher-ranked/trait-bounds/hrtb-opt-in-copy.rs | 28 + tests/ui/higher-ranked/trait-bounds/hrtb-parse.rs | 36 + .../hrtb-perfect-forwarding.polonius.stderr | 71 + .../trait-bounds/hrtb-perfect-forwarding.rs | 56 + .../trait-bounds/hrtb-perfect-forwarding.stderr | 79 + .../hrtb-precedence-of-plus-where-clause.rs | 25 + .../trait-bounds/hrtb-precedence-of-plus.rs | 13 + .../trait-bounds/hrtb-resolve-lifetime.rs | 14 + .../hrtb-trait-object-paren-notation.rs | 26 + .../hrtb-trait-object-passed-to-closure.rs | 25 + .../trait-bounds/hrtb-type-outlives.rs | 46 + .../trait-bounds/hrtb-unboxed-closure-trait.rs | 11 + .../higher-ranked/trait-bounds/hrtb-wrong-kind.rs | 7 + .../trait-bounds/hrtb-wrong-kind.stderr | 21 + .../ui/higher-ranked/trait-bounds/issue-100689.rs | 29 + .../ui/higher-ranked/trait-bounds/issue-102899.rs | 32 + tests/ui/higher-ranked/trait-bounds/issue-30786.rs | 136 ++ .../higher-ranked/trait-bounds/issue-30786.stderr | 46 + .../issue-36139-normalize-closure-sig.rs | 19 + tests/ui/higher-ranked/trait-bounds/issue-39292.rs | 17 + tests/ui/higher-ranked/trait-bounds/issue-42114.rs | 20 + tests/ui/higher-ranked/trait-bounds/issue-43623.rs | 21 + tests/ui/higher-ranked/trait-bounds/issue-46989.rs | 40 + .../higher-ranked/trait-bounds/issue-46989.stderr | 11 + tests/ui/higher-ranked/trait-bounds/issue-57639.rs | 29 + tests/ui/higher-ranked/trait-bounds/issue-58451.rs | 13 + .../higher-ranked/trait-bounds/issue-58451.stderr | 19 + tests/ui/higher-ranked/trait-bounds/issue-59311.rs | 22 + .../higher-ranked/trait-bounds/issue-59311.stderr | 18 + tests/ui/higher-ranked/trait-bounds/issue-60283.rs | 20 + .../trait-bounds/issue-62203-hrtb-ice.rs | 54 + .../trait-bounds/issue-62203-hrtb-ice.stderr | 66 + tests/ui/higher-ranked/trait-bounds/issue-88446.rs | 35 + .../issue-88586-hr-self-outlives-in-trait-def.rs | 13 + tests/ui/higher-ranked/trait-bounds/issue-90177.rs | 32 + tests/ui/higher-ranked/trait-bounds/issue-95034.rs | 80 + .../trait-bounds/issue-95230.next.stderr | 19 + tests/ui/higher-ranked/trait-bounds/issue-95230.rs | 11 + .../normalize-under-binder/issue-44005.rs | 31 + .../normalize-under-binder/issue-56556.rs | 30 + .../normalize-under-binder/issue-62529-1.rs | 88 + .../normalize-under-binder/issue-62529-2.rs | 33 + .../normalize-under-binder/issue-62529-3.rs | 32 + .../normalize-under-binder/issue-62529-3.stderr | 19 + .../normalize-under-binder/issue-62529-4.rs | 39 + .../normalize-under-binder/issue-62529-5.rs | 27 + .../normalize-under-binder/issue-62529-6.rs | 77 + .../normalize-under-binder/issue-70120.rs | 31 + .../issue-71955.migrate.stderr | 79 + .../normalize-under-binder/issue-71955.rs | 51 + .../normalize-under-binder/issue-71955.stderr | 79 + .../normalize-under-binder/issue-74261.rs | 30 + .../normalize-under-binder/issue-76956.rs | 15 + .../normalize-under-binder/issue-80706.rs | 71 + .../normalize-under-binder/issue-80956.rs | 21 + .../normalize-under-binder/issue-81809.rs | 21 + .../normalize-under-binder/issue-85455.rs | 19 + .../normalize-under-binder/issue-85455.stderr | 25 + .../normalize-under-binder/issue-89118.rs | 32 + .../normalize-under-binder/issue-89118.stderr | 69 + .../normalize-under-binder/issue-89436.rs | 44 + .../normalize-under-binder/issue-90612.rs | 41 + .../normalize-under-binder/issue-90638.rs | 35 + .../normalize-under-binder/issue-90875.rs | 31 + .../normalize-under-binder/issue-90950.rs | 53 + .../normalize-under-binder/issue-90950.stderr | 21 + .../norm-before-method-resolution.rs | 23 + .../norm-before-method-resolution.stderr | 18 + ...subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr | 17 - .../hr-subtype/hr-subtype.bound_a_vs_free_x.stderr | 17 - .../hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr | 31 - .../hr-subtype.free_inv_x_vs_free_inv_y.stderr | 42 - .../hr-subtype/hr-subtype.free_x_vs_free_y.stderr | 19 - tests/ui/hr-subtype/hr-subtype.rs | 111 -- tests/ui/hr-subtype/placeholder-pattern-fail.rs | 25 - .../ui/hr-subtype/placeholder-pattern-fail.stderr | 12 - tests/ui/hr-subtype/placeholder-pattern.rs | 18 - tests/ui/hr-subtype/return-static.rs | 13 - tests/ui/hygiene/no_implicit_prelude-2018.stderr | 6 +- tests/ui/impl-trait/auto-trait-leak.rs | 6 +- tests/ui/impl-trait/auto-trait-leak.stderr | 151 +- tests/ui/impl-trait/autoderef.rs | 2 + .../coherence-treats-tait-ambig.current.stderr | 13 + .../coherence-treats-tait-ambig.next.stderr | 13 + tests/ui/impl-trait/coherence-treats-tait-ambig.rs | 19 + .../impl-trait/deduce-signature-from-supertrait.rs | 4 +- tests/ui/impl-trait/defined-by-trait-resolution.rs | 12 + .../dont-suggest-box-on-empty-else-arm.rs | 9 + .../dont-suggest-box-on-empty-else-arm.stderr | 16 + tests/ui/impl-trait/equality.stderr | 4 +- .../impl-trait/in-assoc-type-unconstrained.stderr | 4 +- tests/ui/impl-trait/in-assoc-type.rs | 3 + tests/ui/impl-trait/in-assoc-type.stderr | 6 +- tests/ui/impl-trait/in-trait/foreign.rs | 4 + .../impl-trait/in-trait/issue-102140.next.stderr | 6 +- .../in-trait/method-signature-matches.lt.stderr | 21 + .../method-signature-matches.mismatch.stderr | 20 + .../method-signature-matches.mismatch_async.stderr | 20 + .../in-trait/method-signature-matches.rs | 21 +- .../in-trait/method-signature-matches.stderr | 74 - .../method-signature-matches.too_few.stderr | 12 + .../method-signature-matches.too_many.stderr | 12 + .../return-dont-satisfy-bounds.current.stderr | 16 + .../return-dont-satisfy-bounds.next.stderr | 16 + .../in-trait/return-dont-satisfy-bounds.rs | 19 + .../in-trait/signature-mismatch.current.stderr | 65 +- .../in-trait/signature-mismatch.next.stderr | 65 +- tests/ui/impl-trait/in-trait/signature-mismatch.rs | 55 +- .../impl-trait/in-trait/suggest-missing-item.fixed | 25 + .../ui/impl-trait/in-trait/suggest-missing-item.rs | 21 + .../in-trait/suggest-missing-item.stderr | 21 + .../in-trait/unconstrained-lt.current.stderr | 9 + .../in-trait/unconstrained-lt.next.stderr | 9 + tests/ui/impl-trait/in-trait/unconstrained-lt.rs | 16 + tests/ui/impl-trait/in-trait/variances-of-gat.rs | 19 + .../impl-trait/in-trait/wf-bounds.current.stderr | 27 +- tests/ui/impl-trait/in-trait/wf-bounds.next.stderr | 27 +- tests/ui/impl-trait/in-trait/wf-bounds.rs | 7 + tests/ui/impl-trait/issue-103181-2.rs | 2 + tests/ui/impl-trait/issue-103181-2.stderr | 57 +- tests/ui/impl-trait/issue-55872-3.rs | 1 - tests/ui/impl-trait/issue-55872-3.stderr | 6 +- tests/ui/impl-trait/issues/issue-65581.rs | 1 - tests/ui/impl-trait/issues/issue-70877.rs | 4 +- tests/ui/impl-trait/issues/issue-70877.stderr | 6 +- tests/ui/impl-trait/issues/issue-74282.rs | 9 +- tests/ui/impl-trait/issues/issue-74282.stderr | 18 +- tests/ui/impl-trait/issues/issue-78722-2.rs | 22 + tests/ui/impl-trait/issues/issue-78722-2.stderr | 32 + tests/ui/impl-trait/issues/issue-78722.rs | 3 +- tests/ui/impl-trait/issues/issue-78722.stderr | 6 +- .../impl-trait/multiple-defining-usages-in-body.rs | 2 +- .../multiple-defining-usages-in-body.stderr | 10 +- .../ui/impl-trait/nested-return-type2-tait.stderr | 4 - .../ui/impl-trait/nested-return-type3-tait.stderr | 4 - .../ui/impl-trait/nested-return-type3-tait2.stderr | 4 - .../impl-trait/normalize-opaque-with-bound-vars.rs | 27 + ...pe-alias-impl-trait-declaration-too-subtle-2.rs | 3 +- ...lias-impl-trait-declaration-too-subtle-2.stderr | 15 - ...-alias-impl-trait-declaration-too-subtle.stderr | 4 +- .../recursive-type-alias-impl-trait-declaration.rs | 3 +- ...ursive-type-alias-impl-trait-declaration.stderr | 15 + tests/ui/impl-trait/reveal-during-codegen.rs | 11 + .../static-lifetime-return-position-impl-trait.rs | 12 + tests/ui/impl-trait/universal_wrong_hrtb.rs | 2 +- tests/ui/impl-trait/universal_wrong_hrtb.stderr | 10 +- .../implied-bounds-unconstrained-1.rs | 28 + .../implied-bounds-unconstrained-2.rs | 20 + tests/ui/implied-bounds/references-err.rs | 22 + tests/ui/implied-bounds/references-err.stderr | 9 + tests/ui/imports/auxiliary/issue-85992-extern-1.rs | 6 + tests/ui/imports/auxiliary/issue-85992-extern-2.rs | 1 + tests/ui/imports/issue-55884-2.rs | 1 + tests/ui/imports/issue-55884-2.stderr | 6 +- tests/ui/imports/issue-56125.stderr | 15 +- tests/ui/imports/issue-57539.stderr | 5 +- tests/ui/imports/issue-85992.rs | 11 + tests/ui/imports/issue-85992.stderr | 9 + tests/ui/inference/deref-suggestion.stderr | 13 +- .../elided-lifetime-being-infer-vars.rs | 11 + tests/ui/intrinsics/panic-uninitialized-zeroed.rs | 2 +- tests/ui/issue-94866.rs | 14 - tests/ui/issue-94866.stderr | 21 - tests/ui/issues/issue-100605.stderr | 15 +- tests/ui/issues/issue-11047.rs | 4 +- tests/ui/issues/issue-11680.stderr | 8 +- tests/ui/issues/issue-11709.rs | 4 +- tests/ui/issues/issue-11740.rs | 2 +- tests/ui/issues/issue-11771.stderr | 32 +- tests/ui/issues/issue-12133-3.rs | 2 +- tests/ui/issues/issue-1251.rs | 16 - tests/ui/issues/issue-1257.rs | 11 - tests/ui/issues/issue-13167.rs | 2 + tests/ui/issues/issue-1460.stderr | 4 +- tests/ui/issues/issue-15734.rs | 4 +- tests/ui/issues/issue-16538.mir.stderr | 29 - tests/ui/issues/issue-16538.rs | 19 - tests/ui/issues/issue-16538.thir.stderr | 29 - tests/ui/issues/issue-17954.stderr | 2 +- tests/ui/issues/issue-18389.rs | 8 + tests/ui/issues/issue-18389.stderr | 27 +- tests/ui/issues/issue-1871.rs | 12 - tests/ui/issues/issue-1871.stderr | 9 - tests/ui/issues/issue-20605.rs | 6 - tests/ui/issues/issue-20605.stderr | 16 - tests/ui/issues/issue-2063-resource.rs | 14 - tests/ui/issues/issue-2063.rs | 22 - tests/ui/issues/issue-20644.rs | 2 +- tests/ui/issues/issue-23808.rs | 8 +- tests/ui/issues/issue-24352.stderr | 4 +- tests/ui/issues/issue-28822.rs | 7 - tests/ui/issues/issue-29798.rs | 11 - tests/ui/issues/issue-3008-1.rs | 12 - tests/ui/issues/issue-3008-1.stderr | 17 - tests/ui/issues/issue-3008-2.rs | 6 - tests/ui/issues/issue-3008-2.stderr | 14 - tests/ui/issues/issue-3008-3.rs | 10 - tests/ui/issues/issue-3008-3.stderr | 14 - tests/ui/issues/issue-32709.stderr | 2 +- tests/ui/issues/issue-35570.rs | 1 - tests/ui/issues/issue-35570.stderr | 12 +- .../issue-37311-type-length-limit/issue-37311.rs | 1 + .../issue-37311.stderr | 4 +- tests/ui/issues/issue-3794.rs | 32 - tests/ui/issues/issue-50582.stderr | 16 +- tests/ui/issues/issue-50689.rs | 9 - tests/ui/issues/issue-50811.rs | 1 + tests/ui/issues/issue-50825-1.rs | 22 - tests/ui/issues/issue-50825.rs | 15 - tests/ui/issues/issue-51714.rs | 10 +- tests/ui/issues/issue-51714.stderr | 6 +- tests/ui/issues/issue-52049.stderr | 4 +- tests/ui/issues/issue-5439.stderr | 2 +- tests/ui/issues/issue-5883.rs | 2 +- tests/ui/issues/issue-5883.stderr | 18 +- tests/ui/issues/issue-67552.rs | 1 + tests/ui/issues/issue-67552.stderr | 4 +- tests/ui/issues/issue-78115.rs | 19 - tests/ui/issues/issue-85461.rs | 1 + .../invalid-iterator-chain-with-int-infer.stderr | 2 +- tests/ui/iterators/invalid-iterator-chain.stderr | 10 +- .../ui/iterators/issue-58952-filter-type-length.rs | 2 + .../layout/cannot-transmute-unnormalizable-type.rs | 22 + .../cannot-transmute-unnormalizable-type.stderr | 19 + tests/ui/let-else/let-else-ref-bindings.stderr | 18 + tests/ui/lexer/lex-bad-char-literals-1.stderr | 4 +- ...ue-90600-expected-return-static-indirect.stderr | 2 +- tests/ui/limits/huge-array-simple-32.rs | 3 - tests/ui/limits/huge-array-simple-32.stderr | 2 +- tests/ui/limits/huge-array-simple-64.rs | 3 - tests/ui/limits/huge-array-simple-64.stderr | 2 +- tests/ui/limits/huge-array.rs | 4 - tests/ui/limits/huge-array.stderr | 2 +- tests/ui/limits/huge-enum.rs | 4 - tests/ui/limits/huge-enum.stderr | 2 +- tests/ui/limits/huge-struct.rs | 4 - tests/ui/limits/huge-struct.stderr | 2 +- tests/ui/limits/issue-15919-32.rs | 4 - tests/ui/limits/issue-15919-32.stderr | 2 +- tests/ui/limits/issue-15919-64.rs | 4 - tests/ui/limits/issue-15919-64.stderr | 2 +- tests/ui/limits/issue-17913.rs | 4 - tests/ui/limits/issue-56762.rs | 3 - tests/ui/limits/issue-56762.stderr | 4 +- tests/ui/linkage-attr/incompatible-flavor.rs | 6 + tests/ui/linkage-attr/incompatible-flavor.stderr | 6 + tests/ui/linkage-attr/issue-10755.rs | 2 +- tests/ui/linkage-attr/linkage3.rs | 4 - tests/ui/linkage-attr/linkage3.stderr | 2 +- tests/ui/linkage-attr/unstable-flavor.bpf.stderr | 2 + tests/ui/linkage-attr/unstable-flavor.ptx.stderr | 2 + tests/ui/linkage-attr/unstable-flavor.rs | 14 + .../lint/invalid-nan-comparison-suggestion.fixed | 36 + tests/ui/lint/invalid-nan-comparison-suggestion.rs | 39 + .../lint/invalid-nan-comparison-suggestion.stderr | 114 ++ tests/ui/lint/invalid-nan-comparison.rs | 51 + tests/ui/lint/invalid-nan-comparison.stderr | 159 ++ tests/ui/lint/invalid_from_utf8.rs | 93 + tests/ui/lint/invalid_from_utf8.stderr | 110 ++ tests/ui/lint/issue-99387.rs | 4 +- tests/ui/lint/issue-99387.stderr | 15 + tests/ui/lint/lint-attr-everywhere-early.rs | 2 +- tests/ui/lint/lint-attr-everywhere-late.rs | 2 +- tests/ui/lint/lint-ctypes-113436-1.rs | 28 + tests/ui/lint/lint-ctypes-113436-1.stderr | 35 + tests/ui/lint/lint-ctypes-113436.rs | 34 + tests/ui/lint/lint-ctypes-113900.rs | 12 + tests/ui/lint/lint-ctypes-73249-2.rs | 8 +- tests/ui/lint/lint-ctypes-73249-2.stderr | 6 +- tests/ui/lint/lint-ctypes-73251-1.rs | 6 +- tests/ui/lint/lint-ctypes-73251-1.stderr | 6 +- tests/ui/lint/lint-ctypes-73251-2.rs | 2 +- tests/ui/lint/lint-ctypes-73251-2.stderr | 6 +- tests/ui/lint/lint-ctypes-73251.rs | 4 +- tests/ui/lint/lint-ctypes-94223.rs | 42 + tests/ui/lint/lint-ctypes-94223.stderr | 126 ++ tests/ui/lint/lint-unnecessary-parens.fixed | 8 + tests/ui/lint/lint-unnecessary-parens.rs | 8 + tests/ui/lint/lint-unnecessary-parens.stderr | 86 +- tests/ui/lint/opaque-ty-ffi-unsafe.rs | 4 +- tests/ui/lint/opaque-ty-ffi-unsafe.stderr | 6 +- tests/ui/lint/reference_casting.rs | 51 + tests/ui/lint/reference_casting.stderr | 68 + .../trivial-casts-featuring-type-ascription.stderr | 4 +- tests/ui/lint/type-overflow.stderr | 28 +- tests/ui/lint/undropped_manually_drops.rs | 19 + tests/ui/lint/undropped_manually_drops.stderr | 42 + tests/ui/lint/unused/lint-unused-extern-crate.rs | 2 +- tests/ui/lint/unused/lint-unused-imports.rs | 2 +- tests/ui/lint/unused/lint-unused-variables.rs | 4 +- tests/ui/lint/unused/must-use-block-expr.fixed | 36 + tests/ui/lint/unused/must-use-block-expr.rs | 36 + tests/ui/lint/unused/must-use-block-expr.stderr | 51 + tests/ui/lint/unused_import_warning_issue_45268.rs | 8 +- tests/ui/loops/dont-suggest-break-thru-item.rs | 55 + tests/ui/loops/dont-suggest-break-thru-item.stderr | 55 + tests/ui/macros/auxiliary/proc_macro_sequence.rs | 5 - .../ui/macros/builtin-prelude-no-accidents.stderr | 32 +- tests/ui/macros/builtin-std-paths-fail.stderr | 3 + tests/ui/macros/format-args-temporaries.rs | 10 +- tests/ui/macros/issue-112342-1.rs | 49 + tests/ui/macros/issue-112342-1.stderr | 64 + tests/ui/macros/issue-112342-2.rs | 39 + tests/ui/macros/issue-112342-2.stderr | 24 + tests/ui/macros/issue-88228.rs | 5 +- tests/ui/macros/issue-88228.stderr | 14 +- tests/ui/macros/macro-comma-support-rpass.rs | 4 +- tests/ui/macros/macro-outer-attributes.stderr | 5 + tests/ui/macros/macro-use-wrong-name.stderr | 12 +- tests/ui/macros/same-sequence-span.stderr | 7 +- tests/ui/match/issue-112438.rs | 11 + tests/ui/match/issue-113012.rs | 12 + tests/ui/match/issue-70972-dyn-trait.rs | 2 +- tests/ui/match/issue-70972-dyn-trait.stderr | 2 +- tests/ui/mir/issue-101844.rs | 2 +- tests/ui/mir/issue-112269.rs | 9 + tests/ui/mir/issue-112269.stderr | 31 + tests/ui/mir/issue-80949.rs | 2 +- tests/ui/mir/issue66339.rs | 2 +- tests/ui/mir/ssa-analysis-regression-50041.rs | 11 +- tests/ui/mir/thir-constparam-temp.rs | 4 +- tests/ui/mir/thir-constparam-temp.stderr | 6 +- tests/ui/mismatched_types/E0053.stderr | 2 +- tests/ui/mismatched_types/binops.stderr | 72 +- tests/ui/mismatched_types/issue-112036.rs | 7 + tests/ui/mismatched_types/issue-112036.stderr | 15 + .../suggest-option-asderef-inference-var.rs | 9 + .../suggest-option-asderef-inference-var.stderr | 24 + .../suggest-option-asderef-unfixable.rs | 34 + .../suggest-option-asderef-unfixable.stderr | 75 + .../mismatched_types/suggest-option-asderef.fixed | 39 + .../ui/mismatched_types/suggest-option-asderef.rs | 39 + .../mismatched_types/suggest-option-asderef.stderr | 88 + tests/ui/missing/missing-macro-use.stderr | 6 +- .../never_type/diverging-fallback-control-flow.rs | 12 +- .../diverging-fallback-no-leak.fallback.stderr | 2 +- tests/ui/never_type/issue-13352.stderr | 4 +- tests/ui/nll/assign-while-to-immutable.rs | 4 +- .../nll/issue-112604-closure-output-normalize.rs | 49 + tests/ui/nll/issue-53119.rs | 2 + tests/ui/nll/issue-54943-3.rs | 2 +- .../ui/nll/ty-outlives/impl-trait-captures.stderr | 4 +- .../ui/nll/user-annotations/normalization-2.stderr | 2 +- .../issue-8460-const.noopt.stderr | 12 +- .../numbers-arithmetic/issue-8460-const.opt.stderr | 12 +- ...ssue-8460-const.opt_with_overflow_checks.stderr | 12 +- .../not-suggest-float-literal.stderr | 50 +- .../suggest-float-literal.stderr | 32 +- tests/ui/object-safety/assoc_type_bounds_sized.rs | 17 +- .../object-safety/assoc_type_bounds_sized.stderr | 12 - .../assoc_type_bounds_sized_others.rs | 25 + .../assoc_type_bounds_sized_others.stderr | 21 + .../assoc_type_bounds_sized_unnecessary.rs | 17 + .../assoc_type_bounds_sized_unnecessary.stderr | 27 + .../object-safety/assoc_type_bounds_sized_used.rs | 20 + .../assoc_type_bounds_sized_used.stderr | 53 + tests/ui/offset-of/offset-of-dst-field.rs | 2 + tests/ui/offset-of/offset-of-dst-field.stderr | 41 +- tests/ui/offset-of/offset-of-must-use.rs | 9 + tests/ui/offset-of/offset-of-must-use.stderr | 16 + tests/ui/offset-of/offset-of-output-type.stderr | 20 +- tests/ui/offset-of/offset-of-tuple-nested.rs | 32 + tests/ui/offset-of/offset-of-tuple.rs | 54 + tests/ui/offset-of/offset-of-tuple.stderr | 226 +++ tests/ui/offset-of/offset-of-unsized.rs | 16 + tests/ui/on-unimplemented/multiple-impls.stderr | 18 +- tests/ui/on-unimplemented/slice-index.stderr | 2 +- tests/ui/on-unimplemented/sum.stderr | 4 +- tests/ui/packed/issue-27060-2.stderr | 2 +- tests/ui/parser/bad-escape-suggest-raw-string.rs | 2 +- .../ui/parser/bad-escape-suggest-raw-string.stderr | 2 +- tests/ui/parser/bad-interpolated-block.stderr | 12 + tests/ui/parser/byte-literals.stderr | 4 +- tests/ui/parser/byte-string-literals.stderr | 4 +- tests/ui/parser/foreign-ty-semantic-fail.rs | 1 + tests/ui/parser/foreign-ty-semantic-fail.stderr | 13 +- tests/ui/parser/issue-112188.fixed | 14 + tests/ui/parser/issue-112188.rs | 14 + tests/ui/parser/issue-112188.stderr | 37 + tests/ui/parser/issue-113342.rs | 9 + tests/ui/parser/issue-113342.stderr | 11 + tests/ui/parser/issue-49257.stderr | 2 +- tests/ui/parser/issues/issue-111692.rs | 32 + tests/ui/parser/issues/issue-111692.stderr | 46 + tests/ui/parser/issues/issue-112458.rs | 4 + tests/ui/parser/issues/issue-112458.stderr | 15 + tests/ui/parser/labeled-no-colon-expr.stderr | 4 + tests/ui/parser/lit-err-in-macro.rs | 10 + tests/ui/parser/lit-err-in-macro.stderr | 8 + ...d-call-on-struct-literal-in-if-condition.stderr | 2 +- tests/ui/parser/typod-const-in-const-param-def.rs | 16 + .../parser/typod-const-in-const-param-def.stderr | 46 + tests/ui/parser/utf16-be-without-bom.stderr | Bin 3537 -> 3641 bytes tests/ui/parser/utf16-le-without-bom.stderr | Bin 3500 -> 3603 bytes tests/ui/pattern/byte-string-inference.rs | 15 + tests/ui/pattern/issue-110508.rs | 38 + tests/ui/pattern/issue-72565.rs | 2 +- tests/ui/pattern/issue-72565.stderr | 2 +- tests/ui/pattern/issue-94866.rs | 14 + tests/ui/pattern/issue-94866.stderr | 21 + .../empty-match.exhaustive_patterns.stderr | 22 +- .../pattern/usefulness/empty-match.normal.stderr | 22 +- tests/ui/pattern/usefulness/empty-match.rs | 8 + tests/ui/pattern/usefulness/issue-3601.rs | 17 +- tests/ui/pattern/usefulness/issue-3601.stderr | 5 +- .../ui/pattern/usefulness/match-non-exhaustive.rs | 1 + .../pattern/usefulness/match-non-exhaustive.stderr | 1 + tests/ui/polymorphization/drop_shims/simple.rs | 2 +- tests/ui/polymorphization/drop_shims/transitive.rs | 2 +- .../ui/privacy/effective_visibilities_full_priv.rs | 21 + .../effective_visibilities_full_priv.stderr | 26 + tests/ui/privacy/export-tag-variant.stderr | 4 +- tests/ui/privacy/privacy-in-paths.stderr | 12 +- tests/ui/privacy/privacy-ufcs.stderr | 4 +- tests/ui/privacy/privacy1.stderr | 28 +- .../ui/privacy/private-in-public-non-principal.rs | 7 + .../privacy/private-in-public-non-principal.stderr | 25 +- tests/ui/privacy/private-inferred-type-1.rs | 10 + tests/ui/privacy/private-inferred-type-1.stderr | 18 +- .../sealed-traits/private-trait-non-local.rs | 4 + .../sealed-traits/private-trait-non-local.stderr | 12 + tests/ui/privacy/sealed-traits/private-trait.rs | 10 + .../ui/privacy/sealed-traits/private-trait.stderr | 17 + .../privacy/sealed-traits/re-exported-trait.fixed | 13 + .../ui/privacy/sealed-traits/re-exported-trait.rs | 13 + .../privacy/sealed-traits/re-exported-trait.stderr | 19 + .../ui/privacy/sealed-traits/sealed-trait-local.rs | 19 + .../sealed-traits/sealed-trait-local.stderr | 16 + tests/ui/privacy/unnameable_types.rs | 30 + tests/ui/privacy/unnameable_types.stderr | 38 + tests/ui/privacy/where-priv-type.rs | 12 + tests/ui/privacy/where-priv-type.stderr | 108 +- .../ui/privacy/where-pub-type-impls-priv-trait.rs | 10 + .../privacy/where-pub-type-impls-priv-trait.stderr | 87 +- tests/ui/proc-macro/auxiliary/api/cmp.rs | 11 +- tests/ui/proc-macro/auxiliary/assert-span-pos.rs | 5 +- tests/ui/proc-macro/auxiliary/exports_no_mangle.rs | 11 + tests/ui/proc-macro/auxiliary/macro-only-syntax.rs | 2 +- tests/ui/proc-macro/crt-static.rs | 1 + tests/ui/proc-macro/derive-helper-shadowing.rs | 2 +- tests/ui/proc-macro/derive-helper-shadowing.stderr | 29 +- .../no-mangle-in-proc-macro-issue-111888.rs | 22 + tests/ui/proc-macro/span-preservation.stderr | 2 +- tests/ui/process/process-panic-after-fork.rs | 2 + ...ue-33174-restricted-type-in-public-interface.rs | 16 + ...3174-restricted-type-in-public-interface.stderr | 49 +- tests/ui/range/range-1.stderr | 8 +- tests/ui/reachable/expr_return.rs | 2 +- tests/ui/reachable/expr_return.stderr | 12 +- tests/ui/reachable/unreachable-variant.stderr | 2 +- tests/ui/recursion/issue-83150.rs | 1 + tests/ui/recursion/issue-83150.stderr | 6 +- tests/ui/recursion/issue-95134.rs | 1 + .../regions-implied-bounds-projection-gap-hr-1.rs | 1 - ...gions-implied-bounds-projection-gap-hr-1.stderr | 17 +- tests/ui/resolve/auxiliary/issue-112831-aux.rs | 13 + tests/ui/resolve/export-fully-qualified-2018.rs | 13 + .../ui/resolve/export-fully-qualified-2018.stderr | 14 + tests/ui/resolve/export-fully-qualified.rs | 2 + tests/ui/resolve/export-fully-qualified.stderr | 7 +- tests/ui/resolve/extern-prelude.rs | 2 +- tests/ui/resolve/hidden_glob_reexports.rs | 52 + tests/ui/resolve/hidden_glob_reexports.stderr | 54 + tests/ui/resolve/issue-105069.stderr | 4 +- tests/ui/resolve/issue-109153.rs | 14 + tests/ui/resolve/issue-109153.stderr | 23 + .../issue-112472-multi-generics-suggestion.fixed | 31 + .../issue-112472-multi-generics-suggestion.rs | 31 + .../issue-112472-multi-generics-suggestion.stderr | 25 + tests/ui/resolve/issue-112831.rs | 20 + tests/ui/resolve/privacy-enum-ctor.stderr | 8 +- tests/ui/resolve/resolve-pseudo-shadowing.rs | 2 +- tests/ui/resolve/resolve-self-in-impl.stderr | 30 +- tests/ui/return-nil.rs | 4 +- tests/ui/return/issue-64620.rs | 2 +- tests/ui/return/issue-64620.stderr | 2 +- .../ui/return/issue-86188-return-not-in-fn-body.rs | 12 +- tests/ui/return/tail-expr-as-potential-return.rs | 4 +- .../bind-by-move-no-guards.rs | 19 - .../former-E0008-now-pass.rs | 11 - .../rfc-basic-examples.rs | 43 - .../rfc-reject-double-move-across-arms.rs | 24 - .../rfc-reject-double-move-across-arms.stderr | 19 - .../rfc-reject-double-move-in-first-arm.rs | 26 - .../rfc-reject-double-move-in-first-arm.stderr | 19 - ...allow-hide-behind-direct-unsafe-ptr-embedded.rs | 26 - .../allow-hide-behind-direct-unsafe-ptr-param.rs | 26 - ...low-hide-behind-indirect-unsafe-ptr-embedded.rs | 26 - .../allow-hide-behind-indirect-unsafe-ptr-param.rs | 26 - .../allow-use-behind-cousin-variant.rs | 59 - .../cant-hide-behind-direct-struct-embedded.rs | 26 - .../cant-hide-behind-direct-struct-embedded.stderr | 11 - .../cant-hide-behind-direct-struct-param.rs | 26 - .../cant-hide-behind-direct-struct-param.stderr | 11 - .../cant-hide-behind-doubly-indirect-embedded.rs | 29 - ...ant-hide-behind-doubly-indirect-embedded.stderr | 18 - .../cant-hide-behind-doubly-indirect-param.rs | 29 - .../cant-hide-behind-doubly-indirect-param.stderr | 18 - .../cant-hide-behind-indirect-struct-embedded.rs | 29 - ...ant-hide-behind-indirect-struct-embedded.stderr | 18 - .../cant-hide-behind-indirect-struct-param.rs | 29 - .../cant-hide-behind-indirect-struct-param.stderr | 18 - .../feature-gate.no_gate.stderr | 21 - .../feature-gate.rs | 39 - .../feature-gate.with_gate.stderr | 8 - .../fn-ptr-is-structurally-matchable.rs | 135 -- ...issue-61188-match-slice-forbidden-without-eq.rs | 19 - ...e-61188-match-slice-forbidden-without-eq.stderr | 11 - ...sue-62307-match-ref-ref-forbidden-without-eq.rs | 43 - ...62307-match-ref-ref-forbidden-without-eq.stderr | 29 - .../issue-63479-match-fnptr.rs | 40 - .../issue-63479-match-fnptr.stderr | 16 - .../issue-6804.rs | 21 - .../issue-6804.stderr | 25 - ...h-empty-array-allowed-without-eq-issue-62336.rs | 17 - .../match-forbidden-without-eq.rs | 23 - .../match-forbidden-without-eq.stderr | 21 - .../match-nonempty-array-forbidden-without-eq.rs | 19 - ...atch-nonempty-array-forbidden-without-eq.stderr | 11 - .../match-requires-both-partialeq-and-eq.rs | 21 - .../match-requires-both-partialeq-and-eq.stderr | 11 - .../phantom-data-is-structurally-matchable.rs | 53 - tests/ui/rfc-1717-dllimport/missing-link-attr.rs | 4 - .../ui/rfc-1717-dllimport/missing-link-attr.stderr | 4 - tests/ui/rfc-1717-dllimport/multiple-renames.rs | 7 - .../ui/rfc-1717-dllimport/multiple-renames.stderr | 4 - tests/ui/rfc-1717-dllimport/rename-modifiers.rs | 9 - .../ui/rfc-1717-dllimport/rename-modifiers.stderr | 8 - tests/ui/rfc-1717-dllimport/rename-to-empty.rs | 7 - tests/ui/rfc-1717-dllimport/rename-to-empty.stderr | 4 - .../rfc-1937-termination-trait/issue-103052-1.rs | 11 - .../issue-103052-1.stderr | 17 - .../issue-103052-2.current.stderr | 15 - .../issue-103052-2.next.stderr | 15 - .../rfc-1937-termination-trait/issue-103052-2.rs | 22 - .../termination-trait-for-box-dyn-error.rs | 11 - .../termination-trait-for-never.rs | 7 - .../termination-trait-for-result-box-error_err.rs | 10 - .../termination-trait-for-str.rs | 8 - .../termination-trait-impl-trait.rs | 3 - .../termination-trait-impl-trait.stderr | 11 - .../termination-trait-in-test-should-panic.rs | 15 - .../termination-trait-in-test-should-panic.stderr | 12 - .../termination-trait-in-test.rs | 28 - .../termination-trait-main-i32.rs | 6 - .../termination-trait-main-i32.stderr | 11 - .../termination-trait-main-wrong-type.rs | 3 - .../termination-trait-main-wrong-type.stderr | 11 - .../termination-trait-not-satisfied.rs | 5 - .../termination-trait-not-satisfied.stderr | 11 - .../termination-trait-test-wrong-type.rs | 8 - .../termination-trait-test-wrong-type.stderr | 16 - .../borrowck-issue-49631.rs | 24 - .../borrowck-issue-49631.stderr | 14 - tests/ui/rfc-2005-default-binding-mode/const.rs | 17 - .../ui/rfc-2005-default-binding-mode/const.stderr | 18 - tests/ui/rfc-2005-default-binding-mode/enum.rs | 22 - tests/ui/rfc-2005-default-binding-mode/enum.stderr | 21 - .../rfc-2005-default-binding-mode/explicit-mut.rs | 28 - .../explicit-mut.stderr | 21 - tests/ui/rfc-2005-default-binding-mode/for.rs | 9 - tests/ui/rfc-2005-default-binding-mode/for.stderr | 17 - .../issue-44912-or.rs | 10 - .../issue-44912-or.stderr | 9 - tests/ui/rfc-2005-default-binding-mode/lit.rs | 24 - tests/ui/rfc-2005-default-binding-mode/lit.stderr | 25 - .../no-double-error.rs | 11 - .../no-double-error.stderr | 9 - tests/ui/rfc-2005-default-binding-mode/slice.rs | 7 - .../ui/rfc-2005-default-binding-mode/slice.stderr | 16 - .../ui/rfc-2008-non-exhaustive/auxiliary/enums.rs | 44 - .../auxiliary/monovariants.rs | 8 - .../rfc-2008-non-exhaustive/auxiliary/structs.rs | 41 - .../rfc-2008-non-exhaustive/auxiliary/unstable.rs | 60 - .../rfc-2008-non-exhaustive/auxiliary/variants.rs | 7 - .../rfc-2008-non-exhaustive/borrowck-exhaustive.rs | 44 - .../borrowck-non-exhaustive.rs | 18 - .../borrowck-non-exhaustive.stderr | 14 - tests/ui/rfc-2008-non-exhaustive/enum-as-cast.rs | 11 - .../ui/rfc-2008-non-exhaustive/enum-as-cast.stderr | 11 - tests/ui/rfc-2008-non-exhaustive/enum.rs | 69 - tests/ui/rfc-2008-non-exhaustive/enum.stderr | 59 - .../ui/rfc-2008-non-exhaustive/enum_same_crate.rs | 18 - .../enum_same_crate_empty_match.rs | 37 - .../enum_same_crate_empty_match.stderr | 69 - .../improper_ctypes/auxiliary/types.rs | 29 - .../improper_ctypes/extern_crate_improper.rs | 24 - .../improper_ctypes/extern_crate_improper.stderr | 47 - .../improper_ctypes/same_crate_proper.rs | 48 - .../rfc-2008-non-exhaustive/invalid-attribute.rs | 16 - .../invalid-attribute.stderr | 30 - .../ui/rfc-2008-non-exhaustive/omitted-patterns.rs | 211 --- .../omitted-patterns.stderr | 217 --- .../stable-omitted-patterns.rs | 45 - .../stable-omitted-patterns.stderr | 30 - tests/ui/rfc-2008-non-exhaustive/struct.rs | 49 - tests/ui/rfc-2008-non-exhaustive/struct.stderr | 95 - .../rfc-2008-non-exhaustive/structs_same_crate.rs | 32 - .../uninhabited/auxiliary/uninhabited.rs | 32 - .../uninhabited/coercions.rs | 38 - .../uninhabited/coercions.stderr | 35 - .../uninhabited/coercions_same_crate.rs | 45 - .../uninhabited/coercions_same_crate.stderr | 35 - .../uninhabited/indirect_match.rs | 36 - .../uninhabited/indirect_match.stderr | 79 - .../uninhabited/indirect_match_same_crate.rs | 51 - .../uninhabited/indirect_match_same_crate.stderr | 79 - .../indirect_match_with_exhaustive_patterns.rs | 40 - .../indirect_match_with_exhaustive_patterns.stderr | 79 - ...ct_match_with_exhaustive_patterns_same_crate.rs | 57 - .../uninhabited/issue-65157-repeated-match-arm.rs | 21 - .../issue-65157-repeated-match-arm.stderr | 14 - .../rfc-2008-non-exhaustive/uninhabited/match.rs | 34 - .../uninhabited/match.stderr | 83 - .../uninhabited/match_same_crate.rs | 41 - .../uninhabited/match_same_crate.stderr | 64 - .../uninhabited/match_with_exhaustive_patterns.rs | 37 - .../match_with_exhaustive_patterns.stderr | 83 - .../match_with_exhaustive_patterns_same_crate.rs | 47 - .../uninhabited/patterns.rs | 59 - .../uninhabited/patterns_same_crate.rs | 70 - .../uninhabited/patterns_same_crate.stderr | 38 - tests/ui/rfc-2008-non-exhaustive/variant.rs | 33 - tests/ui/rfc-2008-non-exhaustive/variant.stderr | 102 -- .../variants_fictive_visibility.rs | 12 - .../rfc-2008-non-exhaustive/variants_same_crate.rs | 18 - .../downcast-unsafe-trait-objects.rs | 23 - .../manual-self-impl-for-unsafe-obj.rs | 66 - .../static-dispatch-unsafe-object.rs | 37 - tests/ui/rfc-2091-track-caller/call-chain.rs | 30 - .../caller-location-fnptr-rt-ctfe-equiv.rs | 32 - .../caller-location-fnptr-rt-ctfe-equiv.stderr | 10 - .../caller-location-intrinsic.rs | 27 - .../rfc-2091-track-caller/const-caller-location.rs | 43 - .../diverging-caller-location.rs | 17 - tests/ui/rfc-2091-track-caller/error-odd-syntax.rs | 5 - .../rfc-2091-track-caller/error-odd-syntax.stderr | 8 - .../error-with-invalid-abi.rs | 11 - .../error-with-invalid-abi.stderr | 15 - tests/ui/rfc-2091-track-caller/error-with-main.rs | 4 - .../rfc-2091-track-caller/error-with-main.stderr | 10 - tests/ui/rfc-2091-track-caller/error-with-naked.rs | 24 - .../rfc-2091-track-caller/error-with-naked.stderr | 28 - tests/ui/rfc-2091-track-caller/error-with-start.rs | 7 - .../rfc-2091-track-caller/error-with-start.stderr | 10 - .../ui/rfc-2091-track-caller/intrinsic-wrapper.rs | 22 - .../ui/rfc-2091-track-caller/macro-declaration.rs | 10 - .../ui/rfc-2091-track-caller/mir-inlined-macro.rs | 23 - tests/ui/rfc-2091-track-caller/only-for-fns.rs | 5 - tests/ui/rfc-2091-track-caller/only-for-fns.stderr | 11 - tests/ui/rfc-2091-track-caller/pass.rs | 10 - .../rfc-2091-track-caller/std-panic-locations.rs | 64 - .../track-caller-attribute.rs | 40 - tests/ui/rfc-2091-track-caller/track-caller-ffi.rs | 48 - tests/ui/rfc-2091-track-caller/tracked-closure.rs | 154 -- .../tracked-fn-ptr-with-arg.rs | 62 - tests/ui/rfc-2091-track-caller/tracked-fn-ptr.rs | 62 - .../rfc-2091-track-caller/tracked-trait-impls.rs | 77 - .../ui/rfc-2091-track-caller/tracked-trait-obj.rs | 61 - tests/ui/rfc-2093-infer-outlives/cross-crate.rs | 8 - .../ui/rfc-2093-infer-outlives/cross-crate.stderr | 10 - .../rfc-2093-infer-outlives/dont-infer-static.rs | 12 - .../dont-infer-static.stderr | 19 - tests/ui/rfc-2093-infer-outlives/enum.rs | 27 - tests/ui/rfc-2093-infer-outlives/enum.stderr | 26 - tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs | 12 - .../ui/rfc-2093-infer-outlives/explicit-dyn.stderr | 10 - tests/ui/rfc-2093-infer-outlives/explicit-enum.rs | 13 - .../rfc-2093-infer-outlives/explicit-enum.stderr | 10 - .../rfc-2093-infer-outlives/explicit-projection.rs | 13 - .../explicit-projection.stderr | 10 - .../ui/rfc-2093-infer-outlives/explicit-struct.rs | 13 - .../rfc-2093-infer-outlives/explicit-struct.stderr | 10 - tests/ui/rfc-2093-infer-outlives/explicit-union.rs | 14 - .../rfc-2093-infer-outlives/explicit-union.stderr | 10 - tests/ui/rfc-2093-infer-outlives/issue-54467.rs | 17 - tests/ui/rfc-2093-infer-outlives/nested-enum.rs | 13 - .../ui/rfc-2093-infer-outlives/nested-enum.stderr | 10 - tests/ui/rfc-2093-infer-outlives/nested-regions.rs | 8 - .../rfc-2093-infer-outlives/nested-regions.stderr | 12 - tests/ui/rfc-2093-infer-outlives/nested-structs.rs | 12 - .../rfc-2093-infer-outlives/nested-structs.stderr | 10 - tests/ui/rfc-2093-infer-outlives/nested-union.rs | 14 - .../ui/rfc-2093-infer-outlives/nested-union.stderr | 10 - tests/ui/rfc-2093-infer-outlives/privacy.rs | 20 - tests/ui/rfc-2093-infer-outlives/projection.rs | 8 - tests/ui/rfc-2093-infer-outlives/projection.stderr | 10 - tests/ui/rfc-2093-infer-outlives/reference.rs | 8 - tests/ui/rfc-2093-infer-outlives/reference.stderr | 10 - .../rfc-2093-infer-outlives/regions-enum-not-wf.rs | 39 - .../regions-enum-not-wf.stderr | 36 - .../regions-outlives-nominal-type-region-rev.rs | 22 - ...regions-outlives-nominal-type-region-rev.stderr | 20 - .../regions-outlives-nominal-type-region.rs | 22 - .../regions-outlives-nominal-type-region.stderr | 20 - .../regions-outlives-nominal-type-type-rev.rs | 22 - .../regions-outlives-nominal-type-type-rev.stderr | 20 - .../regions-outlives-nominal-type-type.rs | 22 - .../regions-outlives-nominal-type-type.stderr | 20 - .../regions-struct-not-wf.rs | 28 - .../regions-struct-not-wf.stderr | 48 - tests/ui/rfc-2093-infer-outlives/self-dyn.rs | 13 - tests/ui/rfc-2093-infer-outlives/self-dyn.stderr | 10 - tests/ui/rfc-2093-infer-outlives/self-structs.rs | 13 - .../ui/rfc-2093-infer-outlives/self-structs.stderr | 10 - .../crate-path-non-absolute.rs | 11 - .../crate-path-non-absolute.stderr | 15 - .../keyword-crate-as-identifier.rs | 4 - .../keyword-crate-as-identifier.stderr | 9 - .../auxiliary/xcrate.rs | 5 - .../non-existent-1.rs | 5 - .../non-existent-1.stderr | 9 - .../non-existent-2.rs | 6 - .../non-existent-2.stderr | 9 - .../non-existent-3.rs | 5 - .../non-existent-3.stderr | 9 - .../rfc-2126-extern-absolute-paths/not-allowed.rs | 9 - .../not-allowed.stderr | 16 - .../single-segment.rs | 11 - .../single-segment.stderr | 21 - tests/ui/rfc-2294-if-let-guard/bindings.rs | 9 - tests/ui/rfc-2294-if-let-guard/bindings.stderr | 15 - tests/ui/rfc-2294-if-let-guard/feature-gate.rs | 96 - tests/ui/rfc-2294-if-let-guard/feature-gate.stderr | 431 ----- tests/ui/rfc-2294-if-let-guard/run-pass.rs | 40 - tests/ui/rfc-2294-if-let-guard/typeck.rs | 15 - tests/ui/rfc-2294-if-let-guard/typeck.stderr | 25 - tests/ui/rfc-2294-if-let-guard/warns.rs | 21 - tests/ui/rfc-2294-if-let-guard/warns.stderr | 28 - tests/ui/rfc-2306/convert-id-const-with-gate.rs | 7 - .../dbg-macro-expected-behavior.rs | 69 - .../dbg-macro-expected-behavior.run.stderr | 28 - .../rfc-2361-dbg-macro/dbg-macro-move-semantics.rs | 10 - .../dbg-macro-move-semantics.stderr | 14 - .../rfc-2361-dbg-macro/dbg-macro-requires-debug.rs | 7 - .../dbg-macro-requires-debug.stderr | 18 - .../feature-gate-do_not_recommend.rs | 21 - .../feature-gate-do_not_recommend.stderr | 25 - .../incorrect-locations.rs | 45 - .../incorrect-locations.stderr | 50 - .../rfc-2397-do-not-recommend/unstable-feature.rs | 10 - .../unstable-feature.stderr | 12 - .../mod_file_nonascii_with_path_allowed-aux.rs | 1 - .../ui/rfc-2457/crate_name_nonascii_forbidden-1.rs | 3 - .../crate_name_nonascii_forbidden-1.stderr | 8 - .../ui/rfc-2457/crate_name_nonascii_forbidden-2.rs | 6 - .../crate_name_nonascii_forbidden-2.stderr | 8 - .../ui/rfc-2457/extern_block_nonascii_forbidden.rs | 9 - .../extern_block_nonascii_forbidden.stderr | 34 - tests/ui/rfc-2457/idents-normalized.rs | 7 - tests/ui/rfc-2457/mod_file_nonascii_forbidden.rs | 4 - .../ui/rfc-2457/mod_file_nonascii_forbidden.stderr | 20 - .../mod_file_nonascii_with_path_allowed.rs | 6 - tests/ui/rfc-2457/mod_inline_nonascii_allowed.rs | 7 - tests/ui/rfc-2457/no_mangle_nonascii_forbidden.rs | 20 - .../rfc-2457/no_mangle_nonascii_forbidden.stderr | 21 - .../ast-lowering-does-not-wrap-let-chains.rs | 16 - .../ui/rfc-2497-if-let-chains/ast-pretty-check.rs | 6 - .../rfc-2497-if-let-chains/ast-pretty-check.stdout | 10 - .../rfc-2497-if-let-chains/ast-validate-guards.rs | 23 - .../ast-validate-guards.stderr | 21 - .../rfc-2497-if-let-chains/chains-without-let.rs | 20 - .../chains-without-let.stderr | 33 - .../rfc-2497-if-let-chains/disallowed-positions.rs | 480 ----- .../disallowed-positions.stderr | 1911 -------------------- ...t-let-else-does-not-interact-with-let-chains.rs | 55 - ...t-else-does-not-interact-with-let-chains.stderr | 147 -- tests/ui/rfc-2497-if-let-chains/feature-gate.rs | 62 - .../ui/rfc-2497-if-let-chains/feature-gate.stderr | 120 -- .../invalid-let-in-a-valid-let-context.rs | 45 - .../invalid-let-in-a-valid-let-context.stderr | 38 - .../irrefutable-lets.disallowed.stderr | 115 -- .../ui/rfc-2497-if-let-chains/irrefutable-lets.rs | 78 - tests/ui/rfc-2497-if-let-chains/issue-88498.rs | 16 - tests/ui/rfc-2497-if-let-chains/issue-90722.rs | 11 - tests/ui/rfc-2497-if-let-chains/issue-92145.rs | 11 - tests/ui/rfc-2497-if-let-chains/issue-93150.rs | 8 - tests/ui/rfc-2497-if-let-chains/issue-93150.stderr | 22 - tests/ui/rfc-2497-if-let-chains/issue-99938.rs | 31 - .../rfc-2497-if-let-chains/no-double-assigments.rs | 9 - .../rfc-2497-if-let-chains/protect-precedences.rs | 17 - .../protect-precedences.stderr | 12 - .../ui/rfc-2497-if-let-chains/then-else-blocks.rs | 49 - .../ui/rfc-2565-param-attrs/attr-without-param.rs | 16 - .../rfc-2565-param-attrs/attr-without-param.stderr | 20 - .../ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs | 11 - .../rfc-2565-param-attrs/auxiliary/param-attrs.rs | 43 - ...issue-64682-dropping-first-attrs-in-impl-fns.rs | 21 - tests/ui/rfc-2565-param-attrs/param-attrs-2018.rs | 6 - .../rfc-2565-param-attrs/param-attrs-2018.stderr | 22 - .../ui/rfc-2565-param-attrs/param-attrs-allowed.rs | 101 -- .../param-attrs-builtin-attrs.rs | 174 -- .../param-attrs-builtin-attrs.stderr | 386 ---- tests/ui/rfc-2565-param-attrs/param-attrs-cfg.rs | 121 -- .../ui/rfc-2565-param-attrs/param-attrs-cfg.stderr | 122 -- .../ui/rfc-2565-param-attrs/param-attrs-pretty.rs | 61 - .../proc-macro-cannot-be-used.rs | 66 - .../proc-macro-cannot-be-used.stderr | 176 -- tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs | 19 - tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr | 5 - .../import-name-type-invalid-format.rs | 7 - .../import-name-type-invalid-format.stderr | 8 - .../import-name-type-multiple.rs | 8 - .../import-name-type-multiple.stderr | 8 - .../import-name-type-unknown-value.rs | 7 - .../import-name-type-unknown-value.stderr | 8 - .../import-name-type-unsupported-link-kind.rs | 15 - .../import-name-type-unsupported-link-kind.stderr | 14 - .../import-name-type-x86-only.rs | 7 - .../import-name-type-x86-only.stderr | 8 - tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs | 13 - tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr | 4 - .../ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs | 13 - .../link-ordinal-and-name.stderr | 14 - .../link-ordinal-invalid-format.rs | 11 - .../link-ordinal-invalid-format.stderr | 18 - .../link-ordinal-missing-argument.rs | 11 - .../link-ordinal-missing-argument.stderr | 18 - .../ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs | 12 - .../link-ordinal-multiple.stderr | 26 - .../link-ordinal-not-foreign-fn.rs | 22 - .../link-ordinal-not-foreign-fn.stderr | 20 - .../rfc-2627-raw-dylib/link-ordinal-too-large.rs | 11 - .../link-ordinal-too-large.stderr | 18 - .../link-ordinal-too-many-arguments.rs | 11 - .../link-ordinal-too-many-arguments.stderr | 18 - .../link-ordinal-unsupported-link-kind.rs | 15 - .../link-ordinal-unsupported-link-kind.stderr | 14 - .../ui/rfc-2627-raw-dylib/multiple-declarations.rs | 18 - .../multiple-declarations.stderr | 8 - .../rfc-2627-raw-dylib/raw-dylib-windows-only.rs | 5 - .../raw-dylib-windows-only.stderr | 9 - tests/ui/rfc-2627-raw-dylib/unsupported-abi.rs | 12 - tests/ui/rfc-2627-raw-dylib/unsupported-abi.stderr | 8 - .../assoc-type-const-bound-usage.rs | 14 - tests/ui/rfc-2632-const-trait-impl/assoc-type.rs | 33 - .../ui/rfc-2632-const-trait-impl/assoc-type.stderr | 8 - tests/ui/rfc-2632-const-trait-impl/attr-misuse.rs | 10 - .../rfc-2632-const-trait-impl/attr-misuse.stderr | 14 - .../auxiliary/cross-crate.rs | 23 - .../auxiliary/staged-api.rs | 19 - .../call-const-trait-method-fail.rs | 29 - .../call-const-trait-method-fail.stderr | 15 - .../call-const-trait-method-pass.rs | 43 - .../call-const-trait-method-pass.stderr | 20 - .../call-generic-in-impl.rs | 15 - .../call-generic-in-impl.stderr | 8 - .../call-generic-method-chain.rs | 28 - .../call-generic-method-chain.stderr | 23 - .../call-generic-method-dup-bound.rs | 31 - .../call-generic-method-dup-bound.stderr | 23 - .../call-generic-method-fail.rs | 9 - .../call-generic-method-fail.stderr | 28 - .../call-generic-method-nonconst-bound.rs | 17 - .../call-generic-method-nonconst.rs | 26 - .../call-generic-method-nonconst.stderr | 15 - .../call-generic-method-pass.rs | 24 - .../call-generic-method-pass.stderr | 17 - tests/ui/rfc-2632-const-trait-impl/call.rs | 10 - .../const-and-non-const-impl.rs | 31 - .../const-and-non-const-impl.stderr | 20 - .../const-check-fns-in-const-impl.rs | 16 - .../const-check-fns-in-const-impl.stderr | 11 - .../const-closure-parse-not-item.rs | 10 - .../const-closure-trait-method-fail.rs | 20 - .../const-closure-trait-method-fail.stderr | 16 - .../const-closure-trait-method.rs | 19 - .../ui/rfc-2632-const-trait-impl/const-closures.rs | 30 - .../const-default-method-bodies.rs | 29 - .../const-default-method-bodies.stderr | 15 - .../rfc-2632-const-trait-impl/const-drop-bound.rs | 25 - .../const-drop-fail-2.precise.stderr | 26 - .../rfc-2632-const-trait-impl/const-drop-fail-2.rs | 43 - .../const-drop-fail-2.stderr | 50 - .../const-drop-fail-2.stock.stderr | 26 - .../const-drop-fail.precise.stderr | 58 - .../rfc-2632-const-trait-impl/const-drop-fail.rs | 37 - .../const-drop-fail.stock.stderr | 58 - tests/ui/rfc-2632-const-trait-impl/const-drop.rs | 113 -- .../const-impl-norecover.rs | 12 - .../const-impl-norecover.stderr | 8 - .../const-impl-recovery.rs | 17 - .../const-impl-recovery.stderr | 26 - .../const-impl-requires-const-trait.rs | 9 - .../const-impl-requires-const-trait.stderr | 14 - .../rfc-2632-const-trait-impl/const-impl-trait.rs | 55 - .../const-impl-trait.stderr | 39 - .../const_derives/derive-const-gate.rs | 5 - .../const_derives/derive-const-gate.stderr | 21 - .../const_derives/derive-const-non-const-type.rs | 13 - .../derive-const-non-const-type.stderr | 12 - .../const_derives/derive-const-use.rs | 19 - .../const_derives/derive-const-use.stderr | 53 - .../const_derives/derive-const-with-params.rs | 13 - .../const_derives/derive-const-with-params.stderr | 20 - .../cross-crate-default-method-body-is-const.rs | 18 - .../cross-crate.gatednc.stderr | 15 - tests/ui/rfc-2632-const-trait-impl/cross-crate.rs | 24 - .../cross-crate.stock.stderr | 12 - .../cross-crate.stocknc.stderr | 15 - .../default-method-body-is-const-body-checking.rs | 17 - ...fault-method-body-is-const-body-checking.stderr | 15 - .../default-method-body-is-const-same-trait-ck.rs | 15 - ...fault-method-body-is-const-same-trait-ck.stderr | 15 - ...default-method-body-is-const-with-staged-api.rs | 17 - .../do-not-const-check-override.rs | 19 - .../do-not-const-check.rs | 18 - .../feature-gate.gated.stderr | 8 - tests/ui/rfc-2632-const-trait-impl/feature-gate.rs | 14 - .../feature-gate.stock.stderr | 21 - .../function-pointer-does-not-require-const.rs | 15 - tests/ui/rfc-2632-const-trait-impl/gate.rs | 13 - tests/ui/rfc-2632-const-trait-impl/gate.stderr | 21 - .../ui/rfc-2632-const-trait-impl/generic-bound.rs | 30 - .../rfc-2632-const-trait-impl/generic-bound.stderr | 11 - .../rfc-2632-const-trait-impl/hir-const-check.rs | 17 - .../hir-const-check.stderr | 12 - .../impl-tilde-const-trait.rs | 9 - .../impl-tilde-const-trait.stderr | 8 - .../impl-with-default-fn-fail.rs | 17 - .../impl-with-default-fn-fail.stderr | 12 - .../impl-with-default-fn-pass.rs | 26 - .../inherent-impl-const-bounds.rs | 22 - .../ui/rfc-2632-const-trait-impl/inherent-impl.rs | 13 - .../rfc-2632-const-trait-impl/inherent-impl.stderr | 22 - tests/ui/rfc-2632-const-trait-impl/issue-100222.rs | 39 - tests/ui/rfc-2632-const-trait-impl/issue-102156.rs | 15 - .../rfc-2632-const-trait-impl/issue-102156.stderr | 19 - tests/ui/rfc-2632-const-trait-impl/issue-102985.rs | 12 - .../rfc-2632-const-trait-impl/issue-102985.stderr | 41 - tests/ui/rfc-2632-const-trait-impl/issue-103677.rs | 5 - tests/ui/rfc-2632-const-trait-impl/issue-79450.rs | 20 - .../rfc-2632-const-trait-impl/issue-79450.stderr | 12 - tests/ui/rfc-2632-const-trait-impl/issue-88155.rs | 13 - .../rfc-2632-const-trait-impl/issue-88155.stderr | 24 - tests/ui/rfc-2632-const-trait-impl/issue-90052.rs | 9 - .../rfc-2632-const-trait-impl/issue-90052.stderr | 14 - tests/ui/rfc-2632-const-trait-impl/issue-92111.rs | 23 - .../issue-92230-wf-super-trait-env.rs | 15 - .../ui/rfc-2632-const-trait-impl/nested-closure.rs | 12 - .../non-const-op-const-closure-non-const-outer.rs | 15 - ...n-const-op-const-closure-non-const-outer.stderr | 11 - .../non-const-op-in-closure-in-const.rs | 18 - .../non-const-op-in-closure-in-const.stderr | 8 - ...st-default-bound-non-const-specialized-bound.rs | 58 - ...efault-bound-non-const-specialized-bound.stderr | 18 - .../const-default-const-specialized.rs | 39 - ...onst-default-impl-non-const-specialized-impl.rs | 26 - ...-default-impl-non-const-specialized-impl.stderr | 8 - .../specialization/default-keyword.rs | 15 - .../issue-95186-specialize-on-tilde-const.rs | 49 - ...e-95187-same-trait-bound-different-constness.rs | 57 - .../non-const-default-const-specialized.rs | 39 - .../specializing-constness-2.rs | 31 - .../specializing-constness-2.stderr | 21 - .../specializing-constness.rs | 31 - .../specializing-constness.stderr | 14 - .../staged-api-user-crate.rs | 16 - .../staged-api-user-crate.stderr | 12 - tests/ui/rfc-2632-const-trait-impl/staged-api.rs | 63 - .../staged-api.stable.stderr | 25 - .../staged-api.unstable.stderr | 42 - .../static-const-trait-bound.rs | 18 - .../std-impl-gate.gated.stderr | 9 - .../ui/rfc-2632-const-trait-impl/std-impl-gate.rs | 21 - .../std-impl-gate.stock.stderr | 12 - .../super-traits-fail-2.nn.stderr | 14 - .../super-traits-fail-2.ny.stderr | 14 - .../super-traits-fail-2.rs | 20 - .../super-traits-fail-2.yn.stderr | 19 - .../super-traits-fail-2.yy.stderr | 19 - .../super-traits-fail-3.nn.stderr | 20 - .../super-traits-fail-3.ny.stderr | 14 - .../super-traits-fail-3.rs | 21 - .../super-traits-fail-3.yn.stderr | 8 - .../rfc-2632-const-trait-impl/super-traits-fail.rs | 18 - .../super-traits-fail.stderr | 20 - tests/ui/rfc-2632-const-trait-impl/super-traits.rs | 25 - tests/ui/rfc-2632-const-trait-impl/syntax.rs | 8 - .../tilde-const-and-const-params.rs | 34 - .../tilde-const-and-const-params.stderr | 14 - .../tilde-const-invalid-places.rs | 7 - .../tilde-const-invalid-places.stderr | 8 - .../tilde-const-syntax.rs | 9 - tests/ui/rfc-2632-const-trait-impl/tilde-twice.rs | 6 - .../rfc-2632-const-trait-impl/tilde-twice.stderr | 8 - .../tilde_const_on_impl_bound.rs | 17 - .../trait-default-body-stability.rs | 50 - .../trait-default-body-stability.stderr | 20 - .../trait-method-ptr-in-consts-ice.rs | 23 - .../trait-where-clause-const.rs | 31 - .../trait-where-clause-const.stderr | 35 - .../trait-where-clause-run.rs | 41 - .../trait-where-clause-self-referential.rs | 24 - .../trait-where-clause.rs | 26 - .../trait-where-clause.stderr | 35 - .../ui/rfc-2632-const-trait-impl/without-tilde.rs | 6 - .../rfc-2632-const-trait-impl/without-tilde.stderr | 10 - .../bind-by-move-no-guards.rs | 19 + .../former-E0008-now-pass.rs | 11 + .../rfc-basic-examples.rs | 43 + .../rfc-reject-double-move-across-arms.rs | 24 + .../rfc-reject-double-move-across-arms.stderr | 19 + .../rfc-reject-double-move-in-first-arm.rs | 26 + .../rfc-reject-double-move-in-first-arm.stderr | 19 + tests/ui/rfcs/rfc-1014-2.rs | 31 - .../rfc-1014-2.rs | 31 + .../rfc-1014-stdout-existential-crisis/rfc-1014.rs | 34 + tests/ui/rfcs/rfc-1014.rs | 34 - ...allow-hide-behind-direct-unsafe-ptr-embedded.rs | 26 + .../allow-hide-behind-direct-unsafe-ptr-param.rs | 26 + ...low-hide-behind-indirect-unsafe-ptr-embedded.rs | 26 + .../allow-hide-behind-indirect-unsafe-ptr-param.rs | 26 + .../allow-use-behind-cousin-variant.rs | 59 + .../cant-hide-behind-direct-struct-embedded.rs | 26 + .../cant-hide-behind-direct-struct-embedded.stderr | 11 + .../cant-hide-behind-direct-struct-param.rs | 26 + .../cant-hide-behind-direct-struct-param.stderr | 11 + .../cant-hide-behind-doubly-indirect-embedded.rs | 29 + ...ant-hide-behind-doubly-indirect-embedded.stderr | 18 + .../cant-hide-behind-doubly-indirect-param.rs | 29 + .../cant-hide-behind-doubly-indirect-param.stderr | 18 + .../cant-hide-behind-indirect-struct-embedded.rs | 29 + ...ant-hide-behind-indirect-struct-embedded.stderr | 18 + .../cant-hide-behind-indirect-struct-param.rs | 29 + .../cant-hide-behind-indirect-struct-param.stderr | 18 + .../feature-gate.no_gate.stderr | 21 + .../feature-gate.rs | 39 + .../feature-gate.with_gate.stderr | 8 + .../fn-ptr-is-structurally-matchable.rs | 135 ++ ...issue-61188-match-slice-forbidden-without-eq.rs | 19 + ...e-61188-match-slice-forbidden-without-eq.stderr | 11 + ...sue-62307-match-ref-ref-forbidden-without-eq.rs | 43 + ...62307-match-ref-ref-forbidden-without-eq.stderr | 29 + .../issue-63479-match-fnptr.rs | 40 + .../issue-63479-match-fnptr.stderr | 16 + .../issue-6804.rs | 21 + .../issue-6804.stderr | 25 + ...h-empty-array-allowed-without-eq-issue-62336.rs | 17 + .../match-forbidden-without-eq.rs | 23 + .../match-forbidden-without-eq.stderr | 21 + .../match-nonempty-array-forbidden-without-eq.rs | 19 + ...atch-nonempty-array-forbidden-without-eq.stderr | 11 + .../match-requires-both-partialeq-and-eq.rs | 21 + .../match-requires-both-partialeq-and-eq.stderr | 11 + .../phantom-data-is-structurally-matchable.rs | 53 + .../rfc1445/eq-allows-match-on-ty-in-macro.rs | 23 + .../rfc1445/eq-allows-match.rs | 17 + tests/ui/rfcs/rfc-1623-static/rfc1623-2.rs | 99 + tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr | 39 + tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs | 14 + tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr | 35 + tests/ui/rfcs/rfc-1623-static/rfc1623.rs | 75 + .../1717-dllimport/library-override.rs | 14 + .../rfcs/rfc-1717-dllimport/missing-link-attr.rs | 4 + .../rfc-1717-dllimport/missing-link-attr.stderr | 4 + .../ui/rfcs/rfc-1717-dllimport/multiple-renames.rs | 7 + .../rfc-1717-dllimport/multiple-renames.stderr | 4 + .../ui/rfcs/rfc-1717-dllimport/rename-modifiers.rs | 9 + .../rfc-1717-dllimport/rename-modifiers.stderr | 8 + .../ui/rfcs/rfc-1717-dllimport/rename-to-empty.rs | 7 + .../rfcs/rfc-1717-dllimport/rename-to-empty.stderr | 4 + .../rfc-1857-stabilize-drop-order/drop-order.rs | 224 +++ .../rfc-1937-termination-trait/issue-103052-1.rs | 11 + .../issue-103052-1.stderr | 17 + .../issue-103052-2.current.stderr | 15 + .../issue-103052-2.next.stderr | 15 + .../rfc-1937-termination-trait/issue-103052-2.rs | 22 + .../termination-trait-for-box-dyn-error-err.rs | 11 + .../termination-trait-for-box-dyn-error-ok.rs | 6 + .../termination-trait-for-box-dyn-error.rs | 6 - .../termination-trait-for-never.rs | 7 + .../termination-trait-for-result-box-error_err.rs | 10 + .../termination-trait-for-str-err.rs | 8 + .../termination-trait-for-str-ok.rs | 4 + .../termination-trait-for-str.rs | 4 - .../termination-trait-impl-trait.rs | 3 + .../termination-trait-impl-trait.stderr | 11 + .../termination-trait-in-test-should-panic.rs | 15 + .../termination-trait-in-test-should-panic.stderr | 12 + .../termination-trait-in-test.rs | 28 + .../termination-trait-main-i32.rs | 6 + .../termination-trait-main-i32.stderr | 11 + .../termination-trait-main-wrong-type.rs | 3 + .../termination-trait-main-wrong-type.stderr | 11 + .../termination-trait-not-satisfied.rs | 5 + .../termination-trait-not-satisfied.stderr | 11 + .../termination-trait-test-wrong-type.rs | 8 + .../termination-trait-test-wrong-type.stderr | 16 + .../borrowck-issue-49631.rs | 24 + .../borrowck-issue-49631.stderr | 14 + .../ui/rfcs/rfc-2005-default-binding-mode/const.rs | 17 + .../rfc-2005-default-binding-mode/const.stderr | 18 + .../rfcs/rfc-2005-default-binding-mode/enum-ok.rs | 45 + .../ui/rfcs/rfc-2005-default-binding-mode/enum.rs | 29 +- .../rfcs/rfc-2005-default-binding-mode/enum.stderr | 21 + .../rfc-2005-default-binding-mode/explicit-mut.rs | 28 + .../explicit-mut.stderr | 21 + .../rfcs/rfc-2005-default-binding-mode/for-ok.rs | 20 + tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs | 23 +- .../rfcs/rfc-2005-default-binding-mode/for.stderr | 17 + .../issue-44912-or.rs | 10 + .../issue-44912-or.stderr | 9 + .../rfcs/rfc-2005-default-binding-mode/lit-ok.rs | 34 + tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs | 26 +- .../rfcs/rfc-2005-default-binding-mode/lit.stderr | 25 + .../no-double-error.rs | 11 + .../no-double-error.stderr | 9 + .../rfcs/rfc-2005-default-binding-mode/slice-ok.rs | 25 + .../ui/rfcs/rfc-2005-default-binding-mode/slice.rs | 26 +- .../rfc-2005-default-binding-mode/slice.stderr | 16 + .../rfc-2008-non-exhaustive/auxiliary/enums.rs | 44 + .../auxiliary/monovariants.rs | 8 + .../rfc-2008-non-exhaustive/auxiliary/structs.rs | 41 + .../rfc-2008-non-exhaustive/auxiliary/unstable.rs | 60 + .../rfc-2008-non-exhaustive/auxiliary/variants.rs | 7 + .../rfc-2008-non-exhaustive/borrowck-exhaustive.rs | 44 + .../borrowck-non-exhaustive.rs | 18 + .../borrowck-non-exhaustive.stderr | 14 + .../rfcs/rfc-2008-non-exhaustive/enum-as-cast.rs | 11 + .../rfc-2008-non-exhaustive/enum-as-cast.stderr | 11 + tests/ui/rfcs/rfc-2008-non-exhaustive/enum.rs | 69 + tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr | 59 + .../rfc-2008-non-exhaustive/enum_same_crate.rs | 18 + .../enum_same_crate_empty_match.rs | 37 + .../enum_same_crate_empty_match.stderr | 69 + .../improper_ctypes/auxiliary/types.rs | 29 + .../improper_ctypes/extern_crate_improper.rs | 24 + .../improper_ctypes/extern_crate_improper.stderr | 47 + .../improper_ctypes/same_crate_proper.rs | 48 + .../rfc-2008-non-exhaustive/invalid-attribute.rs | 16 + .../invalid-attribute.stderr | 30 + .../rfc-2008-non-exhaustive/omitted-patterns.rs | 211 +++ .../omitted-patterns.stderr | 217 +++ .../stable-omitted-patterns.rs | 45 + .../stable-omitted-patterns.stderr | 30 + tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs | 49 + .../ui/rfcs/rfc-2008-non-exhaustive/struct.stderr | 95 + .../rfc-2008-non-exhaustive/structs_same_crate.rs | 32 + .../uninhabited/auxiliary/uninhabited.rs | 32 + .../uninhabited/coercions.rs | 38 + .../uninhabited/coercions.stderr | 35 + .../uninhabited/coercions_same_crate.rs | 45 + .../uninhabited/coercions_same_crate.stderr | 35 + .../uninhabited/indirect_match.rs | 36 + .../uninhabited/indirect_match.stderr | 79 + .../uninhabited/indirect_match_same_crate.rs | 51 + .../uninhabited/indirect_match_same_crate.stderr | 79 + .../indirect_match_with_exhaustive_patterns.rs | 40 + .../indirect_match_with_exhaustive_patterns.stderr | 79 + ...ct_match_with_exhaustive_patterns_same_crate.rs | 57 + .../uninhabited/issue-65157-repeated-match-arm.rs | 21 + .../issue-65157-repeated-match-arm.stderr | 14 + .../rfc-2008-non-exhaustive/uninhabited/match.rs | 34 + .../uninhabited/match.stderr | 83 + .../uninhabited/match_same_crate.rs | 41 + .../uninhabited/match_same_crate.stderr | 64 + .../uninhabited/match_with_exhaustive_patterns.rs | 37 + .../match_with_exhaustive_patterns.stderr | 83 + .../match_with_exhaustive_patterns_same_crate.rs | 47 + .../uninhabited/patterns.rs | 59 + .../uninhabited/patterns_same_crate.rs | 70 + .../uninhabited/patterns_same_crate.stderr | 38 + tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs | 33 + .../ui/rfcs/rfc-2008-non-exhaustive/variant.stderr | 102 ++ .../variants_fictive_visibility.rs | 12 + .../rfc-2008-non-exhaustive/variants_same_crate.rs | 18 + .../downcast-unsafe-trait-objects.rs | 23 + .../manual-self-impl-for-unsafe-obj.rs | 66 + .../static-dispatch-unsafe-object.rs | 37 + tests/ui/rfcs/rfc-2091-track-caller/call-chain.rs | 30 + .../caller-location-fnptr-rt-ctfe-equiv.rs | 32 + .../caller-location-fnptr-rt-ctfe-equiv.stderr | 10 + .../caller-location-intrinsic.rs | 27 + .../rfc-2091-track-caller/const-caller-location.rs | 43 + .../diverging-caller-location.rs | 17 + .../rfcs/rfc-2091-track-caller/error-odd-syntax.rs | 5 + .../rfc-2091-track-caller/error-odd-syntax.stderr | 8 + .../error-with-invalid-abi.rs | 11 + .../error-with-invalid-abi.stderr | 15 + .../rfcs/rfc-2091-track-caller/error-with-main.rs | 4 + .../rfc-2091-track-caller/error-with-main.stderr | 10 + .../rfcs/rfc-2091-track-caller/error-with-naked.rs | 24 + .../rfc-2091-track-caller/error-with-naked.stderr | 28 + .../rfcs/rfc-2091-track-caller/error-with-start.rs | 7 + .../rfc-2091-track-caller/error-with-start.stderr | 10 + .../rfc-2091-track-caller/intrinsic-wrapper.rs | 22 + .../rfc-2091-track-caller/macro-declaration.rs | 10 + .../rfc-2091-track-caller/mir-inlined-macro.rs | 23 + .../ui/rfcs/rfc-2091-track-caller/only-for-fns.rs | 5 + .../rfcs/rfc-2091-track-caller/only-for-fns.stderr | 11 + tests/ui/rfcs/rfc-2091-track-caller/pass.rs | 10 + .../rfc-2091-track-caller/std-panic-locations.rs | 64 + .../track-caller-attribute.rs | 40 + .../rfcs/rfc-2091-track-caller/track-caller-ffi.rs | 48 + .../rfcs/rfc-2091-track-caller/tracked-closure.rs | 154 ++ .../tracked-fn-ptr-with-arg.rs | 62 + .../rfcs/rfc-2091-track-caller/tracked-fn-ptr.rs | 62 + .../rfc-2091-track-caller/tracked-trait-impls.rs | 77 + .../rfc-2091-track-caller/tracked-trait-obj.rs | 61 + .../ui/rfcs/rfc-2093-infer-outlives/cross-crate.rs | 8 + .../rfc-2093-infer-outlives/cross-crate.stderr | 10 + .../rfc-2093-infer-outlives/dont-infer-static.rs | 12 + .../dont-infer-static.stderr | 19 + tests/ui/rfcs/rfc-2093-infer-outlives/enum.rs | 27 + tests/ui/rfcs/rfc-2093-infer-outlives/enum.stderr | 26 + .../rfcs/rfc-2093-infer-outlives/explicit-dyn.rs | 12 + .../rfc-2093-infer-outlives/explicit-dyn.stderr | 10 + .../rfcs/rfc-2093-infer-outlives/explicit-enum.rs | 13 + .../rfc-2093-infer-outlives/explicit-enum.stderr | 10 + .../rfc-2093-infer-outlives/explicit-projection.rs | 13 + .../explicit-projection.stderr | 10 + .../rfc-2093-infer-outlives/explicit-struct.rs | 13 + .../rfc-2093-infer-outlives/explicit-struct.stderr | 10 + .../rfcs/rfc-2093-infer-outlives/explicit-union.rs | 14 + .../rfc-2093-infer-outlives/explicit-union.stderr | 10 + .../ui/rfcs/rfc-2093-infer-outlives/issue-54467.rs | 17 + .../ui/rfcs/rfc-2093-infer-outlives/nested-enum.rs | 13 + .../rfc-2093-infer-outlives/nested-enum.stderr | 10 + .../rfcs/rfc-2093-infer-outlives/nested-regions.rs | 8 + .../rfc-2093-infer-outlives/nested-regions.stderr | 12 + .../rfcs/rfc-2093-infer-outlives/nested-structs.rs | 12 + .../rfc-2093-infer-outlives/nested-structs.stderr | 10 + .../rfcs/rfc-2093-infer-outlives/nested-union.rs | 14 + .../rfc-2093-infer-outlives/nested-union.stderr | 10 + tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs | 20 + .../ui/rfcs/rfc-2093-infer-outlives/projection.rs | 8 + .../rfcs/rfc-2093-infer-outlives/projection.stderr | 10 + tests/ui/rfcs/rfc-2093-infer-outlives/reference.rs | 8 + .../rfcs/rfc-2093-infer-outlives/reference.stderr | 10 + .../rfc-2093-infer-outlives/regions-enum-not-wf.rs | 39 + .../regions-enum-not-wf.stderr | 36 + .../regions-outlives-nominal-type-region-rev.rs | 22 + ...regions-outlives-nominal-type-region-rev.stderr | 20 + .../regions-outlives-nominal-type-region.rs | 22 + .../regions-outlives-nominal-type-region.stderr | 20 + .../regions-outlives-nominal-type-type-rev.rs | 22 + .../regions-outlives-nominal-type-type-rev.stderr | 20 + .../regions-outlives-nominal-type-type.rs | 22 + .../regions-outlives-nominal-type-type.stderr | 20 + .../regions-struct-not-wf.rs | 28 + .../regions-struct-not-wf.stderr | 48 + tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.rs | 13 + .../rfcs/rfc-2093-infer-outlives/self-dyn.stderr | 10 + .../rfcs/rfc-2093-infer-outlives/self-structs.rs | 13 + .../rfc-2093-infer-outlives/self-structs.stderr | 10 + .../crate-path-non-absolute.rs | 11 + .../crate-path-non-absolute.stderr | 15 + .../keyword-crate-as-identifier.rs | 4 + .../keyword-crate-as-identifier.stderr | 9 + .../auxiliary/xcrate.rs | 5 + .../non-existent-1.rs | 5 + .../non-existent-1.stderr | 9 + .../non-existent-2.rs | 6 + .../non-existent-2.stderr | 9 + .../non-existent-3.rs | 5 + .../non-existent-3.stderr | 9 + .../rfc-2126-extern-absolute-paths/not-allowed.rs | 9 + .../not-allowed.stderr | 16 + .../single-segment.rs | 11 + .../single-segment.stderr | 21 + tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs | 9 + .../ui/rfcs/rfc-2294-if-let-guard/bindings.stderr | 15 + .../ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs | 96 + .../rfcs/rfc-2294-if-let-guard/feature-gate.stderr | 431 +++++ tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs | 40 + tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs | 15 + tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr | 25 + tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs | 21 + tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr | 28 + tests/ui/rfcs/rfc-2302-self-struct-ctor.rs | 127 -- .../rfc-2302-self-struct-ctor.rs | 127 ++ .../convert-id-const-with-gate.rs | 7 + .../dbg-macro-expected-behavior.rs | 69 + .../dbg-macro-expected-behavior.run.stderr | 28 + .../rfc-2361-dbg-macro/dbg-macro-move-semantics.rs | 10 + .../dbg-macro-move-semantics.stderr | 14 + .../rfc-2361-dbg-macro/dbg-macro-requires-debug.rs | 7 + .../dbg-macro-requires-debug.stderr | 18 + .../feature-gate-do_not_recommend.rs | 21 + .../feature-gate-do_not_recommend.stderr | 25 + .../incorrect-locations.rs | 45 + .../incorrect-locations.stderr | 50 + .../rfc-2397-do-not-recommend/unstable-feature.rs | 10 + .../unstable-feature.stderr | 12 + ...-2421-unreserve-pure-offsetof-sizeof-alignof.rs | 15 - ...of-alignof-sizeof-pure-can-be-used-as-idents.rs | 15 + .../mod_file_nonascii_with_path_allowed-aux.rs | 1 + .../crate_name_nonascii_forbidden-1.rs | 3 + .../crate_name_nonascii_forbidden-1.stderr | 8 + .../crate_name_nonascii_forbidden-2.rs | 6 + .../crate_name_nonascii_forbidden-2.stderr | 8 + .../extern_block_nonascii_forbidden.rs | 9 + .../extern_block_nonascii_forbidden.stderr | 34 + .../rfc-2457-non-ascii-idents/idents-normalized.rs | 7 + .../mod_file_nonascii_forbidden.rs | 4 + .../mod_file_nonascii_forbidden.stderr | 20 + .../mod_file_nonascii_with_path_allowed.rs | 6 + .../mod_inline_nonascii_allowed.rs | 7 + .../no_mangle_nonascii_forbidden.rs | 20 + .../no_mangle_nonascii_forbidden.stderr | 21 + .../ast-lowering-does-not-wrap-let-chains.rs | 16 + .../rfc-2497-if-let-chains/ast-pretty-check.rs | 6 + .../rfc-2497-if-let-chains/ast-pretty-check.stdout | 10 + .../rfc-2497-if-let-chains/ast-validate-guards.rs | 23 + .../ast-validate-guards.stderr | 21 + .../rfc-2497-if-let-chains/chains-without-let.rs | 20 + .../chains-without-let.stderr | 33 + .../rfc-2497-if-let-chains/disallowed-positions.rs | 480 +++++ .../disallowed-positions.stderr | 1911 ++++++++++++++++++++ ...t-let-else-does-not-interact-with-let-chains.rs | 55 + ...t-else-does-not-interact-with-let-chains.stderr | 147 ++ .../ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs | 62 + .../rfc-2497-if-let-chains/feature-gate.stderr | 120 ++ .../invalid-let-in-a-valid-let-context.rs | 45 + .../invalid-let-in-a-valid-let-context.stderr | 38 + .../irrefutable-lets.disallowed.stderr | 115 ++ .../rfc-2497-if-let-chains/irrefutable-lets.rs | 78 + .../ui/rfcs/rfc-2497-if-let-chains/issue-88498.rs | 16 + .../ui/rfcs/rfc-2497-if-let-chains/issue-90722.rs | 11 + .../ui/rfcs/rfc-2497-if-let-chains/issue-92145.rs | 11 + .../ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs | 8 + .../rfcs/rfc-2497-if-let-chains/issue-93150.stderr | 22 + .../ui/rfcs/rfc-2497-if-let-chains/issue-99938.rs | 31 + .../rfc-2497-if-let-chains/no-double-assigments.rs | 9 + .../rfc-2497-if-let-chains/protect-precedences.rs | 17 + .../protect-precedences.stderr | 12 + .../rfc-2497-if-let-chains/then-else-blocks.rs | 49 + .../rfc-2565-param-attrs/attr-without-param.rs | 16 + .../rfc-2565-param-attrs/attr-without-param.stderr | 20 + .../rfc-2565-param-attrs/auxiliary/ident-mac.rs | 11 + .../rfc-2565-param-attrs/auxiliary/param-attrs.rs | 43 + ...issue-64682-dropping-first-attrs-in-impl-fns.rs | 21 + .../rfcs/rfc-2565-param-attrs/param-attrs-2018.rs | 6 + .../rfc-2565-param-attrs/param-attrs-2018.stderr | 22 + .../rfc-2565-param-attrs/param-attrs-allowed.rs | 101 ++ .../param-attrs-builtin-attrs.rs | 174 ++ .../param-attrs-builtin-attrs.stderr | 386 ++++ .../rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs | 121 ++ .../rfc-2565-param-attrs/param-attrs-cfg.stderr | 122 ++ .../rfc-2565-param-attrs/param-attrs-pretty.rs | 61 + .../proc-macro-cannot-be-used.rs | 66 + .../proc-macro-cannot-be-used.stderr | 176 ++ tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs | 19 + .../rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr | 5 + .../import-name-type-invalid-format.rs | 7 + .../import-name-type-invalid-format.stderr | 8 + .../import-name-type-multiple.rs | 8 + .../import-name-type-multiple.stderr | 8 + .../import-name-type-unknown-value.rs | 7 + .../import-name-type-unknown-value.stderr | 8 + .../import-name-type-unsupported-link-kind.rs | 15 + .../import-name-type-unsupported-link-kind.stderr | 14 + .../import-name-type-x86-only.rs | 7 + .../import-name-type-x86-only.stderr | 8 + .../ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs | 13 + .../rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr | 4 + .../rfc-2627-raw-dylib/link-ordinal-and-name.rs | 13 + .../link-ordinal-and-name.stderr | 14 + .../link-ordinal-invalid-format.rs | 11 + .../link-ordinal-invalid-format.stderr | 18 + .../link-ordinal-missing-argument.rs | 11 + .../link-ordinal-missing-argument.stderr | 18 + .../rfc-2627-raw-dylib/link-ordinal-multiple.rs | 12 + .../link-ordinal-multiple.stderr | 26 + .../link-ordinal-not-foreign-fn.rs | 22 + .../link-ordinal-not-foreign-fn.stderr | 20 + .../rfc-2627-raw-dylib/link-ordinal-too-large.rs | 11 + .../link-ordinal-too-large.stderr | 18 + .../link-ordinal-too-many-arguments.rs | 11 + .../link-ordinal-too-many-arguments.stderr | 18 + .../link-ordinal-unsupported-link-kind.rs | 15 + .../link-ordinal-unsupported-link-kind.stderr | 14 + .../rfc-2627-raw-dylib/multiple-declarations.rs | 18 + .../multiple-declarations.stderr | 8 + .../rfc-2627-raw-dylib/raw-dylib-windows-only.rs | 5 + .../raw-dylib-windows-only.stderr | 9 + .../ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs | 12 + .../rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr | 8 + .../assoc-type-const-bound-usage.rs | 14 + .../rfcs/rfc-2632-const-trait-impl/assoc-type.rs | 33 + .../rfc-2632-const-trait-impl/assoc-type.stderr | 8 + .../rfcs/rfc-2632-const-trait-impl/attr-misuse.rs | 10 + .../rfc-2632-const-trait-impl/attr-misuse.stderr | 18 + .../auxiliary/cross-crate.rs | 23 + .../auxiliary/staged-api.rs | 19 + .../call-const-trait-method-fail.rs | 29 + .../call-const-trait-method-fail.stderr | 15 + .../call-const-trait-method-pass.rs | 43 + .../call-const-trait-method-pass.stderr | 20 + .../call-generic-in-impl.rs | 15 + .../call-generic-in-impl.stderr | 8 + .../call-generic-method-chain.rs | 28 + .../call-generic-method-chain.stderr | 23 + .../call-generic-method-dup-bound.rs | 31 + .../call-generic-method-dup-bound.stderr | 23 + .../call-generic-method-fail.rs | 9 + .../call-generic-method-fail.stderr | 28 + .../call-generic-method-nonconst-bound.rs | 17 + .../call-generic-method-nonconst.rs | 26 + .../call-generic-method-nonconst.stderr | 15 + .../call-generic-method-pass.rs | 24 + .../call-generic-method-pass.stderr | 17 + tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs | 10 + .../const-and-non-const-impl.rs | 31 + .../const-and-non-const-impl.stderr | 20 + .../const-check-fns-in-const-impl.rs | 16 + .../const-check-fns-in-const-impl.stderr | 11 + .../const-closure-parse-not-item.rs | 10 + .../const-closure-trait-method-fail.rs | 20 + .../const-closure-trait-method-fail.stderr | 16 + .../const-closure-trait-method.rs | 19 + .../rfc-2632-const-trait-impl/const-closures.rs | 30 + .../const-default-method-bodies.rs | 29 + .../const-default-method-bodies.stderr | 15 + .../rfc-2632-const-trait-impl/const-drop-bound.rs | 25 + .../const-drop-fail-2.precise.stderr | 26 + .../rfc-2632-const-trait-impl/const-drop-fail-2.rs | 43 + .../const-drop-fail-2.stderr | 50 + .../const-drop-fail-2.stock.stderr | 26 + .../const-drop-fail.precise.stderr | 58 + .../rfc-2632-const-trait-impl/const-drop-fail.rs | 37 + .../const-drop-fail.stock.stderr | 58 + .../rfcs/rfc-2632-const-trait-impl/const-drop.rs | 113 ++ .../const-impl-norecover.rs | 12 + .../const-impl-norecover.stderr | 8 + .../const-impl-recovery.rs | 17 + .../const-impl-recovery.stderr | 26 + .../const-impl-requires-const-trait.rs | 9 + .../const-impl-requires-const-trait.stderr | 14 + .../rfc-2632-const-trait-impl/const-impl-trait.rs | 55 + .../const-impl-trait.stderr | 39 + .../const_derives/derive-const-gate.rs | 5 + .../const_derives/derive-const-gate.stderr | 21 + .../const_derives/derive-const-non-const-type.rs | 13 + .../derive-const-non-const-type.stderr | 12 + .../const_derives/derive-const-use.rs | 19 + .../const_derives/derive-const-use.stderr | 53 + .../const_derives/derive-const-with-params.rs | 13 + .../const_derives/derive-const-with-params.stderr | 20 + .../cross-crate-default-method-body-is-const.rs | 18 + .../cross-crate.gatednc.stderr | 15 + .../rfcs/rfc-2632-const-trait-impl/cross-crate.rs | 24 + .../cross-crate.stock.stderr | 12 + .../cross-crate.stocknc.stderr | 15 + .../default-method-body-is-const-body-checking.rs | 17 + ...fault-method-body-is-const-body-checking.stderr | 15 + .../default-method-body-is-const-same-trait-ck.rs | 15 + ...fault-method-body-is-const-same-trait-ck.stderr | 15 + ...default-method-body-is-const-with-staged-api.rs | 17 + .../do-not-const-check-override.rs | 19 + .../do-not-const-check.rs | 18 + .../effects/helloworld.rs | 29 + .../feature-gate.gated.stderr | 8 + .../rfcs/rfc-2632-const-trait-impl/feature-gate.rs | 14 + .../feature-gate.stock.stderr | 21 + .../function-pointer-does-not-require-const.rs | 15 + tests/ui/rfcs/rfc-2632-const-trait-impl/gate.rs | 13 + .../ui/rfcs/rfc-2632-const-trait-impl/gate.stderr | 21 + .../rfc-2632-const-trait-impl/generic-bound.rs | 30 + .../rfc-2632-const-trait-impl/generic-bound.stderr | 11 + .../rfc-2632-const-trait-impl/hir-const-check.rs | 17 + .../hir-const-check.stderr | 12 + .../impl-tilde-const-trait.rs | 9 + .../impl-tilde-const-trait.stderr | 8 + .../impl-with-default-fn-fail.rs | 17 + .../impl-with-default-fn-fail.stderr | 12 + .../impl-with-default-fn-pass.rs | 26 + .../inherent-impl-const-bounds.rs | 22 + .../rfc-2632-const-trait-impl/inherent-impl.rs | 13 + .../rfc-2632-const-trait-impl/inherent-impl.stderr | 22 + .../rfcs/rfc-2632-const-trait-impl/issue-100222.rs | 39 + .../rfcs/rfc-2632-const-trait-impl/issue-102156.rs | 15 + .../rfc-2632-const-trait-impl/issue-102156.stderr | 19 + .../rfcs/rfc-2632-const-trait-impl/issue-102985.rs | 12 + .../rfc-2632-const-trait-impl/issue-102985.stderr | 41 + .../rfcs/rfc-2632-const-trait-impl/issue-103677.rs | 5 + .../rfcs/rfc-2632-const-trait-impl/issue-79450.rs | 20 + .../rfc-2632-const-trait-impl/issue-79450.stderr | 12 + .../rfcs/rfc-2632-const-trait-impl/issue-88155.rs | 13 + .../rfc-2632-const-trait-impl/issue-88155.stderr | 24 + .../rfcs/rfc-2632-const-trait-impl/issue-90052.rs | 9 + .../rfc-2632-const-trait-impl/issue-90052.stderr | 14 + .../rfcs/rfc-2632-const-trait-impl/issue-92111.rs | 23 + .../issue-92230-wf-super-trait-env.rs | 15 + .../match-non-const-eq.gated.stderr | 26 + .../match-non-const-eq.rs | 12 + .../match-non-const-eq.stock.stderr | 13 + .../rfc-2632-const-trait-impl/nested-closure.rs | 12 + .../non-const-op-const-closure-non-const-outer.rs | 15 + ...n-const-op-const-closure-non-const-outer.stderr | 11 + .../non-const-op-in-closure-in-const.rs | 18 + .../non-const-op-in-closure-in-const.stderr | 8 + ...st-default-bound-non-const-specialized-bound.rs | 58 + ...efault-bound-non-const-specialized-bound.stderr | 18 + .../const-default-const-specialized.rs | 39 + ...onst-default-impl-non-const-specialized-impl.rs | 26 + ...-default-impl-non-const-specialized-impl.stderr | 8 + .../specialization/default-keyword.rs | 15 + .../issue-95186-specialize-on-tilde-const.rs | 49 + ...e-95187-same-trait-bound-different-constness.rs | 57 + .../non-const-default-const-specialized.rs | 39 + .../specializing-constness-2.rs | 31 + .../specializing-constness-2.stderr | 21 + .../specializing-constness.rs | 31 + .../specializing-constness.stderr | 14 + .../staged-api-user-crate.rs | 16 + .../staged-api-user-crate.stderr | 12 + .../rfcs/rfc-2632-const-trait-impl/staged-api.rs | 63 + .../staged-api.stable.stderr | 25 + .../staged-api.unstable.stderr | 42 + .../static-const-trait-bound.rs | 18 + .../std-impl-gate.gated.stderr | 9 + .../rfc-2632-const-trait-impl/std-impl-gate.rs | 21 + .../std-impl-gate.stock.stderr | 12 + .../super-traits-fail-2.nn.stderr | 14 + .../super-traits-fail-2.ny.stderr | 14 + .../super-traits-fail-2.rs | 20 + .../super-traits-fail-2.yn.stderr | 19 + .../super-traits-fail-2.yy.stderr | 19 + .../super-traits-fail-3.nn.stderr | 20 + .../super-traits-fail-3.ny.stderr | 14 + .../super-traits-fail-3.rs | 21 + .../super-traits-fail-3.yn.stderr | 8 + .../rfc-2632-const-trait-impl/super-traits-fail.rs | 18 + .../super-traits-fail.stderr | 20 + .../rfcs/rfc-2632-const-trait-impl/super-traits.rs | 25 + tests/ui/rfcs/rfc-2632-const-trait-impl/syntax.rs | 8 + .../tilde-const-and-const-params.rs | 34 + .../tilde-const-and-const-params.stderr | 14 + .../tilde-const-invalid-places.rs | 7 + .../tilde-const-invalid-places.stderr | 8 + .../tilde-const-syntax.rs | 9 + .../rfcs/rfc-2632-const-trait-impl/tilde-twice.rs | 6 + .../rfc-2632-const-trait-impl/tilde-twice.stderr | 8 + .../tilde_const_on_impl_bound.rs | 17 + .../trait-default-body-stability.rs | 50 + .../trait-default-body-stability.stderr | 20 + .../trait-method-ptr-in-consts-ice.rs | 23 + .../trait-where-clause-const.rs | 31 + .../trait-where-clause-const.stderr | 35 + .../trait-where-clause-run.rs | 41 + .../trait-where-clause-self-referential.rs | 24 + .../trait-where-clause.rs | 26 + .../trait-where-clause.stderr | 35 + .../rfc-2632-const-trait-impl/without-tilde.rs | 6 + .../rfc-2632-const-trait-impl/without-tilde.stderr | 10 + .../rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs | 23 - tests/ui/rfcs/rfc1445/eq-allows-match.rs | 17 - tests/ui/rfcs/rfc1623-2.rs | 99 - tests/ui/rfcs/rfc1623-2.stderr | 39 - tests/ui/rfcs/rfc1623-3.rs | 14 - tests/ui/rfcs/rfc1623-3.stderr | 35 - tests/ui/rfcs/rfc1623.rs | 75 - tests/ui/rfcs/rfc1717/library-override.rs | 14 - tests/ui/rfcs/rfc1857-drop-order.rs | 224 --- .../ui/rust-2018/edition-lint-infer-outlives.fixed | 6 + tests/ui/rust-2018/edition-lint-infer-outlives.rs | 8 + .../rust-2018/edition-lint-infer-outlives.stderr | 11 +- .../uniform-paths/ambiguity-macros-nested.stderr | 2 +- .../uniform-paths/ambiguity-macros.stderr | 2 +- .../ui/rust-2018/uniform-paths/ambiguity-nested.rs | 4 +- .../uniform-paths/ambiguity-nested.stderr | 21 - tests/ui/rust-2018/uniform-paths/ambiguity.rs | 4 +- tests/ui/rust-2018/uniform-paths/ambiguity.stderr | 21 - .../uniform-paths/block-scoped-shadow-nested.rs | 3 +- .../block-scoped-shadow-nested.stderr | 24 - .../rust-2018/uniform-paths/block-scoped-shadow.rs | 8 +- .../uniform-paths/block-scoped-shadow.stderr | 60 - .../ui/rust-2018/uniform-paths/issue-56596.stderr | 5 +- tests/ui/rust-2018/uniform-paths/macro-rules.rs | 3 +- .../ui/rust-2018/uniform-paths/macro-rules.stderr | 24 +- .../ui/sanitize/issue-111184-generator-witness.rs | 17 + tests/ui/simd/shuffle.rs | 24 +- ...ust-2021-incompatible-closure-captures-96258.rs | 4 +- ...2021-incompatible-closure-captures-96258.stderr | 27 +- tests/ui/span/multiline-span-simple.stderr | 4 +- ...n-default-items-drop-coherence.coherence.stderr | 12 + ...zation-default-items-drop-coherence.next.stderr | 12 + .../specialization-default-items-drop-coherence.rs | 9 +- .../stability-attribute/auxiliary/default_body.rs | 4 + .../default-body-stability-err.rs | 1 + .../default-body-stability-err.stderr | 14 +- .../default-body-stability-ok-impls.rs | 2 + .../stability-in-private-module.stderr | 4 +- tests/ui/statics/uninhabited-static.stderr | 4 +- tests/ui/std/slice-from-array-issue-113238.rs | 9 + tests/ui/stdlib-unit-tests/not-sync.rs | 2 - tests/ui/stdlib-unit-tests/not-sync.stderr | 15 +- tests/ui/structs-enums/issue-3008-1.rs | 12 + tests/ui/structs-enums/issue-3008-1.stderr | 17 + tests/ui/structs-enums/issue-3008-2.rs | 6 + tests/ui/structs-enums/issue-3008-2.stderr | 14 + tests/ui/structs-enums/issue-3008-3.rs | 10 + tests/ui/structs-enums/issue-3008-3.stderr | 14 + tests/ui/structs/struct-field-cfg.stderr | 2 +- tests/ui/structs/struct-fields-shorthand.stderr | 2 +- tests/ui/structs/struct-fields-too-many.stderr | 2 +- tests/ui/structs/struct-variant-privacy-xc.stderr | 4 +- tests/ui/structs/struct-variant-privacy.stderr | 4 +- .../adt-param-with-implicit-sized-bound.stderr | 2 +- tests/ui/suggestions/as-ref.rs | 2 + tests/ui/suggestions/as-ref.stderr | 32 +- tests/ui/suggestions/crate-or-module-typo.stderr | 5 + .../dont-suggest-try_into-in-macros.stderr | 12 +- .../impl-trait-return-trailing-semicolon.stderr | 2 +- tests/ui/suggestions/into-str.stderr | 8 +- tests/ui/suggestions/issue-102972.rs | 16 + tests/ui/suggestions/issue-102972.stderr | 33 + tests/ui/suggestions/issue-103646.rs | 11 + tests/ui/suggestions/issue-103646.stderr | 21 + tests/ui/suggestions/issue-109991.rs | 27 + tests/ui/suggestions/issue-109991.stderr | 72 + .../ui/suggestions/issue-112590-suggest-import.rs | 10 + .../suggestions/issue-112590-suggest-import.stderr | 36 + .../ui/suggestions/issue-71394-no-from-impl.stderr | 6 +- tests/ui/suggestions/issue-88696.rs | 14 + tests/ui/suggestions/issue-88696.stderr | 11 + tests/ui/suggestions/issue-89640.rs | 3 + tests/ui/suggestions/issue-89640.stderr | 13 + ...of-multiline-trait-bound-in-where-clause.stderr | 6 +- tests/ui/suggestions/suggest-split-at-mut.stderr | 1 + tests/ui/suggestions/while-let-typo.rs | 2 +- tests/ui/suggestions/while-let-typo.stderr | 13 +- tests/ui/switched-expectations.stderr | 4 +- .../const-generics-structural-demangling.rs | 25 +- .../const-generics-structural-demangling.stderr | 62 +- ...nature-verification-for-explicit-return-type.rs | 2 +- tests/ui/test-attrs/test-function-signature.rs | 31 + tests/ui/test-attrs/test-function-signature.stderr | 39 + tests/ui/test-attrs/test-panic-abort-disabled.rs | 1 + tests/ui/test-attrs/test-panic-abort.rs | 9 + tests/ui/test-attrs/test-panic-abort.run.stdout | 7 +- tests/ui/test-attrs/test-type.rs | 3 +- tests/ui/thir-print/thir-flat-const-variant.rs | 18 + tests/ui/thir-print/thir-flat-const-variant.stdout | 399 ++++ tests/ui/thir-print/thir-flat.stdout | 2 +- tests/ui/track-diagnostics/track6.stderr | 2 +- tests/ui/trait-bounds/apit-unsized.rs | 4 + tests/ui/trait-bounds/apit-unsized.stderr | 41 + tests/ui/trait-bounds/unsized-bound.stderr | 30 +- tests/ui/traits/auxiliary/trivial3.rs | 1 + tests/ui/traits/auxiliary/trivial4.rs | 3 + .../bound/assoc-fn-bound-root-obligation.stderr | 6 +- tests/ui/traits/bound/generic_trait.rs | 2 +- tests/ui/traits/cache-reached-depth-ice.rs | 2 +- tests/ui/traits/cache-reached-depth-ice.stderr | 2 +- .../traits/deny-builtin-object-impl.current.stderr | 15 + .../ui/traits/deny-builtin-object-impl.next.stderr | 15 + tests/ui/traits/deny-builtin-object-impl.rs | 20 + tests/ui/traits/ice-with-dyn-pointee-errors.rs | 15 + tests/ui/traits/ice-with-dyn-pointee-errors.stderr | 19 + tests/ui/traits/ice-with-dyn-pointee.rs | 11 + tests/ui/traits/issue-105231.rs | 9 + tests/ui/traits/issue-105231.stderr | 29 + .../issue-83538-tainted-cache-after-cycle.rs | 8 +- .../issue-83538-tainted-cache-after-cycle.stderr | 8 +- tests/ui/traits/issue-85360-eval-obligation-ice.rs | 8 +- .../traits/issue-85360-eval-obligation-ice.stderr | 8 +- tests/ui/traits/issue-91949-hangs-on-recursion.rs | 1 + .../traits/issue-91949-hangs-on-recursion.stderr | 4 +- tests/ui/traits/new-solver/alias-bound-unsound.rs | 2 +- .../traits/new-solver/alias-bound-unsound.stderr | 16 +- .../alias_eq_substs_eq_not_intercrate.rs | 19 +- .../alias_eq_substs_eq_not_intercrate.stderr | 11 + tests/ui/traits/new-solver/array-default.rs | 8 + tests/ui/traits/new-solver/async.fail.stderr | 4 +- tests/ui/traits/new-solver/async.rs | 2 +- .../traits/new-solver/closure-substs-ambiguity.rs | 7 + tests/ui/traits/new-solver/dedup-regions.rs | 31 + .../ui/traits/new-solver/dont-remap-tait-substs.rs | 19 + ...-type_of-tait-in-defining-scope.not_send.stderr | 16 + .../dont-type_of-tait-in-defining-scope.rs | 24 + .../traits/new-solver/dyn-any-dont-prefer-impl.rs | 13 + .../new-solver/equating-projection-cyclically.rs | 12 +- .../equating-projection-cyclically.stderr | 9 +- .../traits/new-solver/lazy-nested-obligations-2.rs | 3 +- .../new-solver/lazy-nested-obligations-2.stderr | 39 + .../new-solver/leak-check-coinductive-cycle.rs | 33 + .../member-constraints-in-root-universe.rs | 17 + .../new-solver/normalized-const-built-in-op.rs | 11 + tests/ui/traits/new-solver/object-unsafety.rs | 10 +- tests/ui/traits/new-solver/object-unsafety.stderr | 63 +- .../new-solver/opportunistic-region-resolve.rs | 19 + .../new-solver/recursive-self-normalization-2.rs | 1 + .../recursive-self-normalization-2.stderr | 10 +- .../new-solver/recursive-self-normalization.rs | 1 + .../new-solver/recursive-self-normalization.stderr | 10 +- tests/ui/traits/new-solver/slice-match-byte-lit.rs | 11 + .../traits/new-solver/specialization-transmute.rs | 12 +- .../new-solver/specialization-transmute.stderr | 22 +- .../new-solver/specialization-unconstrained.rs | 2 +- .../new-solver/specialization-unconstrained.stderr | 11 +- tests/ui/traits/new-solver/tait-eq-proj-2.rs | 23 + tests/ui/traits/new-solver/tait-eq-proj.rs | 35 + tests/ui/traits/new-solver/tait-eq-tait.rs | 18 + ...rojection-param-candidates-are-ambiguous.stderr | 1 + .../unevaluated-const-impl-trait-ref.fails.stderr | 18 + .../new-solver/unevaluated-const-impl-trait-ref.rs | 22 + .../traits/new-solver/winnow-specializing-impls.rs | 22 + .../non_lifetime_binders/foreach-partial-eq.rs | 12 + .../non_lifetime_binders/foreach-partial-eq.stderr | 28 + .../nested-apit-mentioning-outer-bound-var.rs | 11 + .../nested-apit-mentioning-outer-bound-var.stderr | 17 + tests/ui/traits/object/print_vtable_sizes.rs | 61 + tests/ui/traits/object/print_vtable_sizes.stdout | 11 + tests/ui/traits/project-modulo-regions.rs | 4 +- .../project-modulo-regions.with_clause.stderr | 2 +- .../project-modulo-regions.without_clause.stderr | 2 +- tests/ui/traits/suggest-where-clause.stderr | 4 +- tests/ui/traits/trivial_impl.rs | 18 + tests/ui/traits/trivial_impl.stderr | 14 + tests/ui/traits/trivial_impl2.rs | 13 + tests/ui/traits/trivial_impl2.stderr | 14 + tests/ui/traits/trivial_impl3.rs | 19 + tests/ui/traits/trivial_impl3.stderr | 14 + tests/ui/traits/trivial_impl4.rs | 21 + tests/ui/traits/trivial_impl4.stderr | 14 + tests/ui/traits/trivial_impl_sized.rs | 26 + tests/ui/traits/trivial_impl_sized.stderr | 25 + tests/ui/transmutability/alignment/align-fail.rs | 23 + .../ui/transmutability/alignment/align-fail.stderr | 30 + tests/ui/transmutability/alignment/align-pass.rs | 23 + ...imitive_reprs_should_have_correct_length.stderr | 16 +- .../unknown_src_field.rs | 2 +- .../unknown_src_field.stderr | 20 +- tests/ui/transmutability/primitives/bool-mut.rs | 17 + .../ui/transmutability/primitives/bool-mut.stderr | 18 + .../transmutability/primitives/bool.current.stderr | 4 +- .../ui/transmutability/primitives/bool.next.stderr | 4 +- tests/ui/transmutability/primitives/bool.rs | 5 +- tests/ui/transmutability/references.current.stderr | 25 - tests/ui/transmutability/references.next.stderr | 25 - tests/ui/transmutability/references.rs | 30 - .../recursive-wrapper-types-bit-compatible-mut.rs | 25 + ...cursive-wrapper-types-bit-compatible-mut.stderr | 25 + .../recursive-wrapper-types-bit-compatible.rs | 26 + .../recursive-wrapper-types-bit-compatible.stderr | 25 + .../recursive-wrapper-types-bit-incompatible.rs | 25 + ...recursive-wrapper-types-bit-incompatible.stderr | 25 + .../references/recursive-wrapper-types.rs | 27 + .../references/recursive-wrapper-types.stderr | 25 + tests/ui/transmutability/references/u8-to-unit.rs | 24 + .../transmutability/references/unit-to-itself.rs | 24 + tests/ui/transmutability/references/unit-to-u8.rs | 24 + .../transmutability/references/unit-to-u8.stderr | 25 + tests/ui/transmutability/region-infer.stderr | 2 +- .../ui/treat-err-as-bug/panic-causes-oom-112708.rs | 10 + .../panic-causes-oom-112708.stderr | 32 + tests/ui/try-block/issue-45124.rs | 2 +- tests/ui/try-trait/bad-interconversion.stderr | 6 +- tests/ui/try-trait/option-to-result.stderr | 2 +- tests/ui/try-trait/try-on-option.stderr | 2 +- tests/ui/tuple/index-float.rs | 6 +- .../ui/type-alias-impl-trait/auto-trait-leakage.rs | 4 +- .../type-alias-impl-trait/auto-trait-leakage3.rs | 4 +- .../auto-trait-leakage3.stderr | 52 +- tests/ui/type-alias-impl-trait/bound_reduction2.rs | 1 + .../type-alias-impl-trait/bound_reduction2.stderr | 16 +- .../type-alias-impl-trait/bounds-are-checked3.rs | 16 + .../bounds-are-checked3.stderr | 20 + tests/ui/type-alias-impl-trait/bounds.rs | 16 + tests/ui/type-alias-impl-trait/closure_args.rs | 11 +- tests/ui/type-alias-impl-trait/closure_args2.rs | 23 +- tests/ui/type-alias-impl-trait/coherence.stderr | 2 +- .../coherence_different_hidden_ty.rs | 25 + .../coherence_different_hidden_ty.stderr | 12 + .../coherence_generalization.rs | 2 + tests/ui/type-alias-impl-trait/cross_inference.rs | 6 +- .../ui/type-alias-impl-trait/debug-ty-with-weak.rs | 12 + .../declared_but_not_defined_in_scope.stderr | 5 + .../defined-by-user-annotation.rs | 19 + .../defining-use-submodule.rs | 6 +- .../different_defining_uses_never_type-2.rs | 3 +- .../different_defining_uses_never_type-2.stderr | 6 +- .../different_defining_uses_never_type-3.rs | 3 +- .../generic_duplicate_lifetime_param.rs | 1 + .../generic_duplicate_lifetime_param.stderr | 16 +- .../generic_duplicate_param_use.rs | 12 +- .../generic_duplicate_param_use.stderr | 50 +- .../generic_nondefining_use.rs | 9 +- .../generic_nondefining_use.stderr | 44 +- .../generic_type_does_not_live_long_enough.rs | 12 +- .../generic_type_does_not_live_long_enough.stderr | 20 +- .../generic_underconstrained.stderr | 4 +- .../generic_underconstrained2.stderr | 8 +- ...hidden_behind_projection_behind_struct_field.rs | 28 + ...en_behind_projection_behind_struct_field.stderr | 20 + .../hidden_behind_struct_field.rs | 30 + .../hidden_behind_struct_field2.rs | 26 + .../type-alias-impl-trait/higher_kinded_params.rs | 28 + .../type-alias-impl-trait/higher_kinded_params2.rs | 35 + .../higher_kinded_params2.stderr | 15 + .../type-alias-impl-trait/higher_kinded_params3.rs | 36 + .../higher_kinded_params3.stderr | 28 + .../impl-trait-in-type-alias-with-bad-substs.rs | 28 + ...impl-trait-in-type-alias-with-bad-substs.stderr | 20 + .../type-alias-impl-trait/impl_for_weak_alias.rs | 14 + .../impl_for_weak_alias.stderr | 11 + tests/ui/type-alias-impl-trait/inference-cycle.rs | 8 +- .../type-alias-impl-trait/inference-cycle.stderr | 52 +- .../invalid_impl_trait_in_assoc_ty.stderr | 4 +- tests/ui/type-alias-impl-trait/issue-109054.rs | 22 + tests/ui/type-alias-impl-trait/issue-109054.stderr | 12 + .../issue-53398-cyclic-types.rs | 3 +- .../issue-53398-cyclic-types.stderr | 12 - .../issue-53678-generator-and-const-fn.rs | 21 +- .../issue-53678-generator-and-const-fn.stderr | 8 - tests/ui/type-alias-impl-trait/issue-57961.rs | 4 +- tests/ui/type-alias-impl-trait/issue-60564.rs | 1 + tests/ui/type-alias-impl-trait/issue-60564.stderr | 16 +- .../issue-63263-closure-return.rs | 5 +- .../issue-65679-inst-opaque-ty-from-val-twice.rs | 4 +- .../issue-68368-non-defining-use-2.rs | 3 +- .../issue-68368-non-defining-use-2.stderr | 14 +- .../issue-68368-non-defining-use.rs | 1 + .../issue-68368-non-defining-use.stderr | 14 +- .../issue-69136-inner-lifetime-resolve-error.rs | 7 +- ...issue-69136-inner-lifetime-resolve-error.stderr | 16 +- tests/ui/type-alias-impl-trait/issue-70121.rs | 3 +- tests/ui/type-alias-impl-trait/issue-70121.stderr | 15 + .../issue-76202-trait-impl-for-tait.rs | 2 + tests/ui/type-alias-impl-trait/issue-77179.rs | 2 +- tests/ui/type-alias-impl-trait/multi-error.rs | 23 + tests/ui/type-alias-impl-trait/multi-error.stderr | 15 + .../multiple-def-uses-in-one-fn.rs | 1 - .../multiple-def-uses-in-one-fn.stderr | 11 +- .../nested-tait-inference2.stderr | 2 +- .../ui/type-alias-impl-trait/nested_in_closure.rs | 17 + .../nested_type_alias_impl_trait.rs | 4 +- .../no_revealing_outside_defining_module.stderr | 10 + .../type-alias-impl-trait/non-defining-method.rs | 21 + .../non-defining-method.stderr | 15 + .../normalize-hidden-types.current.stderr | 55 + .../normalize-hidden-types.rs | 60 + .../not-matching-trait-refs-isnt-defining.rs | 33 + .../not-matching-trait-refs-isnt-defining.stderr | 22 + tests/ui/type-alias-impl-trait/obligation_ice.rs | 17 + tests/ui/type-alias-impl-trait/privacy.rs | 8 + tests/ui/type-alias-impl-trait/privacy.stderr | 11 + tests/ui/type-alias-impl-trait/reveal_local.rs | 10 +- tests/ui/type-alias-impl-trait/reveal_local.stderr | 96 +- .../ui/type-alias-impl-trait/self-referential-3.rs | 2 +- .../self-referential-3.stderr | 15 + tests/ui/type-alias-impl-trait/self-referential.rs | 2 +- .../type-alias-impl-trait/self-referential.stderr | 6 +- .../type-alias-impl-trait-fns.rs | 8 +- tests/ui/type-alias-impl-trait/type_of_a_let.rs | 8 +- .../ui/type-alias-impl-trait/type_of_a_let.stderr | 6 +- .../issue-113283-alllocator-trait-eq.rs | 18 + tests/ui/type/type-check-defaults.stderr | 4 +- ...dont-record-adjustments-when-pointing-at-arg.rs | 29 + ...-record-adjustments-when-pointing-at-arg.stderr | 17 + tests/ui/typeck/issue-106929.rs | 13 + tests/ui/typeck/issue-106929.stderr | 15 + .../typeck/issue-112252-ptr-arithmetics-help.fixed | 10 + .../ui/typeck/issue-112252-ptr-arithmetics-help.rs | 10 + .../issue-112252-ptr-arithmetics-help.stderr | 54 + ...issue-112385-while-assign-lhs-place-expr-ice.rs | 9 + ...e-112385-while-assign-lhs-place-expr-ice.stderr | 14 + tests/ui/typeck/issue-1871.rs | 12 + tests/ui/typeck/issue-1871.stderr | 9 + tests/ui/typeck/issue-2063-resource.rs | 14 + tests/ui/typeck/issue-2063.rs | 22 + tests/ui/typeck/issue-81293.stderr | 4 +- tests/ui/typeck/issue-86721-return-expr-ice.rs | 2 +- tests/ui/typeck/issue-89856.stderr | 2 +- tests/ui/typeck/issue-90101.stderr | 2 +- .../typeck/ptr-null-mutability-suggestions.fixed | 11 + tests/ui/typeck/ptr-null-mutability-suggestions.rs | 11 + .../typeck/ptr-null-mutability-suggestions.stderr | 21 + tests/ui/typeck/return-dyn-type-mismatch-2.rs | 11 + tests/ui/typeck/return-dyn-type-mismatch-2.stderr | 15 + tests/ui/typeck/return-dyn-type-mismatch.rs | 21 + tests/ui/typeck/return-dyn-type-mismatch.stderr | 15 + tests/ui/typeck/type-placeholder-fn-in-const.rs | 3 +- .../ui/typeck/type-placeholder-fn-in-const.stderr | 10 +- tests/ui/typeck/typeck_type_placeholder_item.rs | 8 +- .../ui/typeck/typeck_type_placeholder_item.stderr | 8 +- .../ui/typeck/typeck_type_placeholder_item_help.rs | 4 +- .../typeck_type_placeholder_item_help.stderr | 4 +- tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr | 8 +- ...e-clause-inherent-impl-ampersand-rust2015.fixed | 17 + ...here-clause-inherent-impl-ampersand-rust2015.rs | 17 + ...-clause-inherent-impl-ampersand-rust2015.stderr | 14 + ...e-clause-inherent-impl-ampersand-rust2018.fixed | 18 + ...here-clause-inherent-impl-ampersand-rust2018.rs | 18 + ...-clause-inherent-impl-ampersand-rust2018.stderr | 14 + .../where-clause-inherent-impl-ampersand.rs | 18 - ...-clause-inherent-impl-ampersand.rust2015.stderr | 15 - ...-clause-inherent-impl-ampersand.rust2018.stderr | 15 - .../where-clause-trait-impl-region-2015.fixed | 14 + .../where-clause-trait-impl-region-2015.rs | 14 + .../where-clause-trait-impl-region-2015.stderr | 14 + .../where-clause-trait-impl-region-2018.fixed | 15 + .../where-clause-trait-impl-region-2018.rs | 15 + .../where-clause-trait-impl-region-2018.stderr | 14 + .../where-clause-trait-impl-region.rs | 15 - .../where-clause-trait-impl-region.rust2015.stderr | 15 - .../where-clause-trait-impl-region.rust2018.stderr | 15 - tests/ui/uninhabited/projection.rs | 32 + tests/ui/union/union-fields-2.mirunsafeck.stderr | 2 +- tests/ui/union/union-fields-2.thirunsafeck.stderr | 2 +- tests/ui/union/union-sized-field.stderr | 6 +- tests/ui/unsafe/auxiliary/external_unsafe_macro.rs | 4 + .../rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr | 10 + tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed | 66 + tests/ui/unsafe/wrapping-unsafe-block-sugg.rs | 66 + tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr | 99 + tests/ui/unsized-locals/issue-67981.stderr | 5 +- tests/ui/unsized-locals/rust-call.rs | 12 + tests/ui/unsized-locals/rust-call.stderr | 13 + tests/ui/unsized/issue-71659.current.stderr | 18 + tests/ui/unsized/issue-71659.next.stderr | 18 + tests/ui/unsized/issue-71659.rs | 3 + tests/ui/unsized/issue-71659.stderr | 18 - tests/ui/unsized/unsized-bare-typaram.stderr | 2 +- tests/ui/unsized/unsized-enum.stderr | 2 +- tests/ui/unsized/unsized-enum2.stderr | 8 +- tests/ui/unsized/unsized-fn-arg.stderr | 2 +- .../unsized/unsized-inherent-impl-self-type.stderr | 2 +- tests/ui/unsized/unsized-struct.stderr | 4 +- .../ui/unsized/unsized-trait-impl-self-type.stderr | 2 +- .../ui/unsized/unsized-trait-impl-trait-arg.stderr | 2 +- tests/ui/unsized/unsized3.stderr | 12 +- tests/ui/unsized/unsized5.stderr | 8 +- tests/ui/unsized/unsized6.stderr | 26 +- tests/ui/unsized/unsized7.stderr | 2 +- tests/ui/use/use-keyword.rs | 2 +- tests/ui/weird-exprs.rs | 16 +- tests/ui/where-clauses/issue-50825-1.rs | 22 + tests/ui/where-clauses/issue-50825.rs | 15 + tests/ui/xcrate/xcrate-private-by-default.stderr | 20 +- 2497 files changed, 36971 insertions(+), 25965 deletions(-) create mode 100644 tests/ui/abi/issue-94223.rs create mode 100644 tests/ui/argument-suggestions/issue-112507.rs create mode 100644 tests/ui/argument-suggestions/issue-112507.stderr create mode 100644 tests/ui/asm/parse-error.rs create mode 100644 tests/ui/asm/parse-error.stderr delete mode 100644 tests/ui/asm/x86_64/parse-error.rs delete mode 100644 tests/ui/asm/x86_64/parse-error.stderr create mode 100644 tests/ui/asm/x86_64/x86_64_parse_error.rs create mode 100644 tests/ui/asm/x86_64/x86_64_parse_error.stderr create mode 100644 tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs create mode 100644 tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr create mode 100644 tests/ui/associated-consts/issue-110933.rs create mode 100644 tests/ui/associated-inherent-types/dont-select-if-disabled.rs create mode 100644 tests/ui/associated-inherent-types/dont-select-if-disabled.stderr create mode 100644 tests/ui/associated-inherent-types/issue-109071.no_gate.stderr create mode 100644 tests/ui/associated-inherent-types/issue-109071.rs create mode 100644 tests/ui/associated-inherent-types/issue-109071.with_gate.stderr create mode 100644 tests/ui/associated-inherent-types/issue-111404-0.rs create mode 100644 tests/ui/associated-inherent-types/issue-111404-1.rs create mode 100644 tests/ui/associated-inherent-types/issue-111404-1.stderr create mode 100644 tests/ui/associated-type-bounds/implied-in-supertrait.rs create mode 100644 tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr delete 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/basic.current_with.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr create mode 100644 tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr delete mode 100644 tests/ui/associated-type-bounds/return-type-notation/equality.stderr create mode 100644 tests/ui/associated-types/dont-suggest-cyclic-constraint.rs create mode 100644 tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr create mode 100644 tests/ui/async-await/deep-futures-are-freeze.rs delete mode 100644 tests/ui/async-await/in-trait/async-associated-types2.rs create mode 100644 tests/ui/async-await/in-trait/missing-feature-flag.current.stderr create 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.rs create mode 100644 tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs create mode 100644 tests/ui/async-await/in-trait/return-not-existing-pair.current.stderr create 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.rs create mode 100644 tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.current.stderr create 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.rs create mode 100644 tests/ui/async-await/issue-78115.rs create mode 100644 tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr create mode 100644 tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr delete 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.current.stderr create mode 100644 tests/ui/async-await/return-type-notation/issue-110963-late.next.stderr delete mode 100644 tests/ui/async-await/return-type-notation/issue-110963-late.stderr create mode 100644 tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs create mode 100644 tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr create mode 100644 tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs create mode 100644 tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr create mode 100644 tests/ui/async-await/return-type-notation/super-method-bound.current.stderr create mode 100644 tests/ui/async-await/return-type-notation/super-method-bound.next.stderr delete 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.current.stderr create mode 100644 tests/ui/async-await/return-type-notation/supertrait-bound.next.stderr delete 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.current.stderr create mode 100644 tests/ui/async-await/return-type-notation/ty-or-ct-params.next.stderr create mode 100644 tests/ui/async-await/return-type-notation/ty-or-ct-params.rs create mode 100644 tests/ui/attributes/doc-test-literal.rs create mode 100644 tests/ui/attributes/doc-test-literal.stderr create mode 100644 tests/ui/auto-traits/issue-23080-2.current.stderr create mode 100644 tests/ui/auto-traits/issue-23080-2.next.stderr delete mode 100644 tests/ui/auto-traits/issue-23080-2.stderr create mode 100644 tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs create mode 100644 tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr create mode 100644 tests/ui/borrowck/issue-111554.rs create mode 100644 tests/ui/borrowck/issue-111554.stderr create mode 100644 tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs create mode 100644 tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs create mode 100644 tests/ui/cfg/auxiliary/cfged_out.rs create mode 100644 tests/ui/cfg/cfg_false_no_std-1.rs create mode 100644 tests/ui/cfg/cfg_false_no_std-2.rs create mode 100644 tests/ui/cfg/diagnostics-cross-crate.rs create mode 100644 tests/ui/cfg/diagnostics-cross-crate.stderr create mode 100644 tests/ui/cfg/diagnostics-not-a-def.rs create mode 100644 tests/ui/cfg/diagnostics-not-a-def.stderr create mode 100644 tests/ui/cfg/diagnostics-reexport.rs create mode 100644 tests/ui/cfg/diagnostics-reexport.stderr create mode 100644 tests/ui/cfg/diagnostics-same-crate.rs create mode 100644 tests/ui/cfg/diagnostics-same-crate.stderr delete mode 100644 tests/ui/chalkify/arithmetic.rs delete mode 100644 tests/ui/chalkify/assert.rs delete mode 100644 tests/ui/chalkify/basic.rs delete mode 100644 tests/ui/chalkify/bugs/async.rs delete mode 100644 tests/ui/chalkify/bugs/async.stderr delete mode 100644 tests/ui/chalkify/builtin-copy-clone.rs delete mode 100644 tests/ui/chalkify/chalk_initial_program.rs delete mode 100644 tests/ui/chalkify/chalk_initial_program.stderr delete mode 100644 tests/ui/chalkify/closure.rs delete mode 100644 tests/ui/chalkify/closure.stderr delete mode 100644 tests/ui/chalkify/generic_impls.rs delete mode 100644 tests/ui/chalkify/generic_impls.stderr delete mode 100644 tests/ui/chalkify/impl_wf.rs delete mode 100644 tests/ui/chalkify/impl_wf.stderr delete mode 100644 tests/ui/chalkify/impl_wf_2.rs delete mode 100644 tests/ui/chalkify/impl_wf_2.stderr delete mode 100644 tests/ui/chalkify/inherent_impl.rs delete mode 100644 tests/ui/chalkify/inherent_impl_min.rs delete mode 100644 tests/ui/chalkify/lower_env1.rs delete mode 100644 tests/ui/chalkify/lower_env2.rs delete mode 100644 tests/ui/chalkify/lower_env3.rs delete mode 100644 tests/ui/chalkify/lower_impl.rs delete mode 100644 tests/ui/chalkify/lower_struct.rs delete mode 100644 tests/ui/chalkify/lower_trait.rs delete mode 100644 tests/ui/chalkify/lower_trait_higher_rank.rs delete mode 100644 tests/ui/chalkify/lower_trait_where_clause.rs delete mode 100644 tests/ui/chalkify/println.rs delete mode 100644 tests/ui/chalkify/projection.rs delete mode 100644 tests/ui/chalkify/recursive_where_clause_on_type.rs delete mode 100644 tests/ui/chalkify/recursive_where_clause_on_type.stderr delete mode 100644 tests/ui/chalkify/super_trait.rs delete mode 100644 tests/ui/chalkify/trait-objects.rs delete mode 100644 tests/ui/chalkify/trait_implied_bound.rs delete mode 100644 tests/ui/chalkify/type_implied_bound.rs delete mode 100644 tests/ui/chalkify/type_inference.rs delete mode 100644 tests/ui/chalkify/type_inference.stderr delete mode 100644 tests/ui/chalkify/type_wf.rs delete mode 100644 tests/ui/chalkify/type_wf.stderr create mode 100644 tests/ui/closures/cannot-call-unsized-via-ptr-2.rs create mode 100644 tests/ui/closures/cannot-call-unsized-via-ptr-2.stderr create mode 100644 tests/ui/closures/cannot-call-unsized-via-ptr.rs create mode 100644 tests/ui/closures/cannot-call-unsized-via-ptr.stderr create mode 100644 tests/ui/closures/issue-111932.rs create mode 100644 tests/ui/closures/issue-111932.stderr create mode 100644 tests/ui/closures/issue-113087.rs create mode 100644 tests/ui/closures/issue-113087.stderr create mode 100644 tests/ui/codegen/subtyping-enforces-type-equality.rs create mode 100644 tests/ui/codegen/subtyping-enforces-type-equality.stderr create mode 100644 tests/ui/codegen/subtyping-impacts-selection-1.rs create mode 100644 tests/ui/codegen/subtyping-impacts-selection-2.rs create mode 100644 tests/ui/coercion/issue-3794.rs delete mode 100644 tests/ui/coherence/coherence-inherited-subtyping.old.stderr delete mode 100644 tests/ui/coherence/coherence-inherited-subtyping.re.stderr create mode 100644 tests/ui/coherence/coherence-inherited-subtyping.stderr create mode 100644 tests/ui/const-generics/const-param-with-additional-obligations.rs create mode 100644 tests/ui/const-generics/const-param-with-additional-obligations.stderr create mode 100644 tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr create mode 100644 tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr delete mode 100644 tests/ui/const-generics/defaults/default-param-wf-concrete.stderr create mode 100644 tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/issue-109141.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/issue-109141.stderr create mode 100644 tests/ui/const-generics/generic_const_exprs/issue-96699.rs create mode 100644 tests/ui/const-generics/issue-112505-overflow.rs create mode 100644 tests/ui/const-generics/issue-112505-overflow.stderr create mode 100644 tests/ui/const-generics/std/const-generics-range.full.stderr create mode 100644 tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr delete mode 100644 tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr create mode 100644 tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr create mode 100644 tests/ui/consts/const-len-underflow-separate-spans.next.stderr create mode 100644 tests/ui/consts/const-len-underflow-separate-spans.old.stderr delete mode 100644 tests/ui/consts/const-len-underflow-separate-spans.stderr delete mode 100644 tests/ui/consts/const_limit/const_eval_limit_not_reached.rs delete mode 100644 tests/ui/consts/const_limit/const_eval_limit_overflow.rs delete mode 100644 tests/ui/consts/const_limit/const_eval_limit_overflow.stderr delete mode 100644 tests/ui/consts/const_limit/const_eval_limit_reached.rs delete mode 100644 tests/ui/consts/const_limit/const_eval_limit_reached.stderr delete mode 100644 tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs delete mode 100644 tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr create mode 100644 tests/ui/consts/issue-16538.mir.stderr create mode 100644 tests/ui/consts/issue-16538.rs create mode 100644 tests/ui/consts/issue-16538.thir.stderr create mode 100644 tests/ui/consts/issue-28822.rs create mode 100644 tests/ui/consts/issue-29798.rs create mode 100644 tests/ui/consts/missing-larger-array-impl.rs create mode 100644 tests/ui/consts/missing-larger-array-impl.stderr create mode 100644 tests/ui/consts/timeout.rs create mode 100644 tests/ui/consts/timeout.stderr delete mode 100644 tests/ui/discrim/discrim-ill-typed.rs delete mode 100644 tests/ui/discrim/discrim-ill-typed.stderr delete mode 100644 tests/ui/discrim/discrim-overflow-2.rs delete mode 100644 tests/ui/discrim/discrim-overflow-2.stderr delete mode 100644 tests/ui/discrim/discrim-overflow.rs delete mode 100644 tests/ui/discrim/discrim-overflow.stderr delete mode 100644 tests/ui/dyn-star/param-env-infer.current.stderr delete mode 100644 tests/ui/dyn-star/param-env-infer.next.stderr delete mode 100644 tests/ui/dyn-star/param-env-infer.rs create mode 100644 tests/ui/dyn-star/param-env-region-infer.current.stderr create mode 100644 tests/ui/dyn-star/param-env-region-infer.next.stderr create mode 100644 tests/ui/dyn-star/param-env-region-infer.rs create mode 100644 tests/ui/enum-discriminant/discriminant-ill-typed.rs create mode 100644 tests/ui/enum-discriminant/discriminant-ill-typed.stderr create mode 100644 tests/ui/enum-discriminant/discriminant-overflow-2.rs create mode 100644 tests/ui/enum-discriminant/discriminant-overflow-2.stderr create mode 100644 tests/ui/enum-discriminant/discriminant-overflow.rs create mode 100644 tests/ui/enum-discriminant/discriminant-overflow.stderr create mode 100644 tests/ui/enum-discriminant/issue-50689.rs create mode 100644 tests/ui/explicit-tail-calls/become-outside.array.stderr create mode 100644 tests/ui/explicit-tail-calls/become-outside.constant.stderr create mode 100644 tests/ui/explicit-tail-calls/become-outside.rs create mode 100644 tests/ui/explicit-tail-calls/return-lifetime-sub.rs create mode 100644 tests/ui/explicit-tail-calls/return-mismatches.rs create mode 100644 tests/ui/explicit-tail-calls/return-mismatches.stderr create mode 100644 tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.rs create mode 100644 tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.stderr create mode 100644 tests/ui/extern/issue-1251.rs create mode 100644 tests/ui/feature-gates/feature-gate-explicit_tail_calls.rs create mode 100644 tests/ui/feature-gates/feature-gate-explicit_tail_calls.stderr create mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.cfg_current.stderr create mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.cfg_next.stderr create mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.no_current.stderr create mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.no_next.stderr create mode 100644 tests/ui/feature-gates/feature-gate-type_privacy_lints.rs create mode 100644 tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr create mode 100644 tests/ui/for-loop-while/issue-1257.rs create mode 100644 tests/ui/for/issue-20605.current.stderr create mode 100644 tests/ui/for/issue-20605.next.stderr create mode 100644 tests/ui/for/issue-20605.rs create mode 100644 tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.rs create mode 100644 tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.stderr create mode 100644 tests/ui/generic-associated-types/issue-90014-tait.rs create mode 100644 tests/ui/generic-associated-types/issue-90014-tait.stderr create mode 100644 tests/ui/generic-associated-types/issue-90014-tait2.rs create mode 100644 tests/ui/generic-associated-types/issue-90014-tait2.stderr delete mode 100644 tests/ui/higher-lifetime-bounds.rs delete mode 100644 tests/ui/higher-lifetime-bounds.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/complex.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/due-to-where-clause.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/due-to-where-clause.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/fn-ptr.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-covariant.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-opt-in-copy.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-parse.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.polonius.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-type-outlives.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-100689.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-102899.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-30786.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-30786.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-36139-normalize-closure-sig.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-39292.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-42114.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-43623.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-46989.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-46989.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-57639.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-58451.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-58451.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-59311.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-59311.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-60283.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-88446.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-90177.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-95034.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/issue-95230.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-44005.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-56556.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.migrate.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-74261.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-76956.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80956.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-81809.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89436.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90875.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs delete mode 100644 tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr create mode 100644 tests/ui/higher-ranked/higher-lifetime-bounds.rs create mode 100644 tests/ui/higher-ranked/higher-lifetime-bounds.stderr create mode 100644 tests/ui/higher-ranked/leak-check-in-selection.rs create mode 100644 tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr create mode 100644 tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr create mode 100644 tests/ui/higher-ranked/subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr create mode 100644 tests/ui/higher-ranked/subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr create mode 100644 tests/ui/higher-ranked/subtype/hr-subtype.free_x_vs_free_y.stderr create mode 100644 tests/ui/higher-ranked/subtype/hr-subtype.rs create mode 100644 tests/ui/higher-ranked/subtype/placeholder-pattern-fail.rs create mode 100644 tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr create mode 100644 tests/ui/higher-ranked/subtype/placeholder-pattern.rs create mode 100644 tests/ui/higher-ranked/subtype/return-static.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/complex.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/due-to-where-clause.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/fn-ptr.classic.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/fn-ptr.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/future.classic.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/future.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-binder-levels-in-object-types.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-object-types-in-closures.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-covariant.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait-object.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-opt-in-copy.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-parse.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.polonius.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus-where-clause.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-resolve-lifetime.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-paren-notation.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-passed-to-closure.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-type-outlives.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-unboxed-closure-trait.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-100689.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-102899.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-30786.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-30786.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-36139-normalize-closure-sig.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-39292.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-42114.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-43623.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-46989.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-46989.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-57639.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-58451.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-58451.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-59311.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-59311.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-60283.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-88446.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-90177.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-95034.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-95230.next.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/issue-95230.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-44005.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-56556.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-2.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-4.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-5.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-70120.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.migrate.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-74261.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-76956.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80706.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80956.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-81809.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90612.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90875.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.stderr create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.rs create mode 100644 tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr delete mode 100644 tests/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr delete mode 100644 tests/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr delete mode 100644 tests/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr delete mode 100644 tests/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr delete mode 100644 tests/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr delete mode 100644 tests/ui/hr-subtype/hr-subtype.rs delete mode 100644 tests/ui/hr-subtype/placeholder-pattern-fail.rs delete mode 100644 tests/ui/hr-subtype/placeholder-pattern-fail.stderr delete mode 100644 tests/ui/hr-subtype/placeholder-pattern.rs delete mode 100644 tests/ui/hr-subtype/return-static.rs create mode 100644 tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr create mode 100644 tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr create mode 100644 tests/ui/impl-trait/coherence-treats-tait-ambig.rs create mode 100644 tests/ui/impl-trait/defined-by-trait-resolution.rs create mode 100644 tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs create mode 100644 tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr create mode 100644 tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr create mode 100644 tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr create mode 100644 tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr delete mode 100644 tests/ui/impl-trait/in-trait/method-signature-matches.stderr create mode 100644 tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr create mode 100644 tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr create mode 100644 tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr create 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.rs create mode 100644 tests/ui/impl-trait/in-trait/suggest-missing-item.fixed create mode 100644 tests/ui/impl-trait/in-trait/suggest-missing-item.rs create mode 100644 tests/ui/impl-trait/in-trait/suggest-missing-item.stderr create mode 100644 tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr create mode 100644 tests/ui/impl-trait/in-trait/unconstrained-lt.next.stderr create mode 100644 tests/ui/impl-trait/in-trait/unconstrained-lt.rs create mode 100644 tests/ui/impl-trait/in-trait/variances-of-gat.rs create mode 100644 tests/ui/impl-trait/issues/issue-78722-2.rs create mode 100644 tests/ui/impl-trait/issues/issue-78722-2.stderr create mode 100644 tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs delete mode 100644 tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr create mode 100644 tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr create mode 100644 tests/ui/impl-trait/reveal-during-codegen.rs create mode 100644 tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs create mode 100644 tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs create mode 100644 tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs create mode 100644 tests/ui/implied-bounds/references-err.rs create mode 100644 tests/ui/implied-bounds/references-err.stderr create mode 100644 tests/ui/imports/auxiliary/issue-85992-extern-1.rs create mode 100644 tests/ui/imports/auxiliary/issue-85992-extern-2.rs create mode 100644 tests/ui/imports/issue-85992.rs create mode 100644 tests/ui/imports/issue-85992.stderr create mode 100644 tests/ui/inline-const/elided-lifetime-being-infer-vars.rs delete mode 100644 tests/ui/issue-94866.rs delete mode 100644 tests/ui/issue-94866.stderr delete mode 100644 tests/ui/issues/issue-1251.rs delete mode 100644 tests/ui/issues/issue-1257.rs delete mode 100644 tests/ui/issues/issue-16538.mir.stderr delete mode 100644 tests/ui/issues/issue-16538.rs delete mode 100644 tests/ui/issues/issue-16538.thir.stderr delete mode 100644 tests/ui/issues/issue-1871.rs delete mode 100644 tests/ui/issues/issue-1871.stderr delete mode 100644 tests/ui/issues/issue-20605.rs delete mode 100644 tests/ui/issues/issue-20605.stderr delete mode 100644 tests/ui/issues/issue-2063-resource.rs delete mode 100644 tests/ui/issues/issue-2063.rs delete mode 100644 tests/ui/issues/issue-28822.rs delete mode 100644 tests/ui/issues/issue-29798.rs delete mode 100644 tests/ui/issues/issue-3008-1.rs delete mode 100644 tests/ui/issues/issue-3008-1.stderr delete mode 100644 tests/ui/issues/issue-3008-2.rs delete mode 100644 tests/ui/issues/issue-3008-2.stderr delete mode 100644 tests/ui/issues/issue-3008-3.rs delete mode 100644 tests/ui/issues/issue-3008-3.stderr delete mode 100644 tests/ui/issues/issue-3794.rs delete mode 100644 tests/ui/issues/issue-50689.rs delete mode 100644 tests/ui/issues/issue-50825-1.rs delete mode 100644 tests/ui/issues/issue-50825.rs delete mode 100644 tests/ui/issues/issue-78115.rs create mode 100644 tests/ui/layout/cannot-transmute-unnormalizable-type.rs create mode 100644 tests/ui/layout/cannot-transmute-unnormalizable-type.stderr create mode 100644 tests/ui/linkage-attr/incompatible-flavor.rs create mode 100644 tests/ui/linkage-attr/incompatible-flavor.stderr create mode 100644 tests/ui/linkage-attr/unstable-flavor.bpf.stderr create mode 100644 tests/ui/linkage-attr/unstable-flavor.ptx.stderr create mode 100644 tests/ui/linkage-attr/unstable-flavor.rs create mode 100644 tests/ui/lint/invalid-nan-comparison-suggestion.fixed create mode 100644 tests/ui/lint/invalid-nan-comparison-suggestion.rs create mode 100644 tests/ui/lint/invalid-nan-comparison-suggestion.stderr create mode 100644 tests/ui/lint/invalid-nan-comparison.rs create mode 100644 tests/ui/lint/invalid-nan-comparison.stderr create mode 100644 tests/ui/lint/invalid_from_utf8.rs create mode 100644 tests/ui/lint/invalid_from_utf8.stderr create mode 100644 tests/ui/lint/issue-99387.stderr create mode 100644 tests/ui/lint/lint-ctypes-113436-1.rs create mode 100644 tests/ui/lint/lint-ctypes-113436-1.stderr create mode 100644 tests/ui/lint/lint-ctypes-113436.rs create mode 100644 tests/ui/lint/lint-ctypes-113900.rs create mode 100644 tests/ui/lint/lint-ctypes-94223.rs create mode 100644 tests/ui/lint/lint-ctypes-94223.stderr create mode 100644 tests/ui/lint/reference_casting.rs create mode 100644 tests/ui/lint/reference_casting.stderr create mode 100644 tests/ui/lint/undropped_manually_drops.rs create mode 100644 tests/ui/lint/undropped_manually_drops.stderr create mode 100644 tests/ui/lint/unused/must-use-block-expr.fixed create mode 100644 tests/ui/lint/unused/must-use-block-expr.rs create mode 100644 tests/ui/lint/unused/must-use-block-expr.stderr create mode 100644 tests/ui/loops/dont-suggest-break-thru-item.rs create mode 100644 tests/ui/loops/dont-suggest-break-thru-item.stderr create mode 100644 tests/ui/macros/issue-112342-1.rs create mode 100644 tests/ui/macros/issue-112342-1.stderr create mode 100644 tests/ui/macros/issue-112342-2.rs create mode 100644 tests/ui/macros/issue-112342-2.stderr create mode 100644 tests/ui/match/issue-112438.rs create mode 100644 tests/ui/match/issue-113012.rs create mode 100644 tests/ui/mir/issue-112269.rs create mode 100644 tests/ui/mir/issue-112269.stderr create mode 100644 tests/ui/mismatched_types/issue-112036.rs create mode 100644 tests/ui/mismatched_types/issue-112036.stderr create mode 100644 tests/ui/mismatched_types/suggest-option-asderef-inference-var.rs create mode 100644 tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr create mode 100644 tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs create mode 100644 tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr create mode 100644 tests/ui/mismatched_types/suggest-option-asderef.fixed create mode 100644 tests/ui/mismatched_types/suggest-option-asderef.rs create mode 100644 tests/ui/mismatched_types/suggest-option-asderef.stderr create mode 100644 tests/ui/nll/issue-112604-closure-output-normalize.rs delete mode 100644 tests/ui/object-safety/assoc_type_bounds_sized.stderr create mode 100644 tests/ui/object-safety/assoc_type_bounds_sized_others.rs create mode 100644 tests/ui/object-safety/assoc_type_bounds_sized_others.stderr create mode 100644 tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs create mode 100644 tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr create mode 100644 tests/ui/object-safety/assoc_type_bounds_sized_used.rs create mode 100644 tests/ui/object-safety/assoc_type_bounds_sized_used.stderr create mode 100644 tests/ui/offset-of/offset-of-must-use.rs create mode 100644 tests/ui/offset-of/offset-of-must-use.stderr create mode 100644 tests/ui/offset-of/offset-of-tuple-nested.rs create mode 100644 tests/ui/offset-of/offset-of-tuple.rs create mode 100644 tests/ui/offset-of/offset-of-tuple.stderr create mode 100644 tests/ui/offset-of/offset-of-unsized.rs create mode 100644 tests/ui/parser/issue-112188.fixed create mode 100644 tests/ui/parser/issue-112188.rs create mode 100644 tests/ui/parser/issue-112188.stderr create mode 100644 tests/ui/parser/issue-113342.rs create mode 100644 tests/ui/parser/issue-113342.stderr create mode 100644 tests/ui/parser/issues/issue-111692.rs create mode 100644 tests/ui/parser/issues/issue-111692.stderr create mode 100644 tests/ui/parser/issues/issue-112458.rs create mode 100644 tests/ui/parser/issues/issue-112458.stderr create mode 100644 tests/ui/parser/lit-err-in-macro.rs create mode 100644 tests/ui/parser/lit-err-in-macro.stderr create mode 100644 tests/ui/parser/typod-const-in-const-param-def.rs create mode 100644 tests/ui/parser/typod-const-in-const-param-def.stderr create mode 100644 tests/ui/pattern/byte-string-inference.rs create mode 100644 tests/ui/pattern/issue-110508.rs create mode 100644 tests/ui/pattern/issue-94866.rs create mode 100644 tests/ui/pattern/issue-94866.stderr create mode 100644 tests/ui/privacy/effective_visibilities_full_priv.rs create mode 100644 tests/ui/privacy/effective_visibilities_full_priv.stderr create mode 100644 tests/ui/privacy/sealed-traits/private-trait-non-local.rs create mode 100644 tests/ui/privacy/sealed-traits/private-trait-non-local.stderr create mode 100644 tests/ui/privacy/sealed-traits/private-trait.rs create mode 100644 tests/ui/privacy/sealed-traits/private-trait.stderr create mode 100644 tests/ui/privacy/sealed-traits/re-exported-trait.fixed create mode 100644 tests/ui/privacy/sealed-traits/re-exported-trait.rs create mode 100644 tests/ui/privacy/sealed-traits/re-exported-trait.stderr create mode 100644 tests/ui/privacy/sealed-traits/sealed-trait-local.rs create mode 100644 tests/ui/privacy/sealed-traits/sealed-trait-local.stderr create mode 100644 tests/ui/privacy/unnameable_types.rs create mode 100644 tests/ui/privacy/unnameable_types.stderr create mode 100644 tests/ui/proc-macro/auxiliary/exports_no_mangle.rs create mode 100644 tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs create mode 100644 tests/ui/resolve/auxiliary/issue-112831-aux.rs create mode 100644 tests/ui/resolve/export-fully-qualified-2018.rs create mode 100644 tests/ui/resolve/export-fully-qualified-2018.stderr create mode 100644 tests/ui/resolve/hidden_glob_reexports.rs create mode 100644 tests/ui/resolve/hidden_glob_reexports.stderr create mode 100644 tests/ui/resolve/issue-109153.rs create mode 100644 tests/ui/resolve/issue-109153.stderr create mode 100644 tests/ui/resolve/issue-112472-multi-generics-suggestion.fixed create mode 100644 tests/ui/resolve/issue-112472-multi-generics-suggestion.rs create mode 100644 tests/ui/resolve/issue-112472-multi-generics-suggestion.stderr create mode 100644 tests/ui/resolve/issue-112831.rs delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs delete mode 100644 tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr delete mode 100644 tests/ui/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs delete mode 100644 tests/ui/rfc-1717-dllimport/missing-link-attr.rs delete mode 100644 tests/ui/rfc-1717-dllimport/missing-link-attr.stderr delete mode 100644 tests/ui/rfc-1717-dllimport/multiple-renames.rs delete mode 100644 tests/ui/rfc-1717-dllimport/multiple-renames.stderr delete mode 100644 tests/ui/rfc-1717-dllimport/rename-modifiers.rs delete mode 100644 tests/ui/rfc-1717-dllimport/rename-modifiers.stderr delete mode 100644 tests/ui/rfc-1717-dllimport/rename-to-empty.rs delete mode 100644 tests/ui/rfc-1717-dllimport/rename-to-empty.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/issue-103052-1.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/issue-103052-1.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/issue-103052-2.current.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/issue-103052-2.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-for-never.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-for-str.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-in-test.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs delete mode 100644 tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/const.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/const.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/enum.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/enum.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/for.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/for.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/lit.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/lit.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/no-double-error.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr delete mode 100644 tests/ui/rfc-2005-default-binding-mode/slice.rs delete mode 100644 tests/ui/rfc-2005-default-binding-mode/slice.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/auxiliary/monovariants.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/auxiliary/structs.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/auxiliary/unstable.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/auxiliary/variants.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum-as-cast.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/invalid-attribute.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/invalid-attribute.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/struct.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/struct.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/structs_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/variant.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/variant.stderr delete mode 100644 tests/ui/rfc-2008-non-exhaustive/variants_fictive_visibility.rs delete mode 100644 tests/ui/rfc-2008-non-exhaustive/variants_same_crate.rs delete mode 100644 tests/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs delete mode 100644 tests/ui/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs delete mode 100644 tests/ui/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs delete mode 100644 tests/ui/rfc-2091-track-caller/call-chain.rs delete mode 100644 tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs delete mode 100644 tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/caller-location-intrinsic.rs delete mode 100644 tests/ui/rfc-2091-track-caller/const-caller-location.rs delete mode 100644 tests/ui/rfc-2091-track-caller/diverging-caller-location.rs delete mode 100644 tests/ui/rfc-2091-track-caller/error-odd-syntax.rs delete mode 100644 tests/ui/rfc-2091-track-caller/error-odd-syntax.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-invalid-abi.rs delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-main.rs delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-main.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-naked.rs delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-naked.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-start.rs delete mode 100644 tests/ui/rfc-2091-track-caller/error-with-start.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs delete mode 100644 tests/ui/rfc-2091-track-caller/macro-declaration.rs delete mode 100644 tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs delete mode 100644 tests/ui/rfc-2091-track-caller/only-for-fns.rs delete mode 100644 tests/ui/rfc-2091-track-caller/only-for-fns.stderr delete mode 100644 tests/ui/rfc-2091-track-caller/pass.rs delete mode 100644 tests/ui/rfc-2091-track-caller/std-panic-locations.rs delete mode 100644 tests/ui/rfc-2091-track-caller/track-caller-attribute.rs delete mode 100644 tests/ui/rfc-2091-track-caller/track-caller-ffi.rs delete mode 100644 tests/ui/rfc-2091-track-caller/tracked-closure.rs delete mode 100644 tests/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs delete mode 100644 tests/ui/rfc-2091-track-caller/tracked-fn-ptr.rs delete mode 100644 tests/ui/rfc-2091-track-caller/tracked-trait-impls.rs delete mode 100644 tests/ui/rfc-2091-track-caller/tracked-trait-obj.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/cross-crate.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/cross-crate.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/enum.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/enum.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-enum.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-projection.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-struct.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-union.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/explicit-union.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/issue-54467.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-enum.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-enum.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-regions.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-regions.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-structs.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-structs.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-union.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/nested-union.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/privacy.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/projection.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/projection.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/reference.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/reference.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/self-dyn.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/self-dyn.stderr delete mode 100644 tests/ui/rfc-2093-infer-outlives/self-structs.rs delete mode 100644 tests/ui/rfc-2093-infer-outlives/self-structs.stderr delete mode 100644 tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.rs delete mode 100644 tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr delete mode 100644 tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs delete mode 100644 tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.rs delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.rs delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.stderr delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/not-allowed.rs delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/not-allowed.stderr delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/single-segment.rs delete mode 100644 tests/ui/rfc-2126-extern-absolute-paths/single-segment.stderr delete mode 100644 tests/ui/rfc-2294-if-let-guard/bindings.rs delete mode 100644 tests/ui/rfc-2294-if-let-guard/bindings.stderr delete mode 100644 tests/ui/rfc-2294-if-let-guard/feature-gate.rs delete mode 100644 tests/ui/rfc-2294-if-let-guard/feature-gate.stderr delete mode 100644 tests/ui/rfc-2294-if-let-guard/run-pass.rs delete mode 100644 tests/ui/rfc-2294-if-let-guard/typeck.rs delete mode 100644 tests/ui/rfc-2294-if-let-guard/typeck.stderr delete mode 100644 tests/ui/rfc-2294-if-let-guard/warns.rs delete mode 100644 tests/ui/rfc-2294-if-let-guard/warns.stderr delete mode 100644 tests/ui/rfc-2306/convert-id-const-with-gate.rs delete mode 100644 tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs delete mode 100644 tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr delete mode 100644 tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs delete mode 100644 tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr delete mode 100644 tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs delete mode 100644 tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr delete mode 100644 tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs delete mode 100644 tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr delete mode 100644 tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs delete mode 100644 tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr delete mode 100644 tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs delete mode 100644 tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr delete mode 100644 tests/ui/rfc-2457/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs delete mode 100644 tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.rs delete mode 100644 tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.stderr delete mode 100644 tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.rs delete mode 100644 tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.stderr delete mode 100644 tests/ui/rfc-2457/extern_block_nonascii_forbidden.rs delete mode 100644 tests/ui/rfc-2457/extern_block_nonascii_forbidden.stderr delete mode 100644 tests/ui/rfc-2457/idents-normalized.rs delete mode 100644 tests/ui/rfc-2457/mod_file_nonascii_forbidden.rs delete mode 100644 tests/ui/rfc-2457/mod_file_nonascii_forbidden.stderr delete mode 100644 tests/ui/rfc-2457/mod_file_nonascii_with_path_allowed.rs delete mode 100644 tests/ui/rfc-2457/mod_inline_nonascii_allowed.rs delete mode 100644 tests/ui/rfc-2457/no_mangle_nonascii_forbidden.rs delete mode 100644 tests/ui/rfc-2457/no_mangle_nonascii_forbidden.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/ast-pretty-check.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout delete mode 100644 tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/chains-without-let.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/chains-without-let.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/disallowed-positions.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/disallowed-positions.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/feature-gate.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/feature-gate.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/irrefutable-lets.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/issue-88498.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/issue-90722.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/issue-92145.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/issue-93150.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/issue-93150.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/issue-99938.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/no-double-assigments.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/protect-precedences.rs delete mode 100644 tests/ui/rfc-2497-if-let-chains/protect-precedences.stderr delete mode 100644 tests/ui/rfc-2497-if-let-chains/then-else-blocks.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/attr-without-param.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/attr-without-param.stderr delete mode 100644 tests/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-2018.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-2018.stderr delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-allowed.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-cfg.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr delete mode 100644 tests/ui/rfc-2565-param-attrs/param-attrs-pretty.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs delete mode 100644 tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr delete mode 100644 tests/ui/rfc-2627-raw-dylib/unsupported-abi.rs delete mode 100644 tests/ui/rfc-2627-raw-dylib/unsupported-abi.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/assoc-type.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/attr-misuse.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/attr-misuse.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/call.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-closures.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-drop.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/cross-crate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/do-not-const-check-override.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/do-not-const-check.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/feature-gate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/gate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/gate.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/generic-bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/hir-const-check.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/hir-const-check.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/inherent-impl.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/inherent-impl.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-100222.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-102156.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-102156.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-102985.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-102985.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-103677.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-79450.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-88155.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-88155.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-90052.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-90052.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-92111.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/nested-closure.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/staged-api.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/staged-api.stable.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/staged-api.unstable.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/super-traits.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/syntax.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-twice.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde-twice.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-where-clause.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr delete mode 100644 tests/ui/rfc-2632-const-trait-impl/without-tilde.rs delete mode 100644 tests/ui/rfc-2632-const-trait-impl/without-tilde.stderr create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs create mode 100644 tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr delete mode 100644 tests/ui/rfcs/rfc-1014-2.rs create mode 100644 tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs create mode 100644 tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs delete mode 100644 tests/ui/rfcs/rfc-1014.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match-on-ty-in-macro.rs create mode 100644 tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match.rs create mode 100644 tests/ui/rfcs/rfc-1623-static/rfc1623-2.rs create mode 100644 tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr create mode 100644 tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs create mode 100644 tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr create mode 100644 tests/ui/rfcs/rfc-1623-static/rfc1623.rs create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/1717-dllimport/library-override.rs create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.rs create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.stderr create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.rs create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.stderr create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.rs create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.stderr create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.rs create mode 100644 tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.stderr create mode 100644 tests/ui/rfcs/rfc-1857-stabilize-drop-order/drop-order.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.current.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.next.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-err.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-ok.rs delete mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-never.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-err.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-ok.rs delete mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs create mode 100644 tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs create mode 100644 tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/monovariants.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/unstable.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/variant.stderr create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/variants_fictive_visibility.rs create mode 100644 tests/ui/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs create mode 100644 tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs create mode 100644 tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs create mode 100644 tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/call-chain.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/caller-location-intrinsic.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/diverging-caller-location.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-main.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-main.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-start.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/error-with-start.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/intrinsic-wrapper.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/macro-declaration.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/mir-inlined-macro.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/pass.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/track-caller-attribute.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/track-caller-ffi.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-impls.rs create mode 100644 tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-obj.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/enum.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/enum.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/issue-54467.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/projection.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/projection.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/reference.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/reference.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.stderr create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.rs create mode 100644 tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.stderr create mode 100644 tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs create mode 100644 tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr create mode 100644 tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs create mode 100644 tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs create mode 100644 tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs create mode 100644 tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr delete mode 100644 tests/ui/rfcs/rfc-2302-self-struct-ctor.rs create mode 100644 tests/ui/rfcs/rfc-2302-self-struct-ctor/rfc-2302-self-struct-ctor.rs create mode 100644 tests/ui/rfcs/rfc-2306-convert-id/convert-id-const-with-gate.rs create mode 100644 tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs create mode 100644 tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr create mode 100644 tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs create mode 100644 tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr create mode 100644 tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs create mode 100644 tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr create mode 100644 tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs create mode 100644 tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr create mode 100644 tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs create mode 100644 tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr create mode 100644 tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs create mode 100644 tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr delete mode 100644 tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs create mode 100644 tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof/offsetof-alignof-sizeof-pure-can-be-used-as-idents.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.stderr create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.stderr create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.stderr create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/idents-normalized.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.stderr create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_with_path_allowed.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_inline_nonascii_allowed.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.rs create mode 100644 tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/issue-88498.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/issue-90722.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/issue-92145.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/issue-99938.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/no-double-assigments.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.rs create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.stderr create mode 100644 tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.stderr create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/ident-mac.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.stderr create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.stderr create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs create mode 100644 tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs create mode 100644 tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs create 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/call-generic-method-pass.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stock.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs create 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/default-method-body-is-const-same-trait-ck.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/effects/helloworld.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/gate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/gate.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-103677.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/nested-closure.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs create 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/const-default-const-specialized.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/default-keyword.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.stable.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.unstable.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/static-const-trait-bound.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs create 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/super-traits.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/syntax.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-syntax.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs create mode 100644 tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr delete mode 100644 tests/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs delete mode 100644 tests/ui/rfcs/rfc1445/eq-allows-match.rs delete mode 100644 tests/ui/rfcs/rfc1623-2.rs delete mode 100644 tests/ui/rfcs/rfc1623-2.stderr delete mode 100644 tests/ui/rfcs/rfc1623-3.rs delete mode 100644 tests/ui/rfcs/rfc1623-3.stderr delete mode 100644 tests/ui/rfcs/rfc1623.rs delete mode 100644 tests/ui/rfcs/rfc1717/library-override.rs delete mode 100644 tests/ui/rfcs/rfc1857-drop-order.rs delete mode 100644 tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr delete mode 100644 tests/ui/rust-2018/uniform-paths/ambiguity.stderr delete mode 100644 tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr delete mode 100644 tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr create mode 100644 tests/ui/sanitize/issue-111184-generator-witness.rs create mode 100644 tests/ui/specialization/specialization-default-items-drop-coherence.coherence.stderr create mode 100644 tests/ui/specialization/specialization-default-items-drop-coherence.next.stderr create mode 100644 tests/ui/std/slice-from-array-issue-113238.rs create mode 100644 tests/ui/structs-enums/issue-3008-1.rs create mode 100644 tests/ui/structs-enums/issue-3008-1.stderr create mode 100644 tests/ui/structs-enums/issue-3008-2.rs create mode 100644 tests/ui/structs-enums/issue-3008-2.stderr create mode 100644 tests/ui/structs-enums/issue-3008-3.rs create mode 100644 tests/ui/structs-enums/issue-3008-3.stderr create mode 100644 tests/ui/suggestions/issue-102972.rs create mode 100644 tests/ui/suggestions/issue-102972.stderr create mode 100644 tests/ui/suggestions/issue-103646.rs create mode 100644 tests/ui/suggestions/issue-103646.stderr create mode 100644 tests/ui/suggestions/issue-109991.rs create mode 100644 tests/ui/suggestions/issue-109991.stderr create mode 100644 tests/ui/suggestions/issue-112590-suggest-import.rs create mode 100644 tests/ui/suggestions/issue-112590-suggest-import.stderr create mode 100644 tests/ui/suggestions/issue-88696.rs create mode 100644 tests/ui/suggestions/issue-88696.stderr create mode 100644 tests/ui/suggestions/issue-89640.rs create mode 100644 tests/ui/suggestions/issue-89640.stderr create mode 100644 tests/ui/test-attrs/test-function-signature.rs create mode 100644 tests/ui/test-attrs/test-function-signature.stderr create mode 100644 tests/ui/thir-print/thir-flat-const-variant.rs create mode 100644 tests/ui/thir-print/thir-flat-const-variant.stdout create mode 100644 tests/ui/trait-bounds/apit-unsized.rs create mode 100644 tests/ui/trait-bounds/apit-unsized.stderr create mode 100644 tests/ui/traits/auxiliary/trivial3.rs create mode 100644 tests/ui/traits/auxiliary/trivial4.rs create mode 100644 tests/ui/traits/deny-builtin-object-impl.current.stderr create mode 100644 tests/ui/traits/deny-builtin-object-impl.next.stderr create mode 100644 tests/ui/traits/deny-builtin-object-impl.rs create mode 100644 tests/ui/traits/ice-with-dyn-pointee-errors.rs create mode 100644 tests/ui/traits/ice-with-dyn-pointee-errors.stderr create mode 100644 tests/ui/traits/ice-with-dyn-pointee.rs create mode 100644 tests/ui/traits/issue-105231.rs create mode 100644 tests/ui/traits/issue-105231.stderr create mode 100644 tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr create mode 100644 tests/ui/traits/new-solver/array-default.rs create mode 100644 tests/ui/traits/new-solver/closure-substs-ambiguity.rs create mode 100644 tests/ui/traits/new-solver/dedup-regions.rs create mode 100644 tests/ui/traits/new-solver/dont-remap-tait-substs.rs create mode 100644 tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr create mode 100644 tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs create mode 100644 tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs create mode 100644 tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr create mode 100644 tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs create mode 100644 tests/ui/traits/new-solver/member-constraints-in-root-universe.rs create mode 100644 tests/ui/traits/new-solver/normalized-const-built-in-op.rs create mode 100644 tests/ui/traits/new-solver/opportunistic-region-resolve.rs create mode 100644 tests/ui/traits/new-solver/slice-match-byte-lit.rs create mode 100644 tests/ui/traits/new-solver/tait-eq-proj-2.rs create mode 100644 tests/ui/traits/new-solver/tait-eq-proj.rs create mode 100644 tests/ui/traits/new-solver/tait-eq-tait.rs create mode 100644 tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr create mode 100644 tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs create mode 100644 tests/ui/traits/new-solver/winnow-specializing-impls.rs create mode 100644 tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs create mode 100644 tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr create mode 100644 tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs create mode 100644 tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr create mode 100644 tests/ui/traits/object/print_vtable_sizes.rs create mode 100644 tests/ui/traits/object/print_vtable_sizes.stdout create mode 100644 tests/ui/traits/trivial_impl.rs create mode 100644 tests/ui/traits/trivial_impl.stderr create mode 100644 tests/ui/traits/trivial_impl2.rs create mode 100644 tests/ui/traits/trivial_impl2.stderr create mode 100644 tests/ui/traits/trivial_impl3.rs create mode 100644 tests/ui/traits/trivial_impl3.stderr create mode 100644 tests/ui/traits/trivial_impl4.rs create mode 100644 tests/ui/traits/trivial_impl4.stderr create mode 100644 tests/ui/traits/trivial_impl_sized.rs create mode 100644 tests/ui/traits/trivial_impl_sized.stderr create mode 100644 tests/ui/transmutability/alignment/align-fail.rs create mode 100644 tests/ui/transmutability/alignment/align-fail.stderr create mode 100644 tests/ui/transmutability/alignment/align-pass.rs create mode 100644 tests/ui/transmutability/primitives/bool-mut.rs create mode 100644 tests/ui/transmutability/primitives/bool-mut.stderr delete mode 100644 tests/ui/transmutability/references.current.stderr delete mode 100644 tests/ui/transmutability/references.next.stderr delete mode 100644 tests/ui/transmutability/references.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types.rs create mode 100644 tests/ui/transmutability/references/recursive-wrapper-types.stderr create mode 100644 tests/ui/transmutability/references/u8-to-unit.rs create mode 100644 tests/ui/transmutability/references/unit-to-itself.rs create mode 100644 tests/ui/transmutability/references/unit-to-u8.rs create mode 100644 tests/ui/transmutability/references/unit-to-u8.stderr create mode 100644 tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs create mode 100644 tests/ui/treat-err-as-bug/panic-causes-oom-112708.stderr create mode 100644 tests/ui/type-alias-impl-trait/bounds-are-checked3.rs create mode 100644 tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr create mode 100644 tests/ui/type-alias-impl-trait/bounds.rs create mode 100644 tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs create mode 100644 tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr create mode 100644 tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs create mode 100644 tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr create mode 100644 tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs create mode 100644 tests/ui/type-alias-impl-trait/higher_kinded_params.rs create mode 100644 tests/ui/type-alias-impl-trait/higher_kinded_params2.rs create mode 100644 tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr create mode 100644 tests/ui/type-alias-impl-trait/higher_kinded_params3.rs create mode 100644 tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr create mode 100644 tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs create mode 100644 tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr create mode 100644 tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs create mode 100644 tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr create mode 100644 tests/ui/type-alias-impl-trait/issue-109054.rs create mode 100644 tests/ui/type-alias-impl-trait/issue-109054.stderr delete mode 100644 tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr delete mode 100644 tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr create mode 100644 tests/ui/type-alias-impl-trait/issue-70121.stderr create mode 100644 tests/ui/type-alias-impl-trait/multi-error.rs create mode 100644 tests/ui/type-alias-impl-trait/multi-error.stderr create mode 100644 tests/ui/type-alias-impl-trait/nested_in_closure.rs create mode 100644 tests/ui/type-alias-impl-trait/non-defining-method.rs create mode 100644 tests/ui/type-alias-impl-trait/non-defining-method.stderr create mode 100644 tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr create mode 100644 tests/ui/type-alias-impl-trait/normalize-hidden-types.rs create mode 100644 tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs create mode 100644 tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr create mode 100644 tests/ui/type-alias-impl-trait/obligation_ice.rs create mode 100644 tests/ui/type-alias-impl-trait/privacy.rs create mode 100644 tests/ui/type-alias-impl-trait/privacy.stderr create mode 100644 tests/ui/type-alias-impl-trait/self-referential-3.stderr create mode 100644 tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs create mode 100644 tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.rs create mode 100644 tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.stderr create mode 100644 tests/ui/typeck/issue-106929.rs create mode 100644 tests/ui/typeck/issue-106929.stderr create mode 100644 tests/ui/typeck/issue-112252-ptr-arithmetics-help.fixed create mode 100644 tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs create mode 100644 tests/ui/typeck/issue-112252-ptr-arithmetics-help.stderr create mode 100644 tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs create mode 100644 tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr create mode 100644 tests/ui/typeck/issue-1871.rs create mode 100644 tests/ui/typeck/issue-1871.stderr create mode 100644 tests/ui/typeck/issue-2063-resource.rs create mode 100644 tests/ui/typeck/issue-2063.rs create mode 100644 tests/ui/typeck/ptr-null-mutability-suggestions.fixed create mode 100644 tests/ui/typeck/ptr-null-mutability-suggestions.rs create mode 100644 tests/ui/typeck/ptr-null-mutability-suggestions.stderr create mode 100644 tests/ui/typeck/return-dyn-type-mismatch-2.rs create mode 100644 tests/ui/typeck/return-dyn-type-mismatch-2.stderr create mode 100644 tests/ui/typeck/return-dyn-type-mismatch.rs create mode 100644 tests/ui/typeck/return-dyn-type-mismatch.stderr create mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed create mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs create mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr create mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed create mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs create mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr delete mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs delete mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr delete mode 100644 tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr create mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed create mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs create mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr create mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed create mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs create mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr delete mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region.rs delete mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr delete mode 100644 tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr create mode 100644 tests/ui/uninhabited/projection.rs create mode 100644 tests/ui/unsafe/auxiliary/external_unsafe_macro.rs create mode 100644 tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed create mode 100644 tests/ui/unsafe/wrapping-unsafe-block-sugg.rs create mode 100644 tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr create mode 100644 tests/ui/unsized-locals/rust-call.rs create mode 100644 tests/ui/unsized-locals/rust-call.stderr create mode 100644 tests/ui/unsized/issue-71659.current.stderr create mode 100644 tests/ui/unsized/issue-71659.next.stderr delete mode 100644 tests/ui/unsized/issue-71659.stderr create mode 100644 tests/ui/where-clauses/issue-50825-1.rs create mode 100644 tests/ui/where-clauses/issue-50825.rs (limited to 'tests/ui') diff --git a/tests/ui/abi/foreign/foreign-fn-with-byval.rs b/tests/ui/abi/foreign/foreign-fn-with-byval.rs index f366b6ee1..e20ee0da4 100644 --- a/tests/ui/abi/foreign/foreign-fn-with-byval.rs +++ b/tests/ui/abi/foreign/foreign-fn-with-byval.rs @@ -1,5 +1,5 @@ // run-pass -#![allow(improper_ctypes)] +#![allow(improper_ctypes, improper_ctypes_definitions)] // ignore-wasm32-bare no libc to test ffi with diff --git a/tests/ui/abi/issue-94223.rs b/tests/ui/abi/issue-94223.rs new file mode 100644 index 000000000..79d6b9403 --- /dev/null +++ b/tests/ui/abi/issue-94223.rs @@ -0,0 +1,8 @@ +// check-pass +#![allow(improper_ctypes_definitions)] +#![crate_type = "lib"] + +// Check that computing the fn abi for `bad`, with a external ABI fn ptr that is not FFI-safe, does +// not ICE. + +pub fn bad(f: extern "C" fn([u8])) {} diff --git a/tests/ui/argument-suggestions/issue-112507.rs b/tests/ui/argument-suggestions/issue-112507.rs new file mode 100644 index 000000000..61743c59a --- /dev/null +++ b/tests/ui/argument-suggestions/issue-112507.rs @@ -0,0 +1,12 @@ +pub enum Value { + Float(Option), +} + +fn main() { + let _a = Value::Float( //~ ERROR this enum variant takes 1 argument but 4 arguments were supplied + 0, + None, + None, + 0, + ); +} diff --git a/tests/ui/argument-suggestions/issue-112507.stderr b/tests/ui/argument-suggestions/issue-112507.stderr new file mode 100644 index 000000000..dfb47e010 --- /dev/null +++ b/tests/ui/argument-suggestions/issue-112507.stderr @@ -0,0 +1,27 @@ +error[E0061]: this enum variant takes 1 argument but 4 arguments were supplied + --> $DIR/issue-112507.rs:6:14 + | +LL | let _a = Value::Float( + | ^^^^^^^^^^^^ +LL | 0, + | - unexpected argument of type `{integer}` +LL | None, +LL | None, + | ---- unexpected argument of type `Option<_>` +LL | 0, + | - unexpected argument of type `{integer}` + | +note: tuple variant defined here + --> $DIR/issue-112507.rs:2:5 + | +LL | Float(Option), + | ^^^^^ +help: remove the extra arguments + | +LL ~ , +LL ~ None); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/asm/aarch64/may_unwind.rs b/tests/ui/asm/aarch64/may_unwind.rs index 6af8728bb..cfb750782 100644 --- a/tests/ui/asm/aarch64/may_unwind.rs +++ b/tests/ui/asm/aarch64/may_unwind.rs @@ -1,6 +1,7 @@ // only-aarch64 // run-pass // needs-asm-support +// needs-unwind #![feature(asm_unwind)] diff --git a/tests/ui/asm/parse-error.rs b/tests/ui/asm/parse-error.rs new file mode 100644 index 000000000..9e002b155 --- /dev/null +++ b/tests/ui/asm/parse-error.rs @@ -0,0 +1,144 @@ +// needs-asm-support + +#![feature(asm_const)] + +use std::arch::{asm, global_asm}; + +fn main() { + let mut foo = 0; + let mut bar = 0; + unsafe { + asm!(); + //~^ ERROR requires at least a template string argument + asm!(foo); + //~^ ERROR asm template must be a string literal + asm!("{}" foo); + //~^ ERROR expected token: `,` + asm!("{}", foo); + //~^ ERROR expected operand, clobber_abi, options, or additional template string + asm!("{}", in foo); + //~^ ERROR expected `(`, found `foo` + asm!("{}", in(reg foo)); + //~^ ERROR expected `)`, found `foo` + asm!("{}", in(reg)); + //~^ ERROR expected expression, found end of macro arguments + asm!("{}", inout(=) foo => bar); + //~^ ERROR expected register class or explicit register + asm!("{}", inout(reg) foo =>); + //~^ ERROR expected expression, found end of macro arguments + asm!("{}", in(reg) foo => bar); + //~^ ERROR expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>` + asm!("{}", sym foo + bar); + //~^ ERROR expected a path for argument to `sym` + asm!("", options(foo)); + //~^ ERROR expected one of + asm!("", options(nomem foo)); + //~^ ERROR expected one of + asm!("", options(nomem, foo)); + //~^ ERROR expected one of + asm!("{}", options(), const foo); + //~^ ERROR attempt to use a non-constant value in a constant + + // test that asm!'s clobber_abi doesn't accept non-string literals + // see also https://github.com/rust-lang/rust/issues/112635 + asm!("", clobber_abi()); + //~^ ERROR at least one abi must be provided + asm!("", clobber_abi(foo)); + //~^ ERROR expected string literal + asm!("", clobber_abi("C" foo)); + //~^ ERROR expected one of `)` or `,`, found `foo` + asm!("", clobber_abi("C", foo)); + //~^ ERROR expected string literal + asm!("", clobber_abi(1)); + //~^ ERROR expected string literal + asm!("", clobber_abi(())); + //~^ ERROR expected string literal + asm!("", clobber_abi(uwu)); + //~^ ERROR expected string literal + asm!("", clobber_abi({})); + //~^ ERROR expected string literal + asm!("", clobber_abi(loop {})); + //~^ ERROR expected string literal + asm!("", clobber_abi(if)); + //~^ ERROR expected string literal + asm!("", clobber_abi(do)); + //~^ ERROR expected string literal + asm!("", clobber_abi(<)); + //~^ ERROR expected string literal + asm!("", clobber_abi(.)); + //~^ ERROR expected string literal + + asm!("{}", clobber_abi("C"), const foo); + //~^ ERROR attempt to use a non-constant value in a constant + asm!("", options(), clobber_abi("C")); + asm!("{}", options(), clobber_abi("C"), const foo); + //~^ ERROR attempt to use a non-constant value in a constant + asm!("{a}", a = const foo, a = const bar); + //~^ ERROR duplicate argument named `a` + //~^^ ERROR argument never used + //~^^^ ERROR attempt to use a non-constant value in a constant + //~^^^^ ERROR attempt to use a non-constant value in a constant + + asm!("", options(), ""); + //~^ ERROR expected one of + asm!("{}", in(reg) foo, "{}", out(reg) foo); + //~^ ERROR expected one of + asm!(format!("{{{}}}", 0), in(reg) foo); + //~^ ERROR asm template must be a string literal + asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); + //~^ ERROR asm template must be a string literal + asm!("{}", in(reg) _); + //~^ ERROR _ cannot be used for input operands + asm!("{}", inout(reg) _); + //~^ ERROR _ cannot be used for input operands + asm!("{}", inlateout(reg) _); + //~^ ERROR _ cannot be used for input operands + } +} + +const FOO: i32 = 1; +const BAR: i32 = 2; +global_asm!(); +//~^ ERROR requires at least a template string argument +global_asm!(FOO); +//~^ ERROR asm template must be a string literal +global_asm!("{}" FOO); +//~^ ERROR expected token: `,` +global_asm!("{}", FOO); +//~^ ERROR expected operand, options, or additional template string +global_asm!("{}", const); +//~^ ERROR expected expression, found end of macro arguments +global_asm!("{}", const(reg) FOO); +//~^ ERROR expected one of +global_asm!("", options(FOO)); +//~^ ERROR expected one of +global_asm!("", options(nomem FOO)); +//~^ ERROR expected one of +global_asm!("", options(nomem, FOO)); +//~^ ERROR expected one of +global_asm!("{}", options(), const FOO); +global_asm!("", clobber_abi(FOO)); +//~^ ERROR expected string literal +global_asm!("", clobber_abi("C" FOO)); +//~^ ERROR expected one of `)` or `,`, found `FOO` +global_asm!("", clobber_abi("C", FOO)); +//~^ ERROR expected string literal +global_asm!("{}", clobber_abi("C"), const FOO); +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` +global_asm!("", options(), clobber_abi("C")); +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` +global_asm!("{}", options(), clobber_abi("C"), const FOO); +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` +global_asm!("", clobber_abi("C"), clobber_abi("C")); +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` +global_asm!("{a}", a = const FOO, a = const BAR); +//~^ ERROR duplicate argument named `a` +//~^^ ERROR argument never used +global_asm!("", options(), ""); +//~^ ERROR expected one of +global_asm!("{}", const FOO, "{}", const FOO); +//~^ ERROR expected one of +global_asm!(format!("{{{}}}", 0), const FOO); +//~^ ERROR asm template must be a string literal +global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); +//~^ ERROR asm template must be a string literal diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr new file mode 100644 index 000000000..075d28e17 --- /dev/null +++ b/tests/ui/asm/parse-error.stderr @@ -0,0 +1,412 @@ +error: requires at least a template string argument + --> $DIR/parse-error.rs:11:9 + | +LL | asm!(); + | ^^^^^^ + +error: asm template must be a string literal + --> $DIR/parse-error.rs:13:14 + | +LL | asm!(foo); + | ^^^ + +error: expected token: `,` + --> $DIR/parse-error.rs:15:19 + | +LL | asm!("{}" foo); + | ^^^ expected `,` + +error: expected operand, clobber_abi, options, or additional template string + --> $DIR/parse-error.rs:17:20 + | +LL | asm!("{}", foo); + | ^^^ expected operand, clobber_abi, options, or additional template string + +error: expected `(`, found `foo` + --> $DIR/parse-error.rs:19:23 + | +LL | asm!("{}", in foo); + | ^^^ expected `(` + +error: expected `)`, found `foo` + --> $DIR/parse-error.rs:21:27 + | +LL | asm!("{}", in(reg foo)); + | ^^^ expected `)` + +error: expected expression, found end of macro arguments + --> $DIR/parse-error.rs:23:27 + | +LL | asm!("{}", in(reg)); + | ^ expected expression + +error: expected register class or explicit register + --> $DIR/parse-error.rs:25:26 + | +LL | asm!("{}", inout(=) foo => bar); + | ^ + +error: expected expression, found end of macro arguments + --> $DIR/parse-error.rs:27:37 + | +LL | asm!("{}", inout(reg) foo =>); + | ^ expected expression + +error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>` + --> $DIR/parse-error.rs:29:32 + | +LL | asm!("{}", in(reg) foo => bar); + | ^^ expected one of 7 possible tokens + +error: expected a path for argument to `sym` + --> $DIR/parse-error.rs:31:24 + | +LL | asm!("{}", sym foo + bar); + | ^^^^^^^^^ + +error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` + --> $DIR/parse-error.rs:33:26 + | +LL | asm!("", options(foo)); + | ^^^ expected one of 10 possible tokens + +error: expected one of `)` or `,`, found `foo` + --> $DIR/parse-error.rs:35:32 + | +LL | asm!("", options(nomem foo)); + | ^^^ expected one of `)` or `,` + +error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` + --> $DIR/parse-error.rs:37:33 + | +LL | asm!("", options(nomem, foo)); + | ^^^ expected one of 10 possible tokens + +error: at least one abi must be provided as an argument to `clobber_abi` + --> $DIR/parse-error.rs:44:30 + | +LL | asm!("", clobber_abi()); + | ^ + +error: expected string literal + --> $DIR/parse-error.rs:46:30 + | +LL | asm!("", clobber_abi(foo)); + | ^^^ not a string literal + +error: expected one of `)` or `,`, found `foo` + --> $DIR/parse-error.rs:48:34 + | +LL | asm!("", clobber_abi("C" foo)); + | ^^^ expected one of `)` or `,` + +error: expected string literal + --> $DIR/parse-error.rs:50:35 + | +LL | asm!("", clobber_abi("C", foo)); + | ^^^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:52:30 + | +LL | asm!("", clobber_abi(1)); + | ^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:54:30 + | +LL | asm!("", clobber_abi(())); + | ^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:56:30 + | +LL | asm!("", clobber_abi(uwu)); + | ^^^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:58:30 + | +LL | asm!("", clobber_abi({})); + | ^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:60:30 + | +LL | asm!("", clobber_abi(loop {})); + | ^^^^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:62:30 + | +LL | asm!("", clobber_abi(if)); + | ^^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:64:30 + | +LL | asm!("", clobber_abi(do)); + | ^^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:66:30 + | +LL | asm!("", clobber_abi(<)); + | ^ not a string literal + +error: expected string literal + --> $DIR/parse-error.rs:68:30 + | +LL | asm!("", clobber_abi(.)); + | ^ not a string literal + +error: duplicate argument named `a` + --> $DIR/parse-error.rs:76:36 + | +LL | asm!("{a}", a = const foo, a = const bar); + | ------------- ^^^^^^^^^^^^^ duplicate argument + | | + | previously here + +error: argument never used + --> $DIR/parse-error.rs:76:36 + | +LL | asm!("{a}", a = const foo, a = const bar); + | ^^^^^^^^^^^^^ argument never used + | + = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` + +error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""` + --> $DIR/parse-error.rs:82:29 + | +LL | asm!("", options(), ""); + | ^^ expected one of 9 possible tokens + +error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"` + --> $DIR/parse-error.rs:84:33 + | +LL | asm!("{}", in(reg) foo, "{}", out(reg) foo); + | ^^^^ expected one of 9 possible tokens + +error: asm template must be a string literal + --> $DIR/parse-error.rs:86:14 + | +LL | asm!(format!("{{{}}}", 0), in(reg) foo); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: asm template must be a string literal + --> $DIR/parse-error.rs:88:21 + | +LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: _ cannot be used for input operands + --> $DIR/parse-error.rs:90:28 + | +LL | asm!("{}", in(reg) _); + | ^ + +error: _ cannot be used for input operands + --> $DIR/parse-error.rs:92:31 + | +LL | asm!("{}", inout(reg) _); + | ^ + +error: _ cannot be used for input operands + --> $DIR/parse-error.rs:94:35 + | +LL | asm!("{}", inlateout(reg) _); + | ^ + +error: requires at least a template string argument + --> $DIR/parse-error.rs:101:1 + | +LL | global_asm!(); + | ^^^^^^^^^^^^^ + +error: asm template must be a string literal + --> $DIR/parse-error.rs:103:13 + | +LL | global_asm!(FOO); + | ^^^ + +error: expected token: `,` + --> $DIR/parse-error.rs:105:18 + | +LL | global_asm!("{}" FOO); + | ^^^ expected `,` + +error: expected operand, options, or additional template string + --> $DIR/parse-error.rs:107:19 + | +LL | global_asm!("{}", FOO); + | ^^^ expected operand, options, or additional template string + +error: expected expression, found end of macro arguments + --> $DIR/parse-error.rs:109:24 + | +LL | global_asm!("{}", const); + | ^ expected expression + +error: expected one of `,`, `.`, `?`, or an operator, found `FOO` + --> $DIR/parse-error.rs:111:30 + | +LL | global_asm!("{}", const(reg) FOO); + | ^^^ expected one of `,`, `.`, `?`, or an operator + +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` + --> $DIR/parse-error.rs:113:25 + | +LL | global_asm!("", options(FOO)); + | ^^^ expected one of `)`, `att_syntax`, or `raw` + +error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` + --> $DIR/parse-error.rs:115:25 + | +LL | global_asm!("", options(nomem FOO)); + | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + +error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` + --> $DIR/parse-error.rs:117:25 + | +LL | global_asm!("", options(nomem, FOO)); + | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + +error: expected string literal + --> $DIR/parse-error.rs:120:29 + | +LL | global_asm!("", clobber_abi(FOO)); + | ^^^ not a string literal + +error: expected one of `)` or `,`, found `FOO` + --> $DIR/parse-error.rs:122:33 + | +LL | global_asm!("", clobber_abi("C" FOO)); + | ^^^ expected one of `)` or `,` + +error: expected string literal + --> $DIR/parse-error.rs:124:34 + | +LL | global_asm!("", clobber_abi("C", FOO)); + | ^^^ not a string literal + +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:126:19 + | +LL | global_asm!("{}", clobber_abi("C"), const FOO); + | ^^^^^^^^^^^^^^^^ + +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:128:28 + | +LL | global_asm!("", options(), clobber_abi("C")); + | ^^^^^^^^^^^^^^^^ + +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:130:30 + | +LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); + | ^^^^^^^^^^^^^^^^ + +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:132:17 + | +LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); + | ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ + +error: duplicate argument named `a` + --> $DIR/parse-error.rs:134:35 + | +LL | global_asm!("{a}", a = const FOO, a = const BAR); + | ------------- ^^^^^^^^^^^^^ duplicate argument + | | + | previously here + +error: argument never used + --> $DIR/parse-error.rs:134:35 + | +LL | global_asm!("{a}", a = const FOO, a = const BAR); + | ^^^^^^^^^^^^^ argument never used + | + = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` + +error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` + --> $DIR/parse-error.rs:137:28 + | +LL | global_asm!("", options(), ""); + | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` + +error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` + --> $DIR/parse-error.rs:139:30 + | +LL | global_asm!("{}", const FOO, "{}", const FOO); + | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` + +error: asm template must be a string literal + --> $DIR/parse-error.rs:141:13 + | +LL | global_asm!(format!("{{{}}}", 0), const FOO); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: asm template must be a string literal + --> $DIR/parse-error.rs:143:20 + | +LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:39:37 + | +LL | let mut foo = 0; + | ----------- help: consider using `const` instead of `let`: `const foo` +... +LL | asm!("{}", options(), const foo); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:71:44 + | +LL | let mut foo = 0; + | ----------- help: consider using `const` instead of `let`: `const foo` +... +LL | asm!("{}", clobber_abi("C"), const foo); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:74:55 + | +LL | let mut foo = 0; + | ----------- help: consider using `const` instead of `let`: `const foo` +... +LL | asm!("{}", options(), clobber_abi("C"), const foo); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:76:31 + | +LL | let mut foo = 0; + | ----------- help: consider using `const` instead of `let`: `const foo` +... +LL | asm!("{a}", a = const foo, a = const bar); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:76:46 + | +LL | let mut bar = 0; + | ----------- help: consider using `const` instead of `let`: `const bar` +... +LL | asm!("{a}", a = const foo, a = const bar); + | ^^^ non-constant value + +error: aborting due to 63 previous errors + +For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/x86_64/parse-error.rs b/tests/ui/asm/x86_64/parse-error.rs deleted file mode 100644 index 2e714d464..000000000 --- a/tests/ui/asm/x86_64/parse-error.rs +++ /dev/null @@ -1,130 +0,0 @@ -// only-x86_64 - -#![feature(asm_const)] - -use std::arch::{asm, global_asm}; - -fn main() { - let mut foo = 0; - let mut bar = 0; - unsafe { - asm!(); - //~^ ERROR requires at least a template string argument - asm!(foo); - //~^ ERROR asm template must be a string literal - asm!("{}" foo); - //~^ ERROR expected token: `,` - asm!("{}", foo); - //~^ ERROR expected operand, clobber_abi, options, or additional template string - asm!("{}", in foo); - //~^ ERROR expected `(`, found `foo` - asm!("{}", in(reg foo)); - //~^ ERROR expected `)`, found `foo` - asm!("{}", in(reg)); - //~^ ERROR expected expression, found end of macro arguments - asm!("{}", inout(=) foo => bar); - //~^ ERROR expected register class or explicit register - asm!("{}", inout(reg) foo =>); - //~^ ERROR expected expression, found end of macro arguments - asm!("{}", in(reg) foo => bar); - //~^ ERROR expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>` - asm!("{}", sym foo + bar); - //~^ ERROR expected a path for argument to `sym` - asm!("", options(foo)); - //~^ ERROR expected one of - asm!("", options(nomem foo)); - //~^ ERROR expected one of - asm!("", options(nomem, foo)); - //~^ ERROR expected one of - asm!("{}", options(), const foo); - //~^ ERROR attempt to use a non-constant value in a constant - asm!("", clobber_abi()); - //~^ ERROR at least one abi must be provided - asm!("", clobber_abi(foo)); - //~^ ERROR expected string literal - asm!("", clobber_abi("C" foo)); - //~^ ERROR expected one of `)` or `,`, found `foo` - asm!("", clobber_abi("C", foo)); - //~^ ERROR expected string literal - asm!("{}", clobber_abi("C"), const foo); - //~^ ERROR attempt to use a non-constant value in a constant - asm!("", options(), clobber_abi("C")); - asm!("{}", options(), clobber_abi("C"), const foo); - //~^ ERROR attempt to use a non-constant value in a constant - asm!("{a}", a = const foo, a = const bar); - //~^ ERROR duplicate argument named `a` - //~^^ ERROR argument never used - //~^^^ ERROR attempt to use a non-constant value in a constant - //~^^^^ ERROR attempt to use a non-constant value in a constant - asm!("", a = in("eax") foo); - //~^ ERROR explicit register arguments cannot have names - asm!("{a}", in("eax") foo, a = const bar); - //~^ ERROR attempt to use a non-constant value in a constant - asm!("{a}", in("eax") foo, a = const bar); - //~^ ERROR attempt to use a non-constant value in a constant - asm!("{1}", in("eax") foo, const bar); - //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments - //~^^ ERROR attempt to use a non-constant value in a constant - asm!("", options(), ""); - //~^ ERROR expected one of - asm!("{}", in(reg) foo, "{}", out(reg) foo); - //~^ ERROR expected one of - asm!(format!("{{{}}}", 0), in(reg) foo); - //~^ ERROR asm template must be a string literal - asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); - //~^ ERROR asm template must be a string literal - asm!("{}", in(reg) _); - //~^ ERROR _ cannot be used for input operands - asm!("{}", inout(reg) _); - //~^ ERROR _ cannot be used for input operands - asm!("{}", inlateout(reg) _); - //~^ ERROR _ cannot be used for input operands - } -} - -const FOO: i32 = 1; -const BAR: i32 = 2; -global_asm!(); -//~^ ERROR requires at least a template string argument -global_asm!(FOO); -//~^ ERROR asm template must be a string literal -global_asm!("{}" FOO); -//~^ ERROR expected token: `,` -global_asm!("{}", FOO); -//~^ ERROR expected operand, options, or additional template string -global_asm!("{}", const); -//~^ ERROR expected expression, found end of macro arguments -global_asm!("{}", const(reg) FOO); -//~^ ERROR expected one of -global_asm!("", options(FOO)); -//~^ ERROR expected one of -global_asm!("", options(nomem FOO)); -//~^ ERROR expected one of -global_asm!("", options(nomem, FOO)); -//~^ ERROR expected one of -global_asm!("{}", options(), const FOO); -global_asm!("", clobber_abi(FOO)); -//~^ ERROR expected string literal -global_asm!("", clobber_abi("C" FOO)); -//~^ ERROR expected one of `)` or `,`, found `FOO` -global_asm!("", clobber_abi("C", FOO)); -//~^ ERROR expected string literal -global_asm!("{}", clobber_abi("C"), const FOO); -//~^ ERROR `clobber_abi` cannot be used with `global_asm!` -global_asm!("", options(), clobber_abi("C")); -//~^ ERROR `clobber_abi` cannot be used with `global_asm!` -global_asm!("{}", options(), clobber_abi("C"), const FOO); -//~^ ERROR `clobber_abi` cannot be used with `global_asm!` -global_asm!("", clobber_abi("C"), clobber_abi("C")); -//~^ ERROR `clobber_abi` cannot be used with `global_asm!` -global_asm!("{a}", a = const FOO, a = const BAR); -//~^ ERROR duplicate argument named `a` -//~^^ ERROR argument never used -global_asm!("", options(), ""); -//~^ ERROR expected one of -global_asm!("{}", const FOO, "{}", const FOO); -//~^ ERROR expected one of -global_asm!(format!("{{{}}}", 0), const FOO); -//~^ ERROR asm template must be a string literal -global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); -//~^ ERROR asm template must be a string literal diff --git a/tests/ui/asm/x86_64/parse-error.stderr b/tests/ui/asm/x86_64/parse-error.stderr deleted file mode 100644 index 0c9d6f715..000000000 --- a/tests/ui/asm/x86_64/parse-error.stderr +++ /dev/null @@ -1,399 +0,0 @@ -error: requires at least a template string argument - --> $DIR/parse-error.rs:11:9 - | -LL | asm!(); - | ^^^^^^ - -error: asm template must be a string literal - --> $DIR/parse-error.rs:13:14 - | -LL | asm!(foo); - | ^^^ - -error: expected token: `,` - --> $DIR/parse-error.rs:15:19 - | -LL | asm!("{}" foo); - | ^^^ expected `,` - -error: expected operand, clobber_abi, options, or additional template string - --> $DIR/parse-error.rs:17:20 - | -LL | asm!("{}", foo); - | ^^^ expected operand, clobber_abi, options, or additional template string - -error: expected `(`, found `foo` - --> $DIR/parse-error.rs:19:23 - | -LL | asm!("{}", in foo); - | ^^^ expected `(` - -error: expected `)`, found `foo` - --> $DIR/parse-error.rs:21:27 - | -LL | asm!("{}", in(reg foo)); - | ^^^ expected `)` - -error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:23:27 - | -LL | asm!("{}", in(reg)); - | ^ expected expression - -error: expected register class or explicit register - --> $DIR/parse-error.rs:25:26 - | -LL | asm!("{}", inout(=) foo => bar); - | ^ - -error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:27:37 - | -LL | asm!("{}", inout(reg) foo =>); - | ^ expected expression - -error: expected one of `!`, `,`, `.`, `::`, `?`, `{`, or an operator, found `=>` - --> $DIR/parse-error.rs:29:32 - | -LL | asm!("{}", in(reg) foo => bar); - | ^^ expected one of 7 possible tokens - -error: expected a path for argument to `sym` - --> $DIR/parse-error.rs:31:24 - | -LL | asm!("{}", sym foo + bar); - | ^^^^^^^^^ - -error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` - --> $DIR/parse-error.rs:33:26 - | -LL | asm!("", options(foo)); - | ^^^ expected one of 10 possible tokens - -error: expected one of `)` or `,`, found `foo` - --> $DIR/parse-error.rs:35:32 - | -LL | asm!("", options(nomem foo)); - | ^^^ expected one of `)` or `,` - -error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `nostack`, `preserves_flags`, `pure`, `raw`, or `readonly`, found `foo` - --> $DIR/parse-error.rs:37:33 - | -LL | asm!("", options(nomem, foo)); - | ^^^ expected one of 10 possible tokens - -error: at least one abi must be provided as an argument to `clobber_abi` - --> $DIR/parse-error.rs:41:30 - | -LL | asm!("", clobber_abi()); - | ^ - -error: expected string literal - --> $DIR/parse-error.rs:43:30 - | -LL | asm!("", clobber_abi(foo)); - | ^^^ not a string literal - -error: expected one of `)` or `,`, found `foo` - --> $DIR/parse-error.rs:45:34 - | -LL | asm!("", clobber_abi("C" foo)); - | ^^^ expected one of `)` or `,` - -error: expected string literal - --> $DIR/parse-error.rs:47:35 - | -LL | asm!("", clobber_abi("C", foo)); - | ^^^ not a string literal - -error: duplicate argument named `a` - --> $DIR/parse-error.rs:54:36 - | -LL | asm!("{a}", a = const foo, a = const bar); - | ------------- ^^^^^^^^^^^^^ duplicate argument - | | - | previously here - -error: argument never used - --> $DIR/parse-error.rs:54:36 - | -LL | asm!("{a}", a = const foo, a = const bar); - | ^^^^^^^^^^^^^ argument never used - | - = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` - -error: explicit register arguments cannot have names - --> $DIR/parse-error.rs:59:18 - | -LL | asm!("", a = in("eax") foo); - | ^^^^^^^^^^^^^^^^^ - -error: positional arguments cannot follow named arguments or explicit register arguments - --> $DIR/parse-error.rs:65:36 - | -LL | asm!("{1}", in("eax") foo, const bar); - | ------------- ^^^^^^^^^ positional argument - | | - | explicit register argument - -error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/parse-error.rs:68:29 - | -LL | asm!("", options(), ""); - | ^^ expected one of 9 possible tokens - -error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:70:33 - | -LL | asm!("{}", in(reg) foo, "{}", out(reg) foo); - | ^^^^ expected one of 9 possible tokens - -error: asm template must be a string literal - --> $DIR/parse-error.rs:72:14 - | -LL | asm!(format!("{{{}}}", 0), in(reg) foo); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: asm template must be a string literal - --> $DIR/parse-error.rs:74:21 - | -LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: _ cannot be used for input operands - --> $DIR/parse-error.rs:76:28 - | -LL | asm!("{}", in(reg) _); - | ^ - -error: _ cannot be used for input operands - --> $DIR/parse-error.rs:78:31 - | -LL | asm!("{}", inout(reg) _); - | ^ - -error: _ cannot be used for input operands - --> $DIR/parse-error.rs:80:35 - | -LL | asm!("{}", inlateout(reg) _); - | ^ - -error: requires at least a template string argument - --> $DIR/parse-error.rs:87:1 - | -LL | global_asm!(); - | ^^^^^^^^^^^^^ - -error: asm template must be a string literal - --> $DIR/parse-error.rs:89:13 - | -LL | global_asm!(FOO); - | ^^^ - -error: expected token: `,` - --> $DIR/parse-error.rs:91:18 - | -LL | global_asm!("{}" FOO); - | ^^^ expected `,` - -error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:93:19 - | -LL | global_asm!("{}", FOO); - | ^^^ expected operand, options, or additional template string - -error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:95:24 - | -LL | global_asm!("{}", const); - | ^ expected expression - -error: expected one of `,`, `.`, `?`, or an operator, found `FOO` - --> $DIR/parse-error.rs:97:30 - | -LL | global_asm!("{}", const(reg) FOO); - | ^^^ expected one of `,`, `.`, `?`, or an operator - -error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` - --> $DIR/parse-error.rs:99:25 - | -LL | global_asm!("", options(FOO)); - | ^^^ expected one of `)`, `att_syntax`, or `raw` - -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:101:25 - | -LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` - -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:103:25 - | -LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` - -error: expected string literal - --> $DIR/parse-error.rs:106:29 - | -LL | global_asm!("", clobber_abi(FOO)); - | ^^^ not a string literal - -error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:108:33 - | -LL | global_asm!("", clobber_abi("C" FOO)); - | ^^^ expected one of `)` or `,` - -error: expected string literal - --> $DIR/parse-error.rs:110:34 - | -LL | global_asm!("", clobber_abi("C", FOO)); - | ^^^ not a string literal - -error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:112:19 - | -LL | global_asm!("{}", clobber_abi("C"), const FOO); - | ^^^^^^^^^^^^^^^^ - -error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:114:28 - | -LL | global_asm!("", options(), clobber_abi("C")); - | ^^^^^^^^^^^^^^^^ - -error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:116:30 - | -LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); - | ^^^^^^^^^^^^^^^^ - -error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:118:17 - | -LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); - | ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ - -error: duplicate argument named `a` - --> $DIR/parse-error.rs:120:35 - | -LL | global_asm!("{a}", a = const FOO, a = const BAR); - | ------------- ^^^^^^^^^^^^^ duplicate argument - | | - | previously here - -error: argument never used - --> $DIR/parse-error.rs:120:35 - | -LL | global_asm!("{a}", a = const FOO, a = const BAR); - | ^^^^^^^^^^^^^ argument never used - | - = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` - -error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:123:28 - | -LL | global_asm!("", options(), ""); - | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` - -error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:125:30 - | -LL | global_asm!("{}", const FOO, "{}", const FOO); - | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` - -error: asm template must be a string literal - --> $DIR/parse-error.rs:127:13 - | -LL | global_asm!(format!("{{{}}}", 0), const FOO); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: asm template must be a string literal - --> $DIR/parse-error.rs:129:20 - | -LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:39:37 - | -LL | let mut foo = 0; - | ----------- help: consider using `const` instead of `let`: `const foo` -... -LL | asm!("{}", options(), const foo); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:49:44 - | -LL | let mut foo = 0; - | ----------- help: consider using `const` instead of `let`: `const foo` -... -LL | asm!("{}", clobber_abi("C"), const foo); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:52:55 - | -LL | let mut foo = 0; - | ----------- help: consider using `const` instead of `let`: `const foo` -... -LL | asm!("{}", options(), clobber_abi("C"), const foo); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:54:31 - | -LL | let mut foo = 0; - | ----------- help: consider using `const` instead of `let`: `const foo` -... -LL | asm!("{a}", a = const foo, a = const bar); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:54:46 - | -LL | let mut bar = 0; - | ----------- help: consider using `const` instead of `let`: `const bar` -... -LL | asm!("{a}", a = const foo, a = const bar); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:61:46 - | -LL | let mut bar = 0; - | ----------- help: consider using `const` instead of `let`: `const bar` -... -LL | asm!("{a}", in("eax") foo, a = const bar); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:63:46 - | -LL | let mut bar = 0; - | ----------- help: consider using `const` instead of `let`: `const bar` -... -LL | asm!("{a}", in("eax") foo, a = const bar); - | ^^^ non-constant value - -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:65:42 - | -LL | let mut bar = 0; - | ----------- help: consider using `const` instead of `let`: `const bar` -... -LL | asm!("{1}", in("eax") foo, const bar); - | ^^^ non-constant value - -error: aborting due to 59 previous errors - -For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/x86_64/x86_64_parse_error.rs b/tests/ui/asm/x86_64/x86_64_parse_error.rs new file mode 100644 index 000000000..715a67687 --- /dev/null +++ b/tests/ui/asm/x86_64/x86_64_parse_error.rs @@ -0,0 +1,21 @@ +// only-x86_64 + +#![feature(asm_const)] + +use std::arch::asm; + +fn main() { + let mut foo = 0; + let mut bar = 0; + unsafe { + asm!("", a = in("eax") foo); + //~^ ERROR explicit register arguments cannot have names + asm!("{a}", in("eax") foo, a = const bar); + //~^ ERROR attempt to use a non-constant value in a constant + asm!("{a}", in("eax") foo, a = const bar); + //~^ ERROR attempt to use a non-constant value in a constant + asm!("{1}", in("eax") foo, const bar); + //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments + //~^^ ERROR attempt to use a non-constant value in a constant + } +} diff --git a/tests/ui/asm/x86_64/x86_64_parse_error.stderr b/tests/ui/asm/x86_64/x86_64_parse_error.stderr new file mode 100644 index 000000000..f2854ae51 --- /dev/null +++ b/tests/ui/asm/x86_64/x86_64_parse_error.stderr @@ -0,0 +1,44 @@ +error: explicit register arguments cannot have names + --> $DIR/x86_64_parse_error.rs:11:18 + | +LL | asm!("", a = in("eax") foo); + | ^^^^^^^^^^^^^^^^^ + +error: positional arguments cannot follow named arguments or explicit register arguments + --> $DIR/x86_64_parse_error.rs:17:36 + | +LL | asm!("{1}", in("eax") foo, const bar); + | ------------- ^^^^^^^^^ positional argument + | | + | explicit register argument + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/x86_64_parse_error.rs:13:46 + | +LL | let mut bar = 0; + | ----------- help: consider using `const` instead of `let`: `const bar` +... +LL | asm!("{a}", in("eax") foo, a = const bar); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/x86_64_parse_error.rs:15:46 + | +LL | let mut bar = 0; + | ----------- help: consider using `const` instead of `let`: `const bar` +... +LL | asm!("{a}", in("eax") foo, a = const bar); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/x86_64_parse_error.rs:17:42 + | +LL | let mut bar = 0; + | ----------- help: consider using `const` instead of `let`: `const bar` +... +LL | asm!("{1}", in("eax") foo, const bar); + | ^^^ non-constant value + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/assign-assign.rs b/tests/ui/assign-assign.rs index bcf506b39..9db8fb008 100644 --- a/tests/ui/assign-assign.rs +++ b/tests/ui/assign-assign.rs @@ -6,7 +6,7 @@ fn test_assign() { let y: () = x = 10; assert_eq!(x, 10); assert_eq!(y, ()); - let mut z = x = 11; + let mut z: () = x = 11; assert_eq!(x, 11); assert_eq!(z, ()); z = x = 12; @@ -19,7 +19,7 @@ fn test_assign_op() { let y: () = x += 10; assert_eq!(x, 10); assert_eq!(y, ()); - let mut z = x += 11; + let mut z: () = x += 11; assert_eq!(x, 21); assert_eq!(z, ()); z = x += 12; diff --git a/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs new file mode 100644 index 000000000..40896c32e --- /dev/null +++ b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.rs @@ -0,0 +1,10 @@ +trait Trait { + const ASSOC: i32; +} + +impl Trait for () { + const ASSOC: &dyn Fn(_) = 1i32; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants +} + +fn main() {} diff --git a/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr new file mode 100644 index 000000000..993a08fab --- /dev/null +++ b/tests/ui/associated-consts/infer-placeholder-in-non-suggestable-pos.stderr @@ -0,0 +1,9 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants + --> $DIR/infer-placeholder-in-non-suggestable-pos.rs:6:26 + | +LL | const ASSOC: &dyn Fn(_) = 1i32; + | ^ not allowed in type signatures + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/associated-consts/issue-110933.rs b/tests/ui/associated-consts/issue-110933.rs new file mode 100644 index 000000000..aa4882ae5 --- /dev/null +++ b/tests/ui/associated-consts/issue-110933.rs @@ -0,0 +1,20 @@ +// check-pass + +#![feature(associated_const_equality)] + +pub trait Trait { + const ASSOC: usize; +} + +pub fn foo< + T: Trait< + ASSOC = { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }, + >, +>() { +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs b/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs index 34b4e47bf..152bb7a60 100644 --- a/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs +++ b/tests/ui/associated-inherent-types/assoc-inherent-unstable.rs @@ -1,6 +1,9 @@ // aux-crate:aux=assoc-inherent-unstable.rs // edition: 2021 +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data' fn main() {} diff --git a/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr b/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr index c0be8bfd7..415ee0193 100644 --- a/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr +++ b/tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature 'data' - --> $DIR/assoc-inherent-unstable.rs:4:13 + --> $DIR/assoc-inherent-unstable.rs:7:13 | LL | type Data = aux::Owner::Data; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs index f41574403..33c73c3db 100644 --- a/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs +++ b/tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.rs @@ -1,5 +1,7 @@ // known-bug: #108491 +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] // FIXME(inherent_associated_types): This should pass. struct Foo { @@ -8,3 +10,5 @@ struct Foo { impl Foo { pub type Bar = usize; } + +fn main() {} 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 f313c4946..23269e1af 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 @@ -1,49 +1,43 @@ -error[E0601]: `main` function not found in crate `cycle_iat_inside_of_adt` - --> $DIR/cycle-iat-inside-of-adt.rs:10:2 - | -LL | } - | ^ consider adding a `main` function to `$DIR/cycle-iat-inside-of-adt.rs` - error[E0391]: cycle detected when computing predicates of `Foo` - --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + --> $DIR/cycle-iat-inside-of-adt.rs:7:1 | LL | struct Foo { | ^^^^^^^^^^ | note: ...which requires computing predicates of `Foo`... - --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + --> $DIR/cycle-iat-inside-of-adt.rs:7:1 | LL | struct Foo { | ^^^^^^^^^^ note: ...which requires computing inferred outlives predicates of `Foo`... - --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + --> $DIR/cycle-iat-inside-of-adt.rs:7:1 | LL | struct Foo { | ^^^^^^^^^^ = note: ...which requires computing the inferred outlives predicates for items in this crate... note: ...which requires computing type of `Foo::bar`... - --> $DIR/cycle-iat-inside-of-adt.rs:6:5 + --> $DIR/cycle-iat-inside-of-adt.rs:8:5 | LL | bar: Self::Bar, | ^^^^^^^^^^^^^^ note: ...which requires computing normalized predicates of `Foo`... - --> $DIR/cycle-iat-inside-of-adt.rs:5:1 + --> $DIR/cycle-iat-inside-of-adt.rs:7:1 | LL | struct Foo { | ^^^^^^^^^^ = note: ...which again requires computing predicates of `Foo`, completing the cycle note: cycle used when collecting item types in top-level module - --> $DIR/cycle-iat-inside-of-adt.rs:5:1 - | -LL | / struct Foo { -LL | | bar: Self::Bar, -LL | | } -LL | | impl Foo { -LL | | pub type Bar = usize; -LL | | } - | |_^ + --> $DIR/cycle-iat-inside-of-adt.rs:3:1 + | +LL | / #![feature(inherent_associated_types)] +LL | | #![allow(incomplete_features)] +LL | | // FIXME(inherent_associated_types): This should pass. +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0391, E0601. -For more information about an error, try `rustc --explain E0391`. +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/associated-inherent-types/dont-select-if-disabled.rs b/tests/ui/associated-inherent-types/dont-select-if-disabled.rs new file mode 100644 index 000000000..472be4fbf --- /dev/null +++ b/tests/ui/associated-inherent-types/dont-select-if-disabled.rs @@ -0,0 +1,17 @@ +// Regression test for #113265. + +// Don't perform selection if the feature is not enabled to prevent cycle errors +// that exist due to current limitations of the implementation from masking the +// feature-gate error. See the aforementioned issue. +// This does lead to rustc not mentioning inherent associated types at usage-sites of +// IATs that were defined in an external crate but that's acceptable for now. + +// FIXME(inherent_associated_types): Revisit this decision once the implementation is smarter. + +// The following program would currently lead to a cycle if IATs were enabled. + +struct S(S::P); //~ ERROR ambiguous associated type + +impl S { type P = (); } //~ ERROR inherent associated types are unstable + +fn main() {} diff --git a/tests/ui/associated-inherent-types/dont-select-if-disabled.stderr b/tests/ui/associated-inherent-types/dont-select-if-disabled.stderr new file mode 100644 index 000000000..87a3f35c9 --- /dev/null +++ b/tests/ui/associated-inherent-types/dont-select-if-disabled.stderr @@ -0,0 +1,24 @@ +error[E0223]: ambiguous associated type + --> $DIR/dont-select-if-disabled.rs:13:10 + | +LL | struct S(S::P); + | ^^^^ + | +help: if there were a trait named `Example` with associated type `P` implemented for `S`, you could use the fully-qualified path + | +LL | struct S(::P); + | ~~~~~~~~~~~~~~~~~ + +error[E0658]: inherent associated types are unstable + --> $DIR/dont-select-if-disabled.rs:15:10 + | +LL | impl S { type P = (); } + | ^^^^^^^^^^^^ + | + = note: see issue #8995 for more information + = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0223, E0658. +For more information about an error, try `rustc --explain E0223`. diff --git a/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr new file mode 100644 index 000000000..6f206f2b8 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109071.no_gate.stderr @@ -0,0 +1,41 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/issue-109071.rs:8:17 + | +LL | type Item = &[T]; + | ^ explicit lifetime name needed here + +error[E0107]: missing generics for struct `Windows` + --> $DIR/issue-109071.rs:7:9 + | +LL | impl Windows { + | ^^^^^^^ expected 1 generic argument + | +note: struct defined here, with 1 generic parameter: `T` + --> $DIR/issue-109071.rs:5:8 + | +LL | struct Windows {} + | ^^^^^^^ - +help: add missing generic argument + | +LL | impl Windows { + | +++ + +error[E0658]: inherent associated types are unstable + --> $DIR/issue-109071.rs:8:5 + | +LL | type Item = &[T]; + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #8995 for more information + = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable + +error[E0223]: ambiguous associated type + --> $DIR/issue-109071.rs:15:22 + | +LL | fn T() -> Option {} + | ^^^^^^^^^^ help: use the fully-qualified path: ` as IntoIterator>::Item` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0107, E0223, E0637, E0658. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/associated-inherent-types/issue-109071.rs b/tests/ui/associated-inherent-types/issue-109071.rs new file mode 100644 index 000000000..951c708e3 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109071.rs @@ -0,0 +1,19 @@ +// revisions: with_gate no_gate +#![cfg_attr(with_gate, feature(inherent_associated_types))] +#![cfg_attr(with_gate, allow(incomplete_features))] + +struct Windows {} + +impl Windows { //~ ERROR: missing generics for struct `Windows` + type Item = &[T]; //~ ERROR: `&` without an explicit lifetime name cannot be used here + //[no_gate]~^ ERROR: inherent associated types are unstable + + fn next() -> Option {} +} + +impl Windows { + fn T() -> Option {} + //[no_gate]~^ ERROR: ambiguous associated type +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-109071.with_gate.stderr b/tests/ui/associated-inherent-types/issue-109071.with_gate.stderr new file mode 100644 index 000000000..a91bb7a51 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109071.with_gate.stderr @@ -0,0 +1,26 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/issue-109071.rs:8:17 + | +LL | type Item = &[T]; + | ^ explicit lifetime name needed here + +error[E0107]: missing generics for struct `Windows` + --> $DIR/issue-109071.rs:7:9 + | +LL | impl Windows { + | ^^^^^^^ expected 1 generic argument + | +note: struct defined here, with 1 generic parameter: `T` + --> $DIR/issue-109071.rs:5:8 + | +LL | struct Windows {} + | ^^^^^^^ - +help: add missing generic argument + | +LL | impl Windows { + | +++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0107, E0637. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/associated-inherent-types/issue-109789.stderr b/tests/ui/associated-inherent-types/issue-109789.stderr index 7af338274..84fc85cd0 100644 --- a/tests/ui/associated-inherent-types/issue-109789.stderr +++ b/tests/ui/associated-inherent-types/issue-109789.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/issue-109789.rs:18:1 + --> $DIR/issue-109789.rs:18:11 | LL | fn bar(_: Foo fn(&'a ())>::Assoc) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | = note: expected struct `Foo` found struct `Foo fn(&'a ())>` diff --git a/tests/ui/associated-inherent-types/issue-111404-0.rs b/tests/ui/associated-inherent-types/issue-111404-0.rs new file mode 100644 index 000000000..1180577bd --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111404-0.rs @@ -0,0 +1,14 @@ +// check-pass + +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo(T); + +impl<'a> Foo { + type Assoc = &'a (); +} + +fn bar(_: for<'a> fn(Foo::Assoc)>::Assoc)) {} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-111404-1.rs b/tests/ui/associated-inherent-types/issue-111404-1.rs new file mode 100644 index 000000000..f4ad5d7ff --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111404-1.rs @@ -0,0 +1,13 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Foo(T); + +impl<'a> Foo { + type Assoc = &'a (); +} + +fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} +//~^ ERROR higher-ranked subtype error + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-111404-1.stderr b/tests/ui/associated-inherent-types/issue-111404-1.stderr new file mode 100644 index 000000000..c55f14323 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111404-1.stderr @@ -0,0 +1,8 @@ +error: higher-ranked subtype error + --> $DIR/issue-111404-1.rs:10:1 + | +LL | fn bar(_: fn(Foo fn(Foo::Assoc)>::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/associated-inherent-types/private-in-public.rs b/tests/ui/associated-inherent-types/private-in-public.rs index a4b372537..e9e189f95 100644 --- a/tests/ui/associated-inherent-types/private-in-public.rs +++ b/tests/ui/associated-inherent-types/private-in-public.rs @@ -1,18 +1,26 @@ #![feature(inherent_associated_types)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] #![crate_type = "lib"] - #![deny(private_in_public)] +#![warn(private_interfaces)] + +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. pub type PubAlias0 = PubTy::PrivAssocTy; //~^ ERROR private associated type `PubTy::PrivAssocTy` in public interface (error E0446) //~| WARNING this was previously accepted +//~| WARNING associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0` pub type PubAlias1 = PrivTy::PubAssocTy; //~^ ERROR private type `PrivTy` in public interface (error E0446) //~| WARNING this was previously accepted +//~| WARNING type `PrivTy` is more private than the item `PubAlias1` pub type PubAlias2 = PubTy::PubAssocTy; //~^ ERROR private type `PrivTy` in public interface (error E0446) //~| WARNING this was previously accepted +//~| WARNING type `PrivTy` is more private than the item `PubAlias2` pub struct PubTy; impl PubTy { diff --git a/tests/ui/associated-inherent-types/private-in-public.stderr b/tests/ui/associated-inherent-types/private-in-public.stderr index f0a64e961..65d187c1b 100644 --- a/tests/ui/associated-inherent-types/private-in-public.stderr +++ b/tests/ui/associated-inherent-types/private-in-public.stderr @@ -1,5 +1,5 @@ error: private associated type `PubTy::PrivAssocTy` in public interface (error E0446) - --> $DIR/private-in-public.rs:7:1 + --> $DIR/private-in-public.rs:12:1 | LL | pub type PubAlias0 = PubTy::PrivAssocTy; | ^^^^^^^^^^^^^^^^^^ @@ -12,8 +12,25 @@ note: the lint level is defined here LL | #![deny(private_in_public)] | ^^^^^^^^^^^^^^^^^ +warning: associated type `PubTy::PrivAssocTy` is more private than the item `PubAlias0` + --> $DIR/private-in-public.rs:12:1 + | +LL | pub type PubAlias0 = PubTy::PrivAssocTy; + | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias0` is reachable at visibility `pub` + | +note: but associated type `PubTy::PrivAssocTy` is only usable at visibility `pub(crate)` + --> $DIR/private-in-public.rs:27:5 + | +LL | type PrivAssocTy = (); + | ^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/private-in-public.rs:6:9 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^ + error: private type `PrivTy` in public interface (error E0446) - --> $DIR/private-in-public.rs:10:1 + --> $DIR/private-in-public.rs:16:1 | LL | pub type PubAlias1 = PrivTy::PubAssocTy; | ^^^^^^^^^^^^^^^^^^ @@ -21,8 +38,20 @@ LL | pub type PubAlias1 = PrivTy::PubAssocTy; = 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 #34537 +warning: type `PrivTy` is more private than the item `PubAlias1` + --> $DIR/private-in-public.rs:16:1 + | +LL | pub type PubAlias1 = PrivTy::PubAssocTy; + | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias1` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/private-in-public.rs:31:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ + error: private type `PrivTy` in public interface (error E0446) - --> $DIR/private-in-public.rs:13:1 + --> $DIR/private-in-public.rs:20:1 | LL | pub type PubAlias2 = PubTy::PubAssocTy; | ^^^^^^^^^^^^^^^^^^ @@ -30,5 +59,17 @@ LL | pub type PubAlias2 = PubTy::PubAssocTy; = 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 #34537 -error: aborting due to 3 previous errors +warning: type `PrivTy` is more private than the item `PubAlias2` + --> $DIR/private-in-public.rs:20:1 + | +LL | pub type PubAlias2 = PubTy::PubAssocTy; + | ^^^^^^^^^^^^^^^^^^ type alias `PubAlias2` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/private-in-public.rs:31:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors; 3 warnings emitted diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs index a8d00803a..a3f471779 100644 --- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs +++ b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs @@ -59,8 +59,8 @@ fn def_et4() -> Et4 { pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs index 08f965452..52199124e 100644 --- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs +++ b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs @@ -66,8 +66,8 @@ fn def_et4() -> Box Tr2<'a>>> { pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-type-bounds/implied-in-supertrait.rs b/tests/ui/associated-type-bounds/implied-in-supertrait.rs new file mode 100644 index 000000000..ea7e7c984 --- /dev/null +++ b/tests/ui/associated-type-bounds/implied-in-supertrait.rs @@ -0,0 +1,19 @@ +// check-pass + +#![feature(associated_type_bounds)] + +trait Trait: Super {} + +trait Super { + type Assoc; +} + +trait Bound {} + +fn foo(x: T) +where + T: Trait, +{ +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr new file mode 100644 index 000000000..b8be132e6 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.current.stderr @@ -0,0 +1,48 @@ +error: return type notation uses `()` instead of `(..)` for elided arguments + --> $DIR/bad-inputs-and-output.rs:20:24 + | +LL | fn baz>() {} + | ^^ help: remove the `..` + +error[E0658]: associated type bounds are unstable + --> $DIR/bad-inputs-and-output.rs:12: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:16: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:5: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:12:23 + | +LL | fn foo>() {} + | ^^^^^ help: remove the input types: `()` + +error: return type not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:16: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/bad-inputs-and-output.next.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr new file mode 100644 index 000000000..b8be132e6 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.next.stderr @@ -0,0 +1,48 @@ +error: return type notation uses `()` instead of `(..)` for elided arguments + --> $DIR/bad-inputs-and-output.rs:20:24 + | +LL | fn baz>() {} + | ^^ help: remove the `..` + +error[E0658]: associated type bounds are unstable + --> $DIR/bad-inputs-and-output.rs:12: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:16: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:5: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:12:23 + | +LL | fn foo>() {} + | ^^^^^ help: remove the input types: `()` + +error: return type not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:16: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/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 58ce41d1a..771acb6c4 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,4 +1,6 @@ // 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 deleted file mode 100644 index 95ef7d82f..000000000 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ /dev/null @@ -1,48 +0,0 @@ -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.current_with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.current_with.stderr new file mode 100644 index 000000000..98c1a2827 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.current_with.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/basic.rs:8:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.stderr new file mode 100644 index 000000000..1066c420c --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.current_without.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/basic.rs:8: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: future cannot be sent between threads safely + --> $DIR/basic.rs:26:13 + | +LL | is_send(foo::()); + | ^^^^^^^^^^ future returned by `foo` 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/basic.rs:16:5 + | +LL | T::method().await?; + | ^^^^^^^^^^^ await occurs here on type `impl Future>`, which is not `Send` +note: required by a bound in `is_send` + --> $DIR/basic.rs:20:20 + | +LL | fn is_send(_: impl Send) {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.stderr new file mode 100644 index 000000000..98c1a2827 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.next_with.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/basic.rs:8:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.stderr new file mode 100644 index 000000000..1066c420c --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.next_without.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/basic.rs:8: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: future cannot be sent between threads safely + --> $DIR/basic.rs:26:13 + | +LL | is_send(foo::()); + | ^^^^^^^^^^ future returned by `foo` 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/basic.rs:16:5 + | +LL | T::method().await?; + | ^^^^^^^^^^^ await occurs here on type `impl Future>`, which is not `Send` +note: required by a bound in `is_send` + --> $DIR/basic.rs:20:20 + | +LL | fn is_send(_: impl Send) {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to previous error; 1 warning emitted + 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 edc6a8e4c..d443c9dc1 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -1,6 +1,9 @@ -// revisions: with without +// 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 // edition: 2021 -//[with] check-pass +// [current_with] check-pass +// [next_with] check-pass #![feature(return_type_notation, async_fn_in_trait)] //~^ WARN the feature `return_type_notation` is incomplete @@ -17,11 +20,12 @@ async fn foo() -> Result<(), ()> { fn is_send(_: impl Send) {} fn test< - #[cfg(with)] T: Foo, - #[cfg(without)] T: Foo, + #[cfg(any(current_with, next_with))] T: Foo, + #[cfg(any(current_without, next_without))] T: Foo, >() { is_send(foo::()); - //[without]~^ ERROR future cannot be sent between threads safely + //[current_without]~^ ERROR future cannot be sent between threads safely + //[next_without]~^^ ERROR future cannot be sent between threads safely } fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.current.stderr new file mode 100644 index 000000000..b631dd0eb --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.current.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:5: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:14:18 + | +LL | fn test>>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.next.stderr new file mode 100644 index 000000000..b631dd0eb --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.next.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:5: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:14:18 + | +LL | fn test>>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + 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 6884305d7..0d6545cc2 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -1,4 +1,6 @@ // 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 deleted file mode 100644 index 490bfdc4c..000000000 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr +++ /dev/null @@ -1,17 +0,0 @@ -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-type-bounds/rpit.rs b/tests/ui/associated-type-bounds/rpit.rs index 47cadf331..59c7733fb 100644 --- a/tests/ui/associated-type-bounds/rpit.rs +++ b/tests/ui/associated-type-bounds/rpit.rs @@ -57,8 +57,8 @@ fn def_et4() -> impl Tr1 Tr2<'a>> { pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs b/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs index e223a8957..93a44c01c 100644 --- a/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs +++ b/tests/ui/associated-type-bounds/trait-alias-impl-trait.rs @@ -89,8 +89,8 @@ pub fn use_et4() { } fn main() { - let _ = use_et1(); - let _ = use_et2(); - let _ = use_et3(); - let _ = use_et4(); + use_et1(); + use_et2(); + use_et3(); + use_et4(); } diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs b/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs new file mode 100644 index 000000000..6894f6b6c --- /dev/null +++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.rs @@ -0,0 +1,11 @@ +use std::fmt::Debug; + +fn foo(mut iter: I, value: &I::Item) +where + I::Item: Eq + Debug, +{ + debug_assert_eq!(iter.next(), Some(value)); + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr new file mode 100644 index 000000000..3ecac9c83 --- /dev/null +++ b/tests/ui/associated-types/dont-suggest-cyclic-constraint.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/dont-suggest-cyclic-constraint.rs:7:35 + | +LL | debug_assert_eq!(iter.next(), Some(value)); + | ^^^^^^^^^^^ expected `Option<::Item>`, found `Option<&::Item>` + | + = note: expected enum `Option<::Item>` + found enum `Option<&::Item>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/associated-types/normalization-debruijn-3.rs b/tests/ui/associated-types/normalization-debruijn-3.rs index 2bea78cf7..bd9a8fcf4 100644 --- a/tests/ui/associated-types/normalization-debruijn-3.rs +++ b/tests/ui/associated-types/normalization-debruijn-3.rs @@ -6,10 +6,10 @@ use std::future::{Future, Ready}; async fn read() { - let _ = connect(&()).await; + connect(&()).await; } async fn connect(addr: A) { - let _ = addr.to_socket_addr().await; + addr.to_socket_addr().await; } pub trait ToSocketAddr { type Future: Future; diff --git a/tests/ui/async-await/deep-futures-are-freeze.rs b/tests/ui/async-await/deep-futures-are-freeze.rs new file mode 100644 index 000000000..dd676d5e1 --- /dev/null +++ b/tests/ui/async-await/deep-futures-are-freeze.rs @@ -0,0 +1,179 @@ +// build-pass +// compile-flags: -Copt-level=s -Clto=fat +// no-prefer-dynamic +// edition: 2021 + +#![recursion_limit = "256"] + +fn main() { + spawn(move || main0()) +} + +fn spawn(future: impl FnOnce() -> F) { + future(); +} + +async fn main0() { + main1().await; + main2().await; +} +async fn main1() { + main2().await; + main3().await; +} +async fn main2() { + main3().await; + main4().await; +} +async fn main3() { + main4().await; + main5().await; +} +async fn main4() { + main5().await; + main6().await; +} +async fn main5() { + main6().await; + main7().await; +} +async fn main6() { + main7().await; + main8().await; +} +async fn main7() { + main8().await; + main9().await; +} +async fn main8() { + main9().await; + main10().await; +} +async fn main9() { + main10().await; + main11().await; +} +async fn main10() { + main11().await; + main12().await; +} +async fn main11() { + main12().await; + main13().await; +} +async fn main12() { + main13().await; + main14().await; +} +async fn main13() { + main14().await; + main15().await; +} +async fn main14() { + main15().await; + main16().await; +} +async fn main15() { + main16().await; + main17().await; +} +async fn main16() { + main17().await; + main18().await; +} +async fn main17() { + main18().await; + main19().await; +} +async fn main18() { + main19().await; + main20().await; +} +async fn main19() { + main20().await; + main21().await; +} +async fn main20() { + main21().await; + main22().await; +} +async fn main21() { + main22().await; + main23().await; +} +async fn main22() { + main23().await; + main24().await; +} +async fn main23() { + main24().await; + main25().await; +} +async fn main24() { + main25().await; + main26().await; +} +async fn main25() { + main26().await; + main27().await; +} +async fn main26() { + main27().await; + main28().await; +} +async fn main27() { + main28().await; + main29().await; +} +async fn main28() { + main29().await; + main30().await; +} +async fn main29() { + main30().await; + main31().await; +} +async fn main30() { + main31().await; + main32().await; +} +async fn main31() { + main32().await; + main33().await; +} +async fn main32() { + main33().await; + main34().await; +} +async fn main33() { + main34().await; + main35().await; +} +async fn main34() { + main35().await; + main36().await; +} +async fn main35() { + main36().await; + main37().await; +} +async fn main36() { + main37().await; + main38().await; +} +async fn main37() { + main38().await; + main39().await; +} +async fn main38() { + main39().await; + main40().await; +} +async fn main39() { + main40().await; +} +async fn main40() { + boom(&mut ()).await; +} + +async fn boom(f: &mut ()) {} diff --git a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr index 07ab8b3c9..b49b15db6 100644 --- a/tests/ui/async-await/drop-track-bad-field-in-fru.stderr +++ b/tests/ui/async-await/drop-track-bad-field-in-fru.stderr @@ -3,6 +3,8 @@ error[E0559]: variant `Option<_>::None` has no field named `value` | LL | None { value: (), ..Default::default() }.await; | ^^^^^ `Option<_>::None` does not have this field + | + = note: all struct fields are already assigned error[E0277]: `Option<_>` is not a future --> $DIR/drop-track-bad-field-in-fru.rs:7:46 diff --git a/tests/ui/async-await/drop-track-field-assign.rs b/tests/ui/async-await/drop-track-field-assign.rs index dd0e3f11c..b79d2af06 100644 --- a/tests/ui/async-await/drop-track-field-assign.rs +++ b/tests/ui/async-await/drop-track-field-assign.rs @@ -21,7 +21,7 @@ impl Agent { let mut info = self.info_result.clone(); info.node = Some("bar".into()); let element = parse_info(info); - let _ = send_element(element).await; + send_element(element).await; } } diff --git a/tests/ui/async-await/field-assign.rs b/tests/ui/async-await/field-assign.rs index dd0e3f11c..b79d2af06 100644 --- a/tests/ui/async-await/field-assign.rs +++ b/tests/ui/async-await/field-assign.rs @@ -21,7 +21,7 @@ impl Agent { let mut info = self.info_result.clone(); info.node = Some("bar".into()); let element = parse_info(info); - let _ = send_element(element).await; + send_element(element).await; } } diff --git a/tests/ui/async-await/in-trait/async-associated-types2.rs b/tests/ui/async-await/in-trait/async-associated-types2.rs deleted file mode 100644 index b889f616a..000000000 --- a/tests/ui/async-await/in-trait/async-associated-types2.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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_in_assoc_type)] -#![allow(incomplete_features)] - -use std::future::Future; - -trait MyTrait { - type Fut<'a>: Future - where - Self: 'a; - - fn foo<'a>(&'a self) -> Self::Fut<'a>; -} - -impl MyTrait for i32 { - type Fut<'a> = impl Future + 'a - where - Self: 'a; - - fn foo<'a>(&'a self) -> Self::Fut<'a> { - async { *self } - } -} - -fn main() {} 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 d5481d277..9869a8d71 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,5 +1,7 @@ // 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 f298e45d2..ecbd1910a 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes.rs @@ -1,5 +1,7 @@ // 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/missing-feature-flag.current.stderr b/tests/ui/async-await/in-trait/missing-feature-flag.current.stderr new file mode 100644 index 000000000..e6ac9bc22 --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-feature-flag.current.stderr @@ -0,0 +1,30 @@ +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 new file mode 100644 index 000000000..e6ac9bc22 --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-feature-flag.next.stderr @@ -0,0 +1,30 @@ +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 new file mode 100644 index 000000000..6481f4a70 --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-feature-flag.rs @@ -0,0 +1,23 @@ +// edition:2018 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(async_fn_in_trait)] +#![feature(min_specialization)] + +struct MyStruct; + +trait MyTrait { + async fn foo(_: T) -> &'static str; +} + +impl MyTrait for MyStruct {} +//~^ ERROR: not all trait items implemented, missing: `foo` [E0046] + +impl MyTrait for MyStruct { + async fn foo(_: i32) -> &'static str {} + //~^ ERROR: `foo` specializes an item from a parent `impl`, but that item is not marked `default` [E0520] + //~| ERROR: mismatched types [E0308] +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs b/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs new file mode 100644 index 000000000..c4008f2b7 --- /dev/null +++ b/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs @@ -0,0 +1,64 @@ +// build-pass +// edition:2021 +// compile-flags: -Cdebuginfo=2 + +// We were not normalizing opaques with escaping bound vars during codegen, +// leading to later errors during debuginfo computation. + +#![feature(async_fn_in_trait)] + +#[derive(Clone, Copy)] +pub struct SharedState {} + +pub trait State { + async fn execute(self, shared_state: &SharedState); +} + +pub trait StateComposer { + fn and_then(self, map_fn: F) -> AndThen + where + Self: State + Sized, + T: State, + F: FnOnce() -> T, + { + AndThen { previous: self, map_fn } + } +} + +impl StateComposer for T where T: State {} +pub struct AndThen { + previous: T, + map_fn: F, +} + +impl State for AndThen +where + T: State, + U: State, + F: FnOnce() -> U, +{ + async fn execute(self, shared_state: &SharedState) + where + Self: Sized, + { + self.previous.execute(shared_state).await; + (self.map_fn)().execute(shared_state).await + } +} + +pub struct SomeState {} + +impl State for SomeState { + async fn execute(self, shared_state: &SharedState) {} +} + +pub fn main() { + let shared_state = SharedState {}; + async { + SomeState {} + .and_then(|| SomeState {}) + .and_then(|| SomeState {}) + .execute(&shared_state) + .await; + }; +} 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 new file mode 100644 index 000000000..56973a1d1 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.current.stderr @@ -0,0 +1,39 @@ +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 new file mode 100644 index 000000000..56973a1d1 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.next.stderr @@ -0,0 +1,39 @@ +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 new file mode 100644 index 000000000..d1b3832d1 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-pair.rs @@ -0,0 +1,19 @@ +// edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(async_fn_in_trait)] + +trait MyTrait<'a, 'b, T> { + async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T); + //~^ ERROR: cannot find type `ConnImpl` in this scope [E0412] +} + +impl<'a, 'b, T, U> MyTrait for U { + //~^ ERROR: implicit elided lifetime not allowed here [E0726] + async fn foo(_: T) -> (&'a U, &'b T) {} + //~^ ERROR: method `foo` has a `&self` declaration in the trait, but not in the impl [E0186] + //~| ERROR: mismatched types [E0308] +} + +fn main() {} 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 new file mode 100644 index 000000000..2564d68d5 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.current.stderr @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..2564d68d5 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.next.stderr @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..37c02827e --- /dev/null +++ b/tests/ui/async-await/in-trait/return-not-existing-type-wrapping-rpitit.rs @@ -0,0 +1,20 @@ +// edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] + +struct Wrapper(T); + +trait Foo { + fn bar() -> Wrapper>; + //~^ ERROR: cannot find type `Missing` in this scope [E0412] +} + +impl Foo for () { + fn bar() -> Wrapper { + Wrapper(0) + } +} + +fn main() {} diff --git a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr index 4b575a3d3..60b7551ff 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-64130-4-async-move.no_drop_tracking.stderr @@ -6,13 +6,13 @@ LL | pub fn foo() -> impl Future + Send { | = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` note: future is not `Send` as this value is used across an await - --> $DIR/issue-64130-4-async-move.rs:27:32 + --> $DIR/issue-64130-4-async-move.rs:27:23 | LL | match client.status() { | ------ has type `&Client` which is not `Send` LL | 200 => { -LL | let _x = get().await; - | ^^^^^ await occurs here, with `client` maybe used later +LL | get().await; + | ^^^^^ await occurs here, with `client` maybe used later ... LL | } | - `client` is later dropped here diff --git a/tests/ui/async-await/issue-64130-4-async-move.rs b/tests/ui/async-await/issue-64130-4-async-move.rs index bcb297aaa..5d68a808b 100644 --- a/tests/ui/async-await/issue-64130-4-async-move.rs +++ b/tests/ui/async-await/issue-64130-4-async-move.rs @@ -24,7 +24,7 @@ pub fn foo() -> impl Future + Send { async move { match client.status() { 200 => { - let _x = get().await; + get().await; } _ => (), } diff --git a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr index 721234aa4..f80bb4242 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr @@ -1,18 +1,25 @@ -error[E0277]: `Sender` cannot be shared between threads safely - --> $DIR/issue-70935-complex-spans.rs:13:45 +error[E0277]: `*mut ()` cannot be shared between threads safely + --> $DIR/issue-70935-complex-spans.rs:18:23 | -LL | fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ `Sender` cannot be shared between threads safely +LL | fn foo(x: NotSync) -> impl Future + Send { + | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `Sender` - = note: required for `&Sender` to implement `Send` + = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` +note: required because it appears within the type `PhantomData<*mut ()>` + --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required because it appears within the type `NotSync` + --> $DIR/issue-70935-complex-spans.rs:12:8 + | +LL | struct NotSync(PhantomData<*mut ()>); + | ^^^^^^^ + = note: required for `&NotSync` to implement `Send` note: required because it's used within this closure - --> $DIR/issue-70935-complex-spans.rs:17:13 + --> $DIR/issue-70935-complex-spans.rs:22:13 | -LL | baz(|| async{ +LL | baz(|| async { | ^^ note: required because it's used within this `async fn` body - --> $DIR/issue-70935-complex-spans.rs:10:67 + --> $DIR/issue-70935-complex-spans.rs:15:67 | LL | async fn baz(_c: impl FnMut() -> T) where T: Future { | ___________________________________________________________________^ @@ -20,11 +27,11 @@ LL | | } | |_^ = note: required because it captures the following types: `ResumeTy`, `impl Future`, `()` note: required because it's used within this `async` block - --> $DIR/issue-70935-complex-spans.rs:16:5 + --> $DIR/issue-70935-complex-spans.rs:21:5 | LL | / async move { -LL | | baz(|| async{ -LL | | foo(tx.clone()); +LL | | baz(|| async { +LL | | foo(x.clone()); LL | | }).await; LL | | } | |_____^ diff --git a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr index c636be15a..eb9d93e22 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.drop_tracking_mir.stderr @@ -1,18 +1,25 @@ -error[E0277]: `Sender` cannot be shared between threads safely - --> $DIR/issue-70935-complex-spans.rs:13:45 +error[E0277]: `*mut ()` cannot be shared between threads safely + --> $DIR/issue-70935-complex-spans.rs:18:23 | -LL | fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ `Sender` cannot be shared between threads safely +LL | fn foo(x: NotSync) -> impl Future + Send { + | ^^^^^^^^^^^^^^^^^^ `*mut ()` cannot be shared between threads safely | - = help: the trait `Sync` is not implemented for `Sender` - = note: required for `&Sender` to implement `Send` + = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` +note: required because it appears within the type `PhantomData<*mut ()>` + --> $SRC_DIR/core/src/marker.rs:LL:COL +note: required because it appears within the type `NotSync` + --> $DIR/issue-70935-complex-spans.rs:12:8 + | +LL | struct NotSync(PhantomData<*mut ()>); + | ^^^^^^^ + = note: required for `&NotSync` to implement `Send` note: required because it's used within this closure - --> $DIR/issue-70935-complex-spans.rs:17:13 + --> $DIR/issue-70935-complex-spans.rs:22:13 | -LL | baz(|| async{ +LL | baz(|| async { | ^^ note: required because it's used within this `async fn` body - --> $DIR/issue-70935-complex-spans.rs:10:67 + --> $DIR/issue-70935-complex-spans.rs:15:67 | LL | async fn baz(_c: impl FnMut() -> T) where T: Future { | ___________________________________________________________________^ @@ -20,11 +27,11 @@ LL | | } | |_^ = note: required because it captures the following types: `impl Future` note: required because it's used within this `async` block - --> $DIR/issue-70935-complex-spans.rs:16:5 + --> $DIR/issue-70935-complex-spans.rs:21:5 | LL | / async move { -LL | | baz(|| async{ -LL | | foo(tx.clone()); +LL | | baz(|| async { +LL | | foo(x.clone()); LL | | }).await; LL | | } | |_____^ diff --git a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr index ef0e182e5..d8ef6a5ee 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr +++ b/tests/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr @@ -1,21 +1,21 @@ error: future cannot be sent between threads safely - --> $DIR/issue-70935-complex-spans.rs:13:45 + --> $DIR/issue-70935-complex-spans.rs:18:23 | -LL | fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { - | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` +LL | fn foo(x: NotSync) -> impl Future + Send { + | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | - = help: the trait `Sync` is not implemented for `Sender` + = help: within `NotSync`, the trait `Sync` is not implemented for `*mut ()` note: future is not `Send` as this value is used across an await - --> $DIR/issue-70935-complex-spans.rs:19:12 + --> $DIR/issue-70935-complex-spans.rs:24:12 | -LL | baz(|| async{ +LL | baz(|| async { | _____________- -LL | | foo(tx.clone()); +LL | | foo(x.clone()); LL | | }).await; | | - ^^^^^- the value is later dropped here | | | | | |_________| await occurs here, with the value maybe used later - | has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send` + | has type `[closure@$DIR/issue-70935-complex-spans.rs:22:13: 22:15]` which is not `Send` error: aborting due to previous error diff --git a/tests/ui/async-await/issue-70935-complex-spans.rs b/tests/ui/async-await/issue-70935-complex-spans.rs index 78625bd39..9ebde1d39 100644 --- a/tests/ui/async-await/issue-70935-complex-spans.rs +++ b/tests/ui/async-await/issue-70935-complex-spans.rs @@ -6,16 +6,21 @@ // with newlines which lead complex diagnostics. use std::future::Future; +use std::marker::PhantomData; + +#[derive(Clone)] +struct NotSync(PhantomData<*mut ()>); +unsafe impl Send for NotSync {} async fn baz(_c: impl FnMut() -> T) where T: Future { } -fn foo(tx: std::sync::mpsc::Sender) -> impl Future + Send { +fn foo(x: NotSync) -> impl Future + Send { //[no_drop_tracking]~^ ERROR future cannot be sent between threads safely - //[drop_tracking,drop_tracking_mir]~^^ ERROR `Sender` cannot be shared between threads + //[drop_tracking,drop_tracking_mir]~^^ ERROR `*mut ()` cannot be shared between threads async move { - baz(|| async{ - foo(tx.clone()); + baz(|| async { + foo(x.clone()); }).await; } } @@ -24,6 +29,6 @@ fn bar(_s: impl Future + Send) { } fn main() { - let (tx, _rx) = std::sync::mpsc::channel(); - bar(foo(tx)); + let x = NotSync(PhantomData); + bar(foo(x)); } diff --git a/tests/ui/async-await/issue-78115.rs b/tests/ui/async-await/issue-78115.rs new file mode 100644 index 000000000..ac18470c6 --- /dev/null +++ b/tests/ui/async-await/issue-78115.rs @@ -0,0 +1,19 @@ +// Regression test for issue #78115: "ICE: variable should be placed in scope earlier" + +// check-pass +// edition:2018 + +#[allow(dead_code)] +struct Foo { + a: () +} + +async fn _bar() { + let foo = Foo { a: () }; + match foo { + Foo { a: _a } | Foo { a: _a } if true => {} + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/async-await/non-trivial-drop.rs b/tests/ui/async-await/non-trivial-drop.rs index d4df9d439..258da0756 100644 --- a/tests/ui/async-await/non-trivial-drop.rs +++ b/tests/ui/async-await/non-trivial-drop.rs @@ -7,7 +7,7 @@ #![feature(generators)] fn main() { - let _ = foo(); + foo(); } fn foo() { diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.current.stderr new file mode 100644 index 000000000..1b847b59e --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.current.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:6: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:17: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:17:11: 22:6]: Send` + +error: higher-ranked lifetime error + --> $DIR/issue-110963-early.rs:17: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:17:11: 22:6]: Send` + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.next.stderr new file mode 100644 index 000000000..1b847b59e --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.next.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:6: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:17: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:17:11: 22:6]: Send` + +error: higher-ranked lifetime error + --> $DIR/issue-110963-early.rs:17: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:17:11: 22:6]: Send` + +error: aborting due to 2 previous errors; 1 warning emitted + 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 0ecbca5c1..eee31aa1f 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,5 +1,7 @@ // 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 deleted file mode 100644 index 33e22dec3..000000000 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr +++ /dev/null @@ -1,37 +0,0 @@ -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.current.stderr b/tests/ui/async-await/return-type-notation/issue-110963-late.current.stderr new file mode 100644 index 000000000..018f4f220 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.current.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:6: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/issue-110963-late.next.stderr b/tests/ui/async-await/return-type-notation/issue-110963-late.next.stderr new file mode 100644 index 000000000..018f4f220 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.next.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:6: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/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs index 17b5d775d..ea047cd3b 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,5 +1,7 @@ // 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 deleted file mode 100644 index 9c6966537..000000000 --- a/tests/ui/async-await/return-type-notation/issue-110963-late.stderr +++ /dev/null @@ -1,11 +0,0 @@ -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/rtn-implied-in-supertrait.rs b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs new file mode 100644 index 000000000..e55104ee9 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs @@ -0,0 +1,28 @@ +// edition:2021 +// check-pass + +#![feature(async_fn_in_trait, return_position_impl_trait_in_trait, return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +use std::future::Future; + +struct JoinHandle(fn() -> T); + +fn spawn(_: impl Future) -> JoinHandle { + todo!() +} + +trait Foo { + async fn bar(&self) -> i32; +} + +trait SendFoo: Foo + Send {} + +fn foobar(foo: impl SendFoo) -> JoinHandle { + spawn(async move { + let future = foo.bar(); + future.await + }) +} + +fn main() {} diff --git a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.stderr new file mode 100644 index 000000000..8626648b5 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.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/rtn-implied-in-supertrait.rs:4:68 + | +LL | #![feature(async_fn_in_trait, 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/rtn-in-impl-signature.rs b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs new file mode 100644 index 000000000..1b16a492a --- /dev/null +++ b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs @@ -0,0 +1,13 @@ +#![feature(return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +// Shouldn't ICE when we have a (bad) RTN in an impl header + +trait Super1<'a> { + fn bar<'b>() -> bool; +} + +impl Super1<'_, bar(): Send> for () {} +//~^ ERROR associated type bindings are not allowed here + +fn main() {} diff --git a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr new file mode 100644 index 000000000..52d8168c9 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr @@ -0,0 +1,18 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/rtn-in-impl-signature.rs:1:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0229]: associated type bindings are not allowed here + --> $DIR/rtn-in-impl-signature.rs:10:17 + | +LL | impl Super1<'_, bar(): Send> for () {} + | ^^^^^^^^^^^ associated type not allowed here + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0229`. diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.current.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.current.stderr new file mode 100644 index 000000000..891c802c5 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound.current.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:6: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/super-method-bound.next.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.next.stderr new file mode 100644 index 000000000..891c802c5 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/super-method-bound.next.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:6: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/super-method-bound.rs b/tests/ui/async-await/return-type-notation/super-method-bound.rs index 58ea3578d..0163c62f5 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,5 +1,7 @@ // 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 deleted file mode 100644 index ac0668d3c..000000000 --- a/tests/ui/async-await/return-type-notation/super-method-bound.stderr +++ /dev/null @@ -1,11 +0,0 @@ -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.current.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.current.stderr new file mode 100644 index 000000000..05cb0ca4a --- /dev/null +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.current.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:5: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/supertrait-bound.next.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.next.stderr new file mode 100644 index 000000000..05cb0ca4a --- /dev/null +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.next.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:5: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/supertrait-bound.rs b/tests/ui/async-await/return-type-notation/supertrait-bound.rs index 19bcfe304..09de32c5d 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.rs +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.rs @@ -1,4 +1,6 @@ // 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 deleted file mode 100644 index c8cec4946..000000000 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.stderr +++ /dev/null @@ -1,11 +0,0 @@ -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.current.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.current.stderr new file mode 100644 index 000000000..1aa008fe4 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.current.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:5: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:16: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:16: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/return-type-notation/ty-or-ct-params.next.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.next.stderr new file mode 100644 index 000000000..1aa008fe4 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.next.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:5: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:16: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:16: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/return-type-notation/ty-or-ct-params.rs b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs new file mode 100644 index 000000000..3141da1d2 --- /dev/null +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs @@ -0,0 +1,22 @@ +// 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 + +trait Foo { + async fn bar() {} + + async fn baz() {} +} + +fn test() +where + T: Foo, + //~^ ERROR return type notation is not allowed for functions that have const parameters + //~| ERROR return type notation is not allowed for functions that have type parameters +{ +} + +fn main() {} diff --git a/tests/ui/attributes/doc-test-literal.rs b/tests/ui/attributes/doc-test-literal.rs new file mode 100644 index 000000000..a06a1afcb --- /dev/null +++ b/tests/ui/attributes/doc-test-literal.rs @@ -0,0 +1,7 @@ +#![deny(warnings)] + +#![doc(test(""))] +//~^ ERROR `#![doc(test(...)]` does not take a literal +//~^^ WARN 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/attributes/doc-test-literal.stderr b/tests/ui/attributes/doc-test-literal.stderr new file mode 100644 index 000000000..ebee09994 --- /dev/null +++ b/tests/ui/attributes/doc-test-literal.stderr @@ -0,0 +1,17 @@ +error: `#![doc(test(...)]` does not take a literal + --> $DIR/doc-test-literal.rs:3:13 + | +LL | #![doc(test(""))] + | ^^ + | + = 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: the lint level is defined here + --> $DIR/doc-test-literal.rs:1:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: `#[deny(invalid_doc_attributes)]` implied by `#[deny(warnings)]` + +error: aborting due to previous error + diff --git a/tests/ui/auto-traits/issue-23080-2.current.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr new file mode 100644 index 000000000..a57c6d9b0 --- /dev/null +++ b/tests/ui/auto-traits/issue-23080-2.current.stderr @@ -0,0 +1,11 @@ +error[E0380]: auto traits cannot have associated items + --> $DIR/issue-23080-2.rs:8:10 + | +LL | unsafe auto trait Trait { + | ----- auto traits cannot have associated items +LL | type Output; + | -----^^^^^^- help: remove these associated items + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0380`. diff --git a/tests/ui/auto-traits/issue-23080-2.next.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr new file mode 100644 index 000000000..a57c6d9b0 --- /dev/null +++ b/tests/ui/auto-traits/issue-23080-2.next.stderr @@ -0,0 +1,11 @@ +error[E0380]: auto traits cannot have associated items + --> $DIR/issue-23080-2.rs:8:10 + | +LL | unsafe auto trait Trait { + | ----- auto traits cannot have associated items +LL | type Output; + | -----^^^^^^- help: remove these associated items + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0380`. diff --git a/tests/ui/auto-traits/issue-23080-2.rs b/tests/ui/auto-traits/issue-23080-2.rs index cb4cf6de1..882b8f393 100644 --- a/tests/ui/auto-traits/issue-23080-2.rs +++ b/tests/ui/auto-traits/issue-23080-2.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![feature(auto_traits)] #![feature(negative_impls)] diff --git a/tests/ui/auto-traits/issue-23080-2.stderr b/tests/ui/auto-traits/issue-23080-2.stderr deleted file mode 100644 index fed485612..000000000 --- a/tests/ui/auto-traits/issue-23080-2.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0380]: auto traits cannot have associated items - --> $DIR/issue-23080-2.rs:5:10 - | -LL | unsafe auto trait Trait { - | ----- auto traits cannot have associated items -LL | type Output; - | -----^^^^^^- help: remove these associated items - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0380`. diff --git a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs new file mode 100644 index 000000000..d8034d57e --- /dev/null +++ b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs @@ -0,0 +1,40 @@ +use std::ops::Deref; +use std::rc::Rc; + +struct Value(T); + +pub trait Wrap { + fn wrap() -> Self; +} + +impl Wrap R> for Value R> { + fn wrap() -> Self { + todo!() + } +} + +impl Wrap for Value R>> { + fn wrap() -> Self { + todo!() + } +} + +impl Deref for Value> { + type Target = F; + + fn deref(&self) -> &Self::Target { + &*self.0 + } +} + +fn main() { + let var_fn = Value::wrap(); + //~^ ERROR type annotations needed for `Value>` + + // The combination of `Value: Wrap` obligation plus the autoderef steps + // (caused by the `Deref` impl above) actually means that the self type + // of the method fn below is constrained to be `Value ?2>>`. + // However, that's only known to us on the error path -- we still need + // to emit an ambiguity error, though. + let _ = var_fn.clone(); +} diff --git a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr new file mode 100644 index 000000000..06a7e9085 --- /dev/null +++ b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr @@ -0,0 +1,17 @@ +error[E0282]: type annotations needed for `Value>` + --> $DIR/deref-ambiguity-becomes-nonambiguous.rs:31:9 + | +LL | let var_fn = Value::wrap(); + | ^^^^^^ +... +LL | let _ = var_fn.clone(); + | ----- type must be known at this point + | +help: consider giving `var_fn` an explicit type, where the placeholders `_` are specified + | +LL | let var_fn: Value> = Value::wrap(); + | ++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/binop/binop-mul-i32-f32.stderr b/tests/ui/binop/binop-mul-i32-f32.stderr index c986bc3fd..115e70006 100644 --- a/tests/ui/binop/binop-mul-i32-f32.stderr +++ b/tests/ui/binop/binop-mul-i32-f32.stderr @@ -6,10 +6,10 @@ LL | x * y | = help: the trait `Mul` is not implemented for `i32` = help: the following other types implement trait `Mul`: + + > <&'a i32 as Mul> <&i32 as Mul<&i32>> - > - error: aborting due to previous error diff --git a/tests/ui/binop/shift-various-bad-types.stderr b/tests/ui/binop/shift-various-bad-types.stderr index 38db66f86..b43672ef3 100644 --- a/tests/ui/binop/shift-various-bad-types.stderr +++ b/tests/ui/binop/shift-various-bad-types.stderr @@ -6,14 +6,14 @@ LL | 22 >> p.char; | = help: the trait `Shr` is not implemented for `{integer}` = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> + + > + > + > + > + > + > + > and 568 others error[E0277]: no implementation for `{integer} >> &str` @@ -24,14 +24,14 @@ LL | 22 >> p.str; | = help: the trait `Shr<&str>` is not implemented for `{integer}` = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> + + > + > + > + > + > + > + > and 568 others error[E0277]: no implementation for `{integer} >> &Panolpy` @@ -42,14 +42,14 @@ LL | 22 >> p; | = help: the trait `Shr<&Panolpy>` is not implemented for `{integer}` = help: the following other types implement trait `Shr`: - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> - <&'a i128 as Shr> + + > + > + > + > + > + > + > and 568 others error[E0308]: mismatched types diff --git a/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr b/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr index 26453b42f..2f397f6b5 100644 --- a/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr +++ b/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr @@ -4,7 +4,7 @@ error[E0712]: thread-local variable borrowed past end of function LL | assert_static(&FOO); | ^^^^ thread-local variables cannot be borrowed beyond the end of the function LL | } - | - end of enclosing function is here + | - end of enclosing function is here error: aborting due to previous error diff --git a/tests/ui/borrowck/issue-111554.rs b/tests/ui/borrowck/issue-111554.rs new file mode 100644 index 000000000..0dad55be3 --- /dev/null +++ b/tests/ui/borrowck/issue-111554.rs @@ -0,0 +1,28 @@ +struct Foo {} + +impl Foo { + pub fn foo(&mut self) { + || bar(&mut self); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable + } + + pub fn baz(&self) { + || bar(&mut self); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable + //~| ERROR cannot borrow data in a `&` reference as mutable + } + + pub fn qux(mut self) { + || bar(&mut self); + // OK + } + + pub fn quux(self) { + || bar(&mut self); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable + } +} + +fn bar(_: &mut Foo) {} + +fn main() {} diff --git a/tests/ui/borrowck/issue-111554.stderr b/tests/ui/borrowck/issue-111554.stderr new file mode 100644 index 000000000..6b7a42e49 --- /dev/null +++ b/tests/ui/borrowck/issue-111554.stderr @@ -0,0 +1,29 @@ +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-111554.rs:5:16 + | +LL | || bar(&mut self); + | ^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-111554.rs:10:16 + | +LL | || bar(&mut self); + | ^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/issue-111554.rs:10:16 + | +LL | || bar(&mut self); + | ^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-111554.rs:21:16 + | +LL | pub fn quux(self) { + | ---- help: consider changing this to be mutable: `mut self` +LL | || bar(&mut self); + | ^^^^^^^^^ cannot borrow as mutable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib.rs b/tests/ui/cfg/auxiliary/cfg_false_lib.rs index 3c011d72b..6c2dbb44d 100644 --- a/tests/ui/cfg/auxiliary/cfg_false_lib.rs +++ b/tests/ui/cfg/auxiliary/cfg_false_lib.rs @@ -1,6 +1,4 @@ -// It is unclear whether a fully unconfigured crate should link to standard library, -// or what its `no_std`/`no_core`/`compiler_builtins` status, more precisely. -// Currently the usual standard library prelude is added to such crates, -// and therefore they link to libstd. +// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. +// This crate has no such attribute, therefore this crate does link to libstd. #![cfg(FALSE)] diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs new file mode 100644 index 000000000..3cfa6c510 --- /dev/null +++ b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_after.rs @@ -0,0 +1,5 @@ +// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. +// Therefore this crate does link to libstd. + +#![cfg(FALSE)] +#![no_std] diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs new file mode 100644 index 000000000..8e89545b8 --- /dev/null +++ b/tests/ui/cfg/auxiliary/cfg_false_lib_no_std_before.rs @@ -0,0 +1,8 @@ +// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. +// Therefore this crate doesn't link to libstd. + +// no-prefer-dynamic + +#![no_std] +#![crate_type = "lib"] +#![cfg(FALSE)] diff --git a/tests/ui/cfg/auxiliary/cfged_out.rs b/tests/ui/cfg/auxiliary/cfged_out.rs new file mode 100644 index 000000000..f6a9089cf --- /dev/null +++ b/tests/ui/cfg/auxiliary/cfged_out.rs @@ -0,0 +1,22 @@ +pub mod inner { + #[cfg(FALSE)] + pub fn uwu() {} + + #[cfg(FALSE)] + pub mod doesnt_exist { + pub fn hello() {} + } + + pub mod wrong { + #[cfg(feature = "suggesting me fails the test!!")] + pub fn meow() {} + } + + pub mod right { + #[cfg(feature = "what-a-cool-feature")] + pub fn meow() {} + } +} + +#[cfg(i_dont_exist_and_you_can_do_nothing_about_it)] +pub fn vanished() {} diff --git a/tests/ui/cfg/cfg-false-feature.rs b/tests/ui/cfg/cfg-false-feature.rs index 21ea3ec79..84c231562 100644 --- a/tests/ui/cfg/cfg-false-feature.rs +++ b/tests/ui/cfg/cfg-false-feature.rs @@ -1,5 +1,4 @@ -// It is unclear which features should be in effect in a fully unconfigured crate (issue #104633). -// Currently none on the features are in effect, so we get the feature gates reported. +// Features above `cfg(FALSE)` are in effect in a fully unconfigured crate (issue #104633). // check-pass // compile-flags: --crate-type lib @@ -8,8 +7,7 @@ #![cfg(FALSE)] #![feature(box_syntax)] -macro mac() {} //~ WARN `macro` is experimental - //~| WARN unstable syntax can change at any point in the future +macro mac() {} // OK trait A = Clone; //~ WARN trait aliases are experimental //~| WARN unstable syntax can change at any point in the future diff --git a/tests/ui/cfg/cfg-false-feature.stderr b/tests/ui/cfg/cfg-false-feature.stderr index 14673fbdb..340930362 100644 --- a/tests/ui/cfg/cfg-false-feature.stderr +++ b/tests/ui/cfg/cfg-false-feature.stderr @@ -1,5 +1,5 @@ warning: trait aliases are experimental - --> $DIR/cfg-false-feature.rs:14:1 + --> $DIR/cfg-false-feature.rs:12:1 | LL | trait A = Clone; | ^^^^^^^^^^^^^^^^ @@ -9,19 +9,8 @@ LL | trait A = Clone; = warning: unstable syntax can change at any point in the future, causing a hard error! = note: for more information, see issue #65860 -warning: `macro` is experimental - --> $DIR/cfg-false-feature.rs:11:1 - | -LL | macro mac() {} - | ^^^^^^^^^^^^^^ - | - = note: see issue #39412 for more information - = help: add `#![feature(decl_macro)]` to the crate attributes to enable - = warning: unstable syntax can change at any point in the future, causing a hard error! - = note: for more information, see issue #65860 - warning: box pattern syntax is experimental - --> $DIR/cfg-false-feature.rs:18:9 + --> $DIR/cfg-false-feature.rs:16:9 | LL | let box _ = Box::new(0); | ^^^^^ @@ -31,5 +20,5 @@ LL | let box _ = Box::new(0); = warning: unstable syntax can change at any point in the future, causing a hard error! = note: for more information, see issue #65860 -warning: 3 warnings emitted +warning: 2 warnings emitted diff --git a/tests/ui/cfg/cfg_false_no_std-1.rs b/tests/ui/cfg/cfg_false_no_std-1.rs new file mode 100644 index 000000000..bcb49e513 --- /dev/null +++ b/tests/ui/cfg/cfg_false_no_std-1.rs @@ -0,0 +1,10 @@ +// No error, panic handler is supplied by libstd linked though the empty library. + +// check-pass +// aux-build: cfg_false_lib_no_std_after.rs + +#![no_std] + +extern crate cfg_false_lib_no_std_after as _; + +fn main() {} diff --git a/tests/ui/cfg/cfg_false_no_std-2.rs b/tests/ui/cfg/cfg_false_no_std-2.rs new file mode 100644 index 000000000..0a2bfd5f6 --- /dev/null +++ b/tests/ui/cfg/cfg_false_no_std-2.rs @@ -0,0 +1,11 @@ +// Error, the linked empty library is `no_std` and doesn't provide a panic handler. + +// dont-check-compiler-stderr +// error-pattern: `#[panic_handler]` function required, but not found +// aux-build: cfg_false_lib_no_std_before.rs + +#![no_std] + +extern crate cfg_false_lib_no_std_before as _; + +fn main() {} diff --git a/tests/ui/cfg/cfg_false_no_std.rs b/tests/ui/cfg/cfg_false_no_std.rs index 319ea0781..4fa831715 100644 --- a/tests/ui/cfg/cfg_false_no_std.rs +++ b/tests/ui/cfg/cfg_false_no_std.rs @@ -1,5 +1,4 @@ -// Currently no error because the panic handler is supplied by libstd linked though the empty -// library, but the desirable behavior is unclear (see comments in cfg_false_lib.rs). +// No error, panic handler is supplied by libstd linked though the empty library. // check-pass // aux-build: cfg_false_lib.rs diff --git a/tests/ui/cfg/cfg_stmt_expr.rs b/tests/ui/cfg/cfg_stmt_expr.rs index 6381bb2d5..f9f4c9810 100644 --- a/tests/ui/cfg/cfg_stmt_expr.rs +++ b/tests/ui/cfg/cfg_stmt_expr.rs @@ -81,7 +81,7 @@ fn main() { // check that lints work #[allow(non_snake_case)] - let FOOBAR = { + let FOOBAR: () = { fn SYLADEX() {} }; diff --git a/tests/ui/cfg/diagnostics-cross-crate.rs b/tests/ui/cfg/diagnostics-cross-crate.rs new file mode 100644 index 000000000..d2725c94b --- /dev/null +++ b/tests/ui/cfg/diagnostics-cross-crate.rs @@ -0,0 +1,31 @@ +// aux-build:cfged_out.rs + +extern crate cfged_out; + +fn main() { + // There is no uwu at this path - no diagnostic. + cfged_out::uwu(); //~ ERROR cannot find function + //~^ NOTE not found in `cfged_out` + + // It does exist here - diagnostic. + cfged_out::inner::uwu(); //~ ERROR cannot find function + //~^ NOTE found an item that was configured out + //~| NOTE not found in `cfged_out::inner` + + // The module isn't found - we would like to get a diagnostic, but currently don't due to + // the awkward way the resolver diagnostics are currently implemented. + // FIXME(Nilstrieb): Also add a note to the cfg diagnostic here + cfged_out::inner::doesnt_exist::hello(); //~ ERROR failed to resolve + //~^ NOTE could not find `doesnt_exist` in `inner` + + // It should find the one in the right module, not the wrong one. + cfged_out::inner::right::meow(); //~ ERROR cannot find function + //~^ NOTE found an item that was configured out + //~| NOTE not found in `cfged_out::inner::right + //~| NOTE the item is gated behind the `what-a-cool-feature` feature + + // Exists in the crate root - diagnostic. + cfged_out::vanished(); //~ ERROR cannot find function + //~^ NOTE found an item that was configured out + //~| NOTE not found in `cfged_out` +} diff --git a/tests/ui/cfg/diagnostics-cross-crate.stderr b/tests/ui/cfg/diagnostics-cross-crate.stderr new file mode 100644 index 000000000..046929bc2 --- /dev/null +++ b/tests/ui/cfg/diagnostics-cross-crate.stderr @@ -0,0 +1,53 @@ +error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` + --> $DIR/diagnostics-cross-crate.rs:18:23 + | +LL | cfged_out::inner::doesnt_exist::hello(); + | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` + +error[E0425]: cannot find function `uwu` in crate `cfged_out` + --> $DIR/diagnostics-cross-crate.rs:7:16 + | +LL | cfged_out::uwu(); + | ^^^ not found in `cfged_out` + +error[E0425]: cannot find function `uwu` in module `cfged_out::inner` + --> $DIR/diagnostics-cross-crate.rs:11:23 + | +LL | cfged_out::inner::uwu(); + | ^^^ not found in `cfged_out::inner` + | +note: found an item that was configured out + --> $DIR/auxiliary/cfged_out.rs:3:12 + | +LL | pub fn uwu() {} + | ^^^ + +error[E0425]: cannot find function `meow` in module `cfged_out::inner::right` + --> $DIR/diagnostics-cross-crate.rs:22:30 + | +LL | cfged_out::inner::right::meow(); + | ^^^^ not found in `cfged_out::inner::right` + | +note: found an item that was configured out + --> $DIR/auxiliary/cfged_out.rs:17:16 + | +LL | pub fn meow() {} + | ^^^^ + = note: the item is gated behind the `what-a-cool-feature` feature + +error[E0425]: cannot find function `vanished` in crate `cfged_out` + --> $DIR/diagnostics-cross-crate.rs:28:16 + | +LL | cfged_out::vanished(); + | ^^^^^^^^ not found in `cfged_out` + | +note: found an item that was configured out + --> $DIR/auxiliary/cfged_out.rs:22:8 + | +LL | pub fn vanished() {} + | ^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/cfg/diagnostics-not-a-def.rs b/tests/ui/cfg/diagnostics-not-a-def.rs new file mode 100644 index 000000000..729394712 --- /dev/null +++ b/tests/ui/cfg/diagnostics-not-a-def.rs @@ -0,0 +1,12 @@ +pub mod inner { + pub fn i_am_here() { + #[cfg(feature = "another one that doesn't exist")] + loop {} + } +} + +fn main() { + inner::i_am_here(); + // ensure that nothing bad happens when we are checking for cfgs + inner::i_am_not(); //~ ERROR cannot find function +} diff --git a/tests/ui/cfg/diagnostics-not-a-def.stderr b/tests/ui/cfg/diagnostics-not-a-def.stderr new file mode 100644 index 000000000..af0e1a172 --- /dev/null +++ b/tests/ui/cfg/diagnostics-not-a-def.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `i_am_not` in module `inner` + --> $DIR/diagnostics-not-a-def.rs:11:12 + | +LL | inner::i_am_not(); + | ^^^^^^^^ not found in `inner` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/cfg/diagnostics-reexport.rs b/tests/ui/cfg/diagnostics-reexport.rs new file mode 100644 index 000000000..b9548e911 --- /dev/null +++ b/tests/ui/cfg/diagnostics-reexport.rs @@ -0,0 +1,40 @@ +pub mod inner { + #[cfg(FALSE)] + mod gone { + pub fn uwu() {} + } + + #[cfg(FALSE)] + pub use super::uwu; + //~^ NOTE found an item that was configured out +} + +pub use a::x; +//~^ ERROR unresolved import `a::x` +//~| NOTE no `x` in `a` + +mod a { + #[cfg(no)] + pub fn x() {} + //~^ NOTE found an item that was configured out +} + +pub use b::{x, y}; +//~^ ERROR unresolved imports `b::x`, `b::y` +//~| NOTE no `x` in `b` +//~| NOTE no `y` in `b` + +mod b { + #[cfg(no)] + pub fn x() {} + //~^ NOTE found an item that was configured out + #[cfg(no)] + pub fn y() {} + //~^ NOTE found an item that was configured out +} + +fn main() { + // There is no uwu at this path - no diagnostic. + inner::uwu(); //~ ERROR cannot find function + //~^ NOTE not found in `inner` +} diff --git a/tests/ui/cfg/diagnostics-reexport.stderr b/tests/ui/cfg/diagnostics-reexport.stderr new file mode 100644 index 000000000..e25b7cf86 --- /dev/null +++ b/tests/ui/cfg/diagnostics-reexport.stderr @@ -0,0 +1,47 @@ +error[E0432]: unresolved import `a::x` + --> $DIR/diagnostics-reexport.rs:12:9 + | +LL | pub use a::x; + | ^^^^ no `x` in `a` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:18:12 + | +LL | pub fn x() {} + | ^ + +error[E0432]: unresolved imports `b::x`, `b::y` + --> $DIR/diagnostics-reexport.rs:22:13 + | +LL | pub use b::{x, y}; + | ^ ^ no `y` in `b` + | | + | no `x` in `b` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:29:12 + | +LL | pub fn x() {} + | ^ +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:32:12 + | +LL | pub fn y() {} + | ^ + +error[E0425]: cannot find function `uwu` in module `inner` + --> $DIR/diagnostics-reexport.rs:38:12 + | +LL | inner::uwu(); + | ^^^ not found in `inner` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:8:20 + | +LL | pub use super::uwu; + | ^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0425, E0432. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/cfg/diagnostics-same-crate.rs b/tests/ui/cfg/diagnostics-same-crate.rs new file mode 100644 index 000000000..f76ace06a --- /dev/null +++ b/tests/ui/cfg/diagnostics-same-crate.rs @@ -0,0 +1,51 @@ +pub mod inner { + #[cfg(FALSE)] + pub fn uwu() {} + //~^ NOTE found an item that was configured out + + #[cfg(FALSE)] + pub mod doesnt_exist { + pub fn hello() {} + } + + pub mod wrong { + #[cfg(feature = "suggesting me fails the test!!")] + pub fn meow() {} + } + + pub mod right { + #[cfg(feature = "what-a-cool-feature")] + pub fn meow() {} + //~^ NOTE found an item that was configured out + } +} + +#[cfg(i_dont_exist_and_you_can_do_nothing_about_it)] +pub fn vanished() {} + +fn main() { + // There is no uwu at this path - no diagnostic. + uwu(); //~ ERROR cannot find function + //~^ NOTE not found in this scope + + // It does exist here - diagnostic. + inner::uwu(); //~ ERROR cannot find function + //~| NOTE not found in `inner` + + // The module isn't found - we would like to get a diagnostic, but currently don't due to + // the awkward way the resolver diagnostics are currently implemented. + // FIXME(Nilstrieb): Also add a note to the cfg diagnostic here + inner::doesnt_exist::hello(); //~ ERROR failed to resolve + //~| NOTE could not find `doesnt_exist` in `inner` + + // It should find the one in the right module, not the wrong one. + inner::right::meow(); //~ ERROR cannot find function + //~| NOTE not found in `inner::right + //~| NOTE the item is gated behind the `what-a-cool-feature` feature + + // Exists in the crate root - we would generally want a diagnostic, + // but currently don't have one. + // Not that it matters much though, this is highly unlikely to confuse anyone. + vanished(); //~ ERROR cannot find function + //~^ NOTE not found in this scope +} diff --git a/tests/ui/cfg/diagnostics-same-crate.stderr b/tests/ui/cfg/diagnostics-same-crate.stderr new file mode 100644 index 000000000..30ee6479b --- /dev/null +++ b/tests/ui/cfg/diagnostics-same-crate.stderr @@ -0,0 +1,47 @@ +error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` + --> $DIR/diagnostics-same-crate.rs:38:12 + | +LL | inner::doesnt_exist::hello(); + | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` + +error[E0425]: cannot find function `uwu` in module `inner` + --> $DIR/diagnostics-same-crate.rs:32:12 + | +LL | inner::uwu(); + | ^^^ not found in `inner` + | +note: found an item that was configured out + --> $DIR/diagnostics-same-crate.rs:3:12 + | +LL | pub fn uwu() {} + | ^^^ + +error[E0425]: cannot find function `meow` in module `inner::right` + --> $DIR/diagnostics-same-crate.rs:42:19 + | +LL | inner::right::meow(); + | ^^^^ not found in `inner::right` + | +note: found an item that was configured out + --> $DIR/diagnostics-same-crate.rs:18:16 + | +LL | pub fn meow() {} + | ^^^^ + = note: the item is gated behind the `what-a-cool-feature` feature + +error[E0425]: cannot find function `uwu` in this scope + --> $DIR/diagnostics-same-crate.rs:28:5 + | +LL | uwu(); + | ^^^ not found in this scope + +error[E0425]: cannot find function `vanished` in this scope + --> $DIR/diagnostics-same-crate.rs:49:5 + | +LL | vanished(); + | ^^^^^^^^ not found in this scope + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/chalkify/arithmetic.rs b/tests/ui/chalkify/arithmetic.rs deleted file mode 100644 index 6c78a71b0..000000000 --- a/tests/ui/chalkify/arithmetic.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -fn main() { - 1 + 2; - 3 * 6; - 2 - 5; - 17 / 6; - 23 % 11; - 4 & 6; - 7 | 15; - 4 << 7; - 123 >> 3; - 1 == 2; - 5 != 5; - 6 < 2; - 7 > 11; - 3 <= 1; - 9 >= 14; -} diff --git a/tests/ui/chalkify/assert.rs b/tests/ui/chalkify/assert.rs deleted file mode 100644 index 834c8935e..000000000 --- a/tests/ui/chalkify/assert.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -fn main() { - assert_eq!(1, 1); -} diff --git a/tests/ui/chalkify/basic.rs b/tests/ui/chalkify/basic.rs deleted file mode 100644 index 4a7cd9396..000000000 --- a/tests/ui/chalkify/basic.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo {} - -struct Bar {} - -impl Foo for Bar {} - -fn main() -> () { - let _ = Bar {}; -} diff --git a/tests/ui/chalkify/bugs/async.rs b/tests/ui/chalkify/bugs/async.rs deleted file mode 100644 index a1ef4732b..000000000 --- a/tests/ui/chalkify/bugs/async.rs +++ /dev/null @@ -1,25 +0,0 @@ -// edition:2021 -// known-bug: unknown -// unset-rustc-env:RUST_BACKTRACE -// compile-flags:-Z trait-solver=chalk -// error-pattern:internal compiler error -// failure-status:101 -// 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" - -fn main() -> () {} - -async fn foo(x: u32) -> u32 { - x -} diff --git a/tests/ui/chalkify/bugs/async.stderr b/tests/ui/chalkify/bugs/async.stderr deleted file mode 100644 index 7e64e67f2..000000000 --- a/tests/ui/chalkify/bugs/async.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: `[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future - --> $DIR/async.rs:23:25 - | -LL | async fn foo(x: u32) -> u32 { - | ^^^ `[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future - | - = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:23:29: 25:2]` - = note: [async fn body@$DIR/async.rs:23:29: 25:2] must be a future or must implement `IntoFuture` to be awaited - -error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:23:29: 25:2]], def_id: ... }, Term::Ty(u32)), []), depth=0)` - --> $DIR/async.rs:23:25 - | -LL | async fn foo(x: u32) -> u32 { - | ^^^query stack during panic: -#0 [typeck] type-checking `foo` -#1 [thir_body] building THIR for `foo` -#2 [check_match] match-checking `foo` -#3 [mir_built] building MIR for `foo` -#4 [unsafety_check_result] unsafety-checking `foo` -#5 [mir_const] preparing `foo` for borrow checking -#6 [mir_promoted] promoting constants in MIR for `foo` -#7 [mir_borrowck] borrow-checking `foo` -#8 [type_of] computing type of `foo::{opaque#0}` -#9 [check_mod_item_types] checking item types in top-level module -#10 [analysis] running analysis passes on this crate -end of query stack -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/chalkify/builtin-copy-clone.rs b/tests/ui/chalkify/builtin-copy-clone.rs deleted file mode 100644 index a478c006e..000000000 --- a/tests/ui/chalkify/builtin-copy-clone.rs +++ /dev/null @@ -1,45 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -// Test that `Clone` is correctly implemented for builtin types. - -#[derive(Copy, Clone)] -struct S(#[allow(unused_tuple_struct_fields)] i32); - -fn test_clone(arg: T) { - let _ = arg.clone(); -} - -fn test_copy(arg: T) { - let _ = arg; - let _ = arg; -} - -fn test_copy_clone(arg: T) { - test_copy(arg); - test_clone(arg); -} - -fn foo() { } - -fn main() { - // FIXME: add closures when they're considered WF - test_copy_clone(foo); - let f: fn() = foo; - test_copy_clone(f); - // FIXME(#86252): reinstate array test after chalk upgrade - //test_copy_clone([1; 56]); - test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); - test_copy_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, true, 'a', 1.1)); - test_copy_clone(()); - test_copy_clone(((1, 1), (1, 1, 1), (1.1, 1, 1, 'a'), ())); - - let a = ( - (S(1), S(0)), - ( - (S(0), S(0), S(1)), - S(0) - ) - ); - test_copy_clone(a); -} diff --git a/tests/ui/chalkify/chalk_initial_program.rs b/tests/ui/chalkify/chalk_initial_program.rs deleted file mode 100644 index 21de72b6f..000000000 --- a/tests/ui/chalkify/chalk_initial_program.rs +++ /dev/null @@ -1,16 +0,0 @@ -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -impl Foo for i32 { } - -impl Foo for u32 { } - -fn gimme() { } - -// Note: this also tests that `std::process::Termination` is implemented for `()`. -fn main() { - gimme::(); - gimme::(); - gimme::(); //~ERROR the trait bound `f32: Foo` is not satisfied -} diff --git a/tests/ui/chalkify/chalk_initial_program.stderr b/tests/ui/chalkify/chalk_initial_program.stderr deleted file mode 100644 index 343c0a318..000000000 --- a/tests/ui/chalkify/chalk_initial_program.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/chalk_initial_program.rs:15:13 - | -LL | gimme::(); - | ^^^ the trait `Foo` is not implemented for `f32` - | - = help: the following other types implement trait `Foo`: - i32 - u32 -note: required by a bound in `gimme` - --> $DIR/chalk_initial_program.rs:9:13 - | -LL | fn gimme() { } - | ^^^ required by this bound in `gimme` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/chalkify/closure.rs b/tests/ui/chalkify/closure.rs deleted file mode 100644 index a908a1e97..000000000 --- a/tests/ui/chalkify/closure.rs +++ /dev/null @@ -1,38 +0,0 @@ -// compile-flags: -Z trait-solver=chalk - -fn main() -> () { - let t = || {}; - t(); - - let mut a = 0; - let mut b = move || { - a = 1; - }; - b(); - - let mut c = b; - - c(); - b(); - - let mut a = 0; - let mut b = || { - a = 1; - }; - b(); - - let mut c = b; - - c(); - b(); //~ ERROR - - // FIXME(chalk): this doesn't quite work - /* - let b = |c| { - c - }; - - let a = &32; - b(a); - */ -} diff --git a/tests/ui/chalkify/closure.stderr b/tests/ui/chalkify/closure.stderr deleted file mode 100644 index a33c0ba0d..000000000 --- a/tests/ui/chalkify/closure.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0382]: borrow of moved value: `b` - --> $DIR/closure.rs:27:5 - | -LL | let mut c = b; - | - value moved here -... -LL | b(); - | ^ value borrowed here after move - | -note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment - --> $DIR/closure.rs:20:9 - | -LL | a = 1; - | ^ -help: consider mutably borrowing `b` - | -LL | let mut c = &mut b; - | ++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/chalkify/generic_impls.rs b/tests/ui/chalkify/generic_impls.rs deleted file mode 100644 index 7d33e12d8..000000000 --- a/tests/ui/chalkify/generic_impls.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -impl Foo for (T, u32) { } - -fn gimme() { } - -fn foo() { - gimme::<(T, u32)>(); - gimme::<(Option, u32)>(); - gimme::<(Option, f32)>(); //~ ERROR -} - -fn main() { - gimme::<(i32, u32)>(); - gimme::<(i32, f32)>(); //~ ERROR -} diff --git a/tests/ui/chalkify/generic_impls.stderr b/tests/ui/chalkify/generic_impls.stderr deleted file mode 100644 index d4a8354d3..000000000 --- a/tests/ui/chalkify/generic_impls.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: the trait bound `(Option, f32): Foo` is not satisfied - --> $DIR/generic_impls.rs:12:13 - | -LL | gimme::<(Option, f32)>(); - | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(Option, f32)` - | - = help: the trait `Foo` is implemented for `(T, u32)` -note: required by a bound in `gimme` - --> $DIR/generic_impls.rs:7:13 - | -LL | fn gimme() { } - | ^^^ required by this bound in `gimme` - -error[E0277]: the trait bound `(i32, f32): Foo` is not satisfied - --> $DIR/generic_impls.rs:17:13 - | -LL | gimme::<(i32, f32)>(); - | ^^^^^^^^^^ the trait `Foo` is not implemented for `(i32, f32)` - | - = help: the trait `Foo` is implemented for `(T, u32)` -note: required by a bound in `gimme` - --> $DIR/generic_impls.rs:7:13 - | -LL | fn gimme() { } - | ^^^ required by this bound in `gimme` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/chalkify/impl_wf.rs b/tests/ui/chalkify/impl_wf.rs deleted file mode 100644 index c8dfd4c3a..000000000 --- a/tests/ui/chalkify/impl_wf.rs +++ /dev/null @@ -1,26 +0,0 @@ -// compile-flags: -Z trait-solver=chalk - -trait Foo: Sized { } - -trait Bar { - type Item: Foo; -} - -impl Foo for i32 { } - -impl Foo for str { } -//~^ ERROR the size for values of type `str` cannot be known at compilation time - - -// Implicit `T: Sized` bound. -impl Foo for Option { } - -trait Baz where U: Foo { } - -impl Baz for i32 { } - -impl Baz for f32 { } -//~^ ERROR the trait bound `f32: Foo` is not satisfied - -fn main() { -} diff --git a/tests/ui/chalkify/impl_wf.stderr b/tests/ui/chalkify/impl_wf.stderr deleted file mode 100644 index 84c32fa37..000000000 --- a/tests/ui/chalkify/impl_wf.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/impl_wf.rs:11:14 - | -LL | impl Foo for str { } - | ^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `Foo` - --> $DIR/impl_wf.rs:3:12 - | -LL | trait Foo: Sized { } - | ^^^^^ required by this bound in `Foo` - -error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/impl_wf.rs:22:19 - | -LL | impl Baz for f32 { } - | ^^^ the trait `Foo` is not implemented for `f32` - | - = help: the trait `Foo` is implemented for `i32` -note: required by a bound in `Baz` - --> $DIR/impl_wf.rs:18:31 - | -LL | trait Baz where U: Foo { } - | ^^^ required by this bound in `Baz` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/chalkify/impl_wf_2.rs b/tests/ui/chalkify/impl_wf_2.rs deleted file mode 100644 index 325044ad6..000000000 --- a/tests/ui/chalkify/impl_wf_2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Split out of impl_wf.rs to work around rust aborting compilation early - -// compile-flags: -Z trait-solver=chalk - -trait Foo: Sized { } - -trait Bar { - type Item: Foo; -} - -impl Foo for i32 { } - -// Implicit `T: Sized` bound. -impl Foo for Option { } - -impl Bar for () { - type Item = i32; -} - -impl Bar for Option { - type Item = Option; -} - -impl Bar for f32 { - type Item = f32; - //~^ ERROR the trait bound `f32: Foo` is not satisfied -} - -trait Baz where U: Foo { } - -impl Baz for i32 { } - -fn main() {} diff --git a/tests/ui/chalkify/impl_wf_2.stderr b/tests/ui/chalkify/impl_wf_2.stderr deleted file mode 100644 index 1c1df644b..000000000 --- a/tests/ui/chalkify/impl_wf_2.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: the trait bound `f32: Foo` is not satisfied - --> $DIR/impl_wf_2.rs:25:17 - | -LL | type Item = f32; - | ^^^ the trait `Foo` is not implemented for `f32` - | - = help: the trait `Foo` is implemented for `i32` -note: required by a bound in `Bar::Item` - --> $DIR/impl_wf_2.rs:8:16 - | -LL | type Item: Foo; - | ^^^ required by this bound in `Bar::Item` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/chalkify/inherent_impl.rs b/tests/ui/chalkify/inherent_impl.rs deleted file mode 100644 index f0f24d485..000000000 --- a/tests/ui/chalkify/inherent_impl.rs +++ /dev/null @@ -1,42 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -impl Foo for i32 { } - -struct S { - x: T, -} - -fn only_foo(_x: &T) { } - -impl S { - // Test that we have the correct environment inside an inherent method. - fn dummy_foo(&self) { - only_foo(&self.x) - } -} - -trait Bar { } -impl Bar for u32 { } - -fn only_bar() { } - -impl S { - // Test that the environment of `dummy_bar` adds up with the environment - // of the inherent impl. - fn dummy_bar(&self) { - only_foo(&self.x); - only_bar::(); - } -} - -fn main() { - let s = S { - x: 5, - }; - - s.dummy_bar::(); - s.dummy_foo(); -} diff --git a/tests/ui/chalkify/inherent_impl_min.rs b/tests/ui/chalkify/inherent_impl_min.rs deleted file mode 100644 index 3eda7102d..000000000 --- a/tests/ui/chalkify/inherent_impl_min.rs +++ /dev/null @@ -1,27 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -impl Foo for i32 { } - -struct S { - x: T, -} - -fn only_foo(_x: &T) { } - -impl S { - // Test that we have the correct environment inside an inherent method. - fn dummy_foo(&self) { - only_foo(&self.x) - } -} - -fn main() { - let s = S { - x: 5, - }; - - s.dummy_foo(); -} diff --git a/tests/ui/chalkify/lower_env1.rs b/tests/ui/chalkify/lower_env1.rs deleted file mode 100644 index c8762001e..000000000 --- a/tests/ui/chalkify/lower_env1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -#![allow(dead_code)] - -trait Foo { } - -trait Bar where Self: Foo { } - -fn bar() { -} - -fn main() { -} diff --git a/tests/ui/chalkify/lower_env2.rs b/tests/ui/chalkify/lower_env2.rs deleted file mode 100644 index 7d4f81f12..000000000 --- a/tests/ui/chalkify/lower_env2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -#![allow(dead_code)] - -trait Foo { } - -struct S<'a, T: ?Sized> where T: Foo { - data: &'a T, -} - -fn bar(_x: S<'_, T>) { // note that we have an implicit `T: Sized` bound -} - -fn main() { -} diff --git a/tests/ui/chalkify/lower_env3.rs b/tests/ui/chalkify/lower_env3.rs deleted file mode 100644 index 5b70c4abb..000000000 --- a/tests/ui/chalkify/lower_env3.rs +++ /dev/null @@ -1,16 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -#![allow(dead_code)] - -trait Foo { - fn foo(&self); -} - -impl Foo for T where T: Clone { - fn foo(&self) { - } -} - -fn main() { -} diff --git a/tests/ui/chalkify/lower_impl.rs b/tests/ui/chalkify/lower_impl.rs deleted file mode 100644 index 6f79b3ba3..000000000 --- a/tests/ui/chalkify/lower_impl.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -impl Foo for T where T: Iterator { } - -trait Bar { - type Assoc; -} - -impl Bar for T where T: Iterator { - type Assoc = Vec; -} - -fn main() { -} diff --git a/tests/ui/chalkify/lower_struct.rs b/tests/ui/chalkify/lower_struct.rs deleted file mode 100644 index 6be0d4dd5..000000000 --- a/tests/ui/chalkify/lower_struct.rs +++ /dev/null @@ -1,8 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -struct Foo<'a, T> where Box: Clone { - _x: std::marker::PhantomData<&'a T>, -} - -fn main() { } diff --git a/tests/ui/chalkify/lower_trait.rs b/tests/ui/chalkify/lower_trait.rs deleted file mode 100644 index 8f5b35822..000000000 --- a/tests/ui/chalkify/lower_trait.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -trait Bar { } - -trait Foo { - type Assoc: Bar + ?Sized; -} - -fn main() { -} diff --git a/tests/ui/chalkify/lower_trait_higher_rank.rs b/tests/ui/chalkify/lower_trait_higher_rank.rs deleted file mode 100644 index f04a1deea..000000000 --- a/tests/ui/chalkify/lower_trait_higher_rank.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8 -{ -} - -fn main() { -} diff --git a/tests/ui/chalkify/lower_trait_where_clause.rs b/tests/ui/chalkify/lower_trait_where_clause.rs deleted file mode 100644 index a21d2f319..000000000 --- a/tests/ui/chalkify/lower_trait_where_clause.rs +++ /dev/null @@ -1,16 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -use std::borrow::Borrow; - -trait Foo<'a, 'b, T, U> -where - T: Borrow + ?Sized, - U: ?Sized + 'b, - 'a: 'b, - Box:, // NOTE(#53696) this checks an empty list of bounds. -{ -} - -fn main() { -} diff --git a/tests/ui/chalkify/println.rs b/tests/ui/chalkify/println.rs deleted file mode 100644 index edddc3821..000000000 --- a/tests/ui/chalkify/println.rs +++ /dev/null @@ -1,6 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -fn main() { - println!("hello"); -} diff --git a/tests/ui/chalkify/projection.rs b/tests/ui/chalkify/projection.rs deleted file mode 100644 index 19bb2ae14..000000000 --- a/tests/ui/chalkify/projection.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -trait Bar { - type Item: Foo; -} - -impl Foo for i32 { } -impl Bar for i32 { - type Item = i32; -} - -fn only_foo() { } - -fn only_bar() { - // `T` implements `Bar` hence `::Item` must also implement `Bar` - only_foo::() -} - -fn main() { - only_bar::(); - only_foo::<::Item>(); -} diff --git a/tests/ui/chalkify/recursive_where_clause_on_type.rs b/tests/ui/chalkify/recursive_where_clause_on_type.rs deleted file mode 100644 index c2c8aa6aa..000000000 --- a/tests/ui/chalkify/recursive_where_clause_on_type.rs +++ /dev/null @@ -1,30 +0,0 @@ -// FIXME(chalk): should fail, see comments -// check-fail -// compile-flags: -Z trait-solver=chalk - -#![feature(trivial_bounds)] - -trait Bar { - fn foo(); -} -trait Foo: Bar { } - -struct S where S: Foo; - -impl Foo for S { -} - -fn bar() { - T::foo(); -} - -fn foo() { - bar::() -} - -fn main() { - // For some reason, the error is duplicated... - - foo::() //~ ERROR the type `S` is not well-formed - //~^ ERROR the type `S` is not well-formed -} diff --git a/tests/ui/chalkify/recursive_where_clause_on_type.stderr b/tests/ui/chalkify/recursive_where_clause_on_type.stderr deleted file mode 100644 index cead5adea..000000000 --- a/tests/ui/chalkify/recursive_where_clause_on_type.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: the type `S` is not well-formed - --> $DIR/recursive_where_clause_on_type.rs:28:11 - | -LL | foo::() - | ^ - -error: the type `S` is not well-formed - --> $DIR/recursive_where_clause_on_type.rs:28:5 - | -LL | foo::() - | ^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/chalkify/super_trait.rs b/tests/ui/chalkify/super_trait.rs deleted file mode 100644 index 540ae51e5..000000000 --- a/tests/ui/chalkify/super_trait.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo { } -trait Bar: Foo { } - -impl Foo for i32 { } -impl Bar for i32 { } - -fn only_foo() { } - -fn only_bar() { - // `T` implements `Bar` hence `T` must also implement `Foo` - only_foo::() -} - -fn main() { - only_bar::() -} diff --git a/tests/ui/chalkify/trait-objects.rs b/tests/ui/chalkify/trait-objects.rs deleted file mode 100644 index 144d9788b..000000000 --- a/tests/ui/chalkify/trait-objects.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// compile-flags: -Z trait-solver=chalk - -use std::fmt::Display; - -fn main() { - let d: &dyn Display = &mut 3; - d.to_string(); - (&d).to_string(); - let f: &dyn Fn(i32) -> _ = &|x| x + x; - f(2); -} diff --git a/tests/ui/chalkify/trait_implied_bound.rs b/tests/ui/chalkify/trait_implied_bound.rs deleted file mode 100644 index f97dbf6b7..000000000 --- a/tests/ui/chalkify/trait_implied_bound.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -trait Foo { } -trait Bar where U: Foo { } - -impl Foo for i32 { } -impl Bar for i32 { } - -fn only_foo() { } - -fn only_bar>() { - only_foo::() -} - -fn main() { - only_bar::() -} diff --git a/tests/ui/chalkify/type_implied_bound.rs b/tests/ui/chalkify/type_implied_bound.rs deleted file mode 100644 index 70f1b4265..000000000 --- a/tests/ui/chalkify/type_implied_bound.rs +++ /dev/null @@ -1,29 +0,0 @@ -// run-pass -// compile-flags: -Z trait-solver=chalk - -trait Eq { } -trait Hash: Eq { } - -impl Eq for i32 { } -impl Hash for i32 { } - -struct Set { - _x: T, -} - -fn only_eq() { } - -fn take_a_set(_: &Set) { - // `Set` is an input type of `take_a_set`, hence we know that - // `T` must implement `Hash`, and we know in turn that `T` must - // implement `Eq`. - only_eq::() -} - -fn main() { - let set = Set { - _x: 5, - }; - - take_a_set(&set); -} diff --git a/tests/ui/chalkify/type_inference.rs b/tests/ui/chalkify/type_inference.rs deleted file mode 100644 index d7167d0dc..000000000 --- a/tests/ui/chalkify/type_inference.rs +++ /dev/null @@ -1,28 +0,0 @@ -// compile-flags: -Z trait-solver=chalk - -trait Foo { } -impl Foo for i32 { } - -trait Bar { } -impl Bar for i32 { } -impl Bar for u32 { } - -fn only_foo(_x: T) { } - -fn only_bar(_x: T) { } - -fn main() { - let x = 5.0; - - // The only type which implements `Foo` is `i32`, so the chalk trait solver - // is expecting a variable of type `i32`. This behavior differs from the - // old-style trait solver. I guess this will change, that's why I'm - // adding that test. - // FIXME(chalk): order of these two errors is non-deterministic, - // so let's just hide one for now - //only_foo(x); // ERROR the trait bound `f64: Foo` is not satisfied - - // Here we have two solutions so we get back the behavior of the old-style - // trait solver. - only_bar(x); //~ ERROR the trait bound `{float}: Bar` is not satisfied -} diff --git a/tests/ui/chalkify/type_inference.stderr b/tests/ui/chalkify/type_inference.stderr deleted file mode 100644 index 508a6dd13..000000000 --- a/tests/ui/chalkify/type_inference.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0277]: the trait bound `{float}: Bar` is not satisfied - --> $DIR/type_inference.rs:27:14 - | -LL | only_bar(x); - | -------- ^ the trait `Bar` is not implemented for `{float}` - | | - | required by a bound introduced by this call - | - = help: the following other types implement trait `Bar`: - i32 - u32 -note: required by a bound in `only_bar` - --> $DIR/type_inference.rs:12:16 - | -LL | fn only_bar(_x: T) { } - | ^^^ required by this bound in `only_bar` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/chalkify/type_wf.rs b/tests/ui/chalkify/type_wf.rs deleted file mode 100644 index 37d2f5ca8..000000000 --- a/tests/ui/chalkify/type_wf.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-fail -// compile-flags: -Z trait-solver=chalk - -trait Foo { } - -struct S { - x: T, -} - -impl Foo for i32 { } -impl Foo for Option { } - -fn main() { - let s = S { - x: 5, - }; - - let s = S { - x: 5.0, //~ ERROR the trait bound `{float}: Foo` is not satisfied - }; - - let s = S { - x: Some(5.0), - }; -} diff --git a/tests/ui/chalkify/type_wf.stderr b/tests/ui/chalkify/type_wf.stderr deleted file mode 100644 index 6e8daf635..000000000 --- a/tests/ui/chalkify/type_wf.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: the trait bound `{float}: Foo` is not satisfied - --> $DIR/type_wf.rs:19:12 - | -LL | x: 5.0, - | ^^^ the trait `Foo` is not implemented for `{float}` - | - = help: the trait `Foo` is implemented for `i32` -note: required by a bound in `S` - --> $DIR/type_wf.rs:6:13 - | -LL | struct S { - | ^^^ required by this bound in `S` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs index 41b09ba03..c3898afa9 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs @@ -87,6 +87,31 @@ fn test_4_should_not_capture_array() { } }; c(); + + // We also do not need to capture an array + // behind a reference (#112607) + let array: &[i32; 3] = &[0; 3]; + let c = #[rustc_capture_analysis] + || { + //~^ First Pass analysis includes: + match array { + [_, _, _] => {} + } + }; + c(); + + // We should still not insert a read if the array is inside an + // irrefutable pattern + struct Foo(T); + let f = &Foo(&[10; 3]); + let c = #[rustc_capture_analysis] + || { + //~^ First Pass analysis includes: + match f { + Foo([_, _, _]) => () + } + }; + c(); } // Testing MultiVariant patterns diff --git a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr index e137af1a0..c3c3f8b84 100644 --- a/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr @@ -109,7 +109,29 @@ LL | | }; | |_____^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:105:5 + --> $DIR/patterns-capture-analysis.rs:95:5 + | +LL | / || { +LL | | +LL | | match array { +LL | | [_, _, _] => {} +LL | | } +LL | | }; + | |_____^ + +error: First Pass analysis includes: + --> $DIR/patterns-capture-analysis.rs:108:5 + | +LL | / || { +LL | | +LL | | match f { +LL | | Foo([_, _, _]) => () +LL | | } +LL | | }; + | |_____^ + +error: First Pass analysis includes: + --> $DIR/patterns-capture-analysis.rs:130:5 | LL | / || { LL | | @@ -121,13 +143,13 @@ LL | | }; | |_____^ | note: Capturing variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:108:15 + --> $DIR/patterns-capture-analysis.rs:133:15 | LL | match variant { | ^^^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:105:5 + --> $DIR/patterns-capture-analysis.rs:130:5 | LL | / || { LL | | @@ -139,13 +161,13 @@ LL | | }; | |_____^ | note: Min Capture variant[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:108:15 + --> $DIR/patterns-capture-analysis.rs:133:15 | LL | match variant { | ^^^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:123:5 + --> $DIR/patterns-capture-analysis.rs:148:5 | LL | / || { LL | | @@ -157,13 +179,13 @@ LL | | }; | |_____^ | note: Capturing slice[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:126:15 + --> $DIR/patterns-capture-analysis.rs:151:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:123:5 + --> $DIR/patterns-capture-analysis.rs:148:5 | LL | / || { LL | | @@ -175,13 +197,13 @@ LL | | }; | |_____^ | note: Min Capture slice[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:126:15 + --> $DIR/patterns-capture-analysis.rs:151:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:135:5 + --> $DIR/patterns-capture-analysis.rs:160:5 | LL | / || { LL | | @@ -193,13 +215,13 @@ LL | | }; | |_____^ | note: Capturing slice[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:138:15 + --> $DIR/patterns-capture-analysis.rs:163:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:135:5 + --> $DIR/patterns-capture-analysis.rs:160:5 | LL | / || { LL | | @@ -211,13 +233,13 @@ LL | | }; | |_____^ | note: Min Capture slice[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:138:15 + --> $DIR/patterns-capture-analysis.rs:163:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:147:5 + --> $DIR/patterns-capture-analysis.rs:172:5 | LL | / || { LL | | @@ -229,13 +251,13 @@ LL | | }; | |_____^ | note: Capturing slice[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:150:15 + --> $DIR/patterns-capture-analysis.rs:175:15 | LL | match slice { | ^^^^^ error: Min Capture analysis includes: - --> $DIR/patterns-capture-analysis.rs:147:5 + --> $DIR/patterns-capture-analysis.rs:172:5 | LL | / || { LL | | @@ -247,13 +269,13 @@ LL | | }; | |_____^ | note: Min Capture slice[] -> ImmBorrow - --> $DIR/patterns-capture-analysis.rs:150:15 + --> $DIR/patterns-capture-analysis.rs:175:15 | LL | match slice { | ^^^^^ error: First Pass analysis includes: - --> $DIR/patterns-capture-analysis.rs:164:5 + --> $DIR/patterns-capture-analysis.rs:189:5 | LL | / || { LL | | @@ -264,5 +286,5 @@ LL | | } LL | | }; | |_____^ -error: aborting due to 16 previous errors +error: aborting due to 18 previous errors diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs b/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs index 03400e0ee..6d4cf6fa5 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs @@ -15,7 +15,7 @@ struct Struct { fn main() { let mut s = Struct { x: 10, y: 10, s: String::new() }; - let mut c = { + let mut c = || { s.x += 10; s.y += 42; s.s = String::from("new"); diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs b/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs index d2375aa69..a386e9f40 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/lit-pattern-matching-with-methods.rs @@ -2,7 +2,7 @@ //check-pass #![warn(unused)] #![feature(rustc_attrs)] -#![feature(btree_drain_filter)] +#![feature(btree_extract_if)] use std::collections::BTreeMap; use std::panic::{catch_unwind, AssertUnwindSafe}; @@ -14,14 +14,14 @@ fn main() { map.insert("c", ()); { - let mut it = map.drain_filter(|_, _| true); + let mut it = map.extract_if(|_, _| true); catch_unwind(AssertUnwindSafe(|| while it.next().is_some() {})).unwrap_err(); let result = catch_unwind(AssertUnwindSafe(|| it.next())); assert!(matches!(result, Ok(None))); } { - let mut it = map.drain_filter(|_, _| true); + let mut it = map.extract_if(|_, _| true); catch_unwind(AssertUnwindSafe(|| while let Some(_) = it.next() {})).unwrap_err(); let result = catch_unwind(AssertUnwindSafe(|| it.next())); assert!(matches!(result, Ok(None))); diff --git a/tests/ui/closures/cannot-call-unsized-via-ptr-2.rs b/tests/ui/closures/cannot-call-unsized-via-ptr-2.rs new file mode 100644 index 000000000..2d8565517 --- /dev/null +++ b/tests/ui/closures/cannot-call-unsized-via-ptr-2.rs @@ -0,0 +1,11 @@ +#![feature(unsized_fn_params)] + +fn main() { + // CoerceMany "LUB" + let f = if true { |_a| {} } else { |_b| {} }; + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + //~| ERROR the size for values of type `[u8]` cannot be known at compilation time + + let slice: Box<[u8]> = Box::new([1; 8]); + f(*slice); +} diff --git a/tests/ui/closures/cannot-call-unsized-via-ptr-2.stderr b/tests/ui/closures/cannot-call-unsized-via-ptr-2.stderr new file mode 100644 index 000000000..d88b84365 --- /dev/null +++ b/tests/ui/closures/cannot-call-unsized-via-ptr-2.stderr @@ -0,0 +1,21 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/cannot-call-unsized-via-ptr-2.rs:5:24 + | +LL | let f = if true { |_a| {} } else { |_b| {} }; + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all function arguments must have a statically known size + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/cannot-call-unsized-via-ptr-2.rs:5:41 + | +LL | let f = if true { |_a| {} } else { |_b| {} }; + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all function arguments must have a statically known size + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/cannot-call-unsized-via-ptr.rs b/tests/ui/closures/cannot-call-unsized-via-ptr.rs new file mode 100644 index 000000000..5ce4650b0 --- /dev/null +++ b/tests/ui/closures/cannot-call-unsized-via-ptr.rs @@ -0,0 +1,10 @@ +#![feature(unsized_fn_params)] + +fn main() { + // Simple coercion + let f: fn([u8]) = |_result| {}; + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + + let slice: Box<[u8]> = Box::new([1; 8]); + f(*slice); +} diff --git a/tests/ui/closures/cannot-call-unsized-via-ptr.stderr b/tests/ui/closures/cannot-call-unsized-via-ptr.stderr new file mode 100644 index 000000000..9ecc66d5c --- /dev/null +++ b/tests/ui/closures/cannot-call-unsized-via-ptr.stderr @@ -0,0 +1,12 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/cannot-call-unsized-via-ptr.rs:5:24 + | +LL | let f: fn([u8]) = |_result| {}; + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all function arguments must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/closure-move-sync.rs b/tests/ui/closures/closure-move-sync.rs index ea2d1434c..3ee2b35f5 100644 --- a/tests/ui/closures/closure-move-sync.rs +++ b/tests/ui/closures/closure-move-sync.rs @@ -13,10 +13,4 @@ fn bar() { t.join().unwrap(); } -fn foo() { - let (tx, _rx) = channel(); - thread::spawn(|| tx.send(()).unwrap()); - //~^ ERROR `Sender<()>` cannot be shared between threads safely -} - fn main() {} diff --git a/tests/ui/closures/closure-move-sync.stderr b/tests/ui/closures/closure-move-sync.stderr index 64e3b51ea..aee903ac9 100644 --- a/tests/ui/closures/closure-move-sync.stderr +++ b/tests/ui/closures/closure-move-sync.stderr @@ -20,24 +20,6 @@ LL | let t = thread::spawn(|| { note: required by a bound in `spawn` --> $SRC_DIR/std/src/thread/mod.rs:LL:COL -error[E0277]: `Sender<()>` cannot be shared between threads safely - --> $DIR/closure-move-sync.rs:18:19 - | -LL | thread::spawn(|| tx.send(()).unwrap()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^ `Sender<()>` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `Sender<()>` - = note: required for `&Sender<()>` to implement `Send` -note: required because it's used within this closure - --> $DIR/closure-move-sync.rs:18:19 - | -LL | thread::spawn(|| tx.send(()).unwrap()); - | ^^ -note: required by a bound in `spawn` - --> $SRC_DIR/std/src/thread/mod.rs:LL:COL - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/issue-111932.rs b/tests/ui/closures/issue-111932.rs new file mode 100644 index 000000000..eb3fe08cb --- /dev/null +++ b/tests/ui/closures/issue-111932.rs @@ -0,0 +1,9 @@ +trait Foo: std::fmt::Debug {} + +fn print_foos(foos: impl Iterator) { + foos.for_each(|foo| { //~ ERROR [E0277] + println!("{:?}", foo); //~ ERROR [E0277] + }); +} + +fn main() {} diff --git a/tests/ui/closures/issue-111932.stderr b/tests/ui/closures/issue-111932.stderr new file mode 100644 index 000000000..937bdf3be --- /dev/null +++ b/tests/ui/closures/issue-111932.stderr @@ -0,0 +1,26 @@ +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/issue-111932.rs:4:20 + | +LL | foos.for_each(|foo| { + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = note: all function arguments must have a statically known size + = help: unsized fn params are gated as an unstable feature + +error[E0277]: the size for values of type `dyn Foo` cannot be known at compilation time + --> $DIR/issue-111932.rs:5:26 + | +LL | println!("{:?}", foo); + | ---- ^^^ doesn't have a size known at compile-time + | | + | required by a bound introduced by this call + | + = help: the trait `Sized` is not implemented for `dyn Foo` +note: required by a bound in `core::fmt::rt::Argument::<'a>::new_debug` + --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/issue-113087.rs b/tests/ui/closures/issue-113087.rs new file mode 100644 index 000000000..a4edc2f2f --- /dev/null +++ b/tests/ui/closures/issue-113087.rs @@ -0,0 +1,11 @@ +fn some_fn<'a>(_: &'a i32, _: impl FnOnce(&'a i32)) {} + +fn main() { + let some_closure = |_| {}; + + for a in [1] { + some_fn(&a, |c| { //~ ERROR does not live long enough + some_closure(c); + }); + } +} diff --git a/tests/ui/closures/issue-113087.stderr b/tests/ui/closures/issue-113087.stderr new file mode 100644 index 000000000..8ccef4a54 --- /dev/null +++ b/tests/ui/closures/issue-113087.stderr @@ -0,0 +1,16 @@ +error[E0597]: `a` does not live long enough + --> $DIR/issue-113087.rs:7:17 + | +LL | for a in [1] { + | - binding `a` declared here +LL | some_fn(&a, |c| { + | ^^ borrowed value does not live long enough +LL | some_closure(c); + | ------------ borrow later captured here by closure +LL | }); +LL | } + | - `a` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/closures/issue-72408-nested-closures-exponential.rs b/tests/ui/closures/issue-72408-nested-closures-exponential.rs index 2d6ba9365..d064ebcef 100644 --- a/tests/ui/closures/issue-72408-nested-closures-exponential.rs +++ b/tests/ui/closures/issue-72408-nested-closures-exponential.rs @@ -1,4 +1,5 @@ // build-pass +// ignore-compare-mode-next-solver (hangs) // Closures include captured types twice in a type tree. // diff --git a/tests/ui/codegen/subtyping-enforces-type-equality.rs b/tests/ui/codegen/subtyping-enforces-type-equality.rs new file mode 100644 index 000000000..a5ffcb3f8 --- /dev/null +++ b/tests/ui/codegen/subtyping-enforces-type-equality.rs @@ -0,0 +1,48 @@ +// ignore-pass +// build-pass +// edition:2021 +use std::future::Future; +use std::pin::Pin; + +type BoxFuture = Pin>>; + +fn main() { + let _ = wrapper_call(handler); +} + +async fn wrapper_call(handler: impl Handler) { + handler.call().await; +} +async fn handler() { + f(&()).await; +} +async fn f<'a>(db: impl Acquire<'a>) { + db.acquire().await; +} + +trait Handler { + type Future: Future; + fn call(self) -> Self::Future; +} + +impl Handler for F +where + F: Fn() -> Fut, + Fut: Future, +{ + type Future = Fut; + fn call(self) -> Self::Future { + loop {} + } +} + +trait Acquire<'a> { + type Connection; + fn acquire(self) -> BoxFuture; +} +impl<'a> Acquire<'a> for &'a () { + type Connection = Self; + fn acquire(self) -> BoxFuture { + loop {} + } +} diff --git a/tests/ui/codegen/subtyping-enforces-type-equality.stderr b/tests/ui/codegen/subtyping-enforces-type-equality.stderr new file mode 100644 index 000000000..870ca0f83 --- /dev/null +++ b/tests/ui/codegen/subtyping-enforces-type-equality.stderr @@ -0,0 +1 @@ +WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type. See the issues/114858 diff --git a/tests/ui/codegen/subtyping-impacts-selection-1.rs b/tests/ui/codegen/subtyping-impacts-selection-1.rs new file mode 100644 index 000000000..09e06f6d6 --- /dev/null +++ b/tests/ui/codegen/subtyping-impacts-selection-1.rs @@ -0,0 +1,44 @@ +// run-pass +// revisions: mir codegen +//[mir] compile-flags: -Zmir-opt-level=3 +//[codegen] compile-flags: -Zmir-opt-level=0 + +// A regression test for #107205 +#![allow(coherence_leak_check)] +struct Foo(T); + +fn useful<'a>(_: &'a u8) {} + +trait GetInner { + type Assoc; + fn muahaha(&mut self) -> Self::Assoc; +} + +impl GetInner for Foo { + type Assoc = String; + fn muahaha(&mut self) -> String { + String::from("I am a string") + } +} + +impl GetInner for Foo fn(&'a u8)> { + type Assoc = [usize; 3]; + fn muahaha(&mut self) -> [usize; 3] { + [100; 3] + } +} + +fn break_me(hr_fnptr: Box fn(&'a u8)>>) -> Box> { + let lr_fnptr = hr_fnptr as Box>; + lr_fnptr as Box> +} + +fn main() { + drop(Box::new(Foo(useful as fn(&'static u8))) as Box>); + drop(Box::new(Foo(useful as fn(&u8))) as Box>); + + let mut any = break_me(Box::new(Foo(useful))); + + let evil_string = any.muahaha(); + assert_eq!(evil_string, "I am a string"); +} diff --git a/tests/ui/codegen/subtyping-impacts-selection-2.rs b/tests/ui/codegen/subtyping-impacts-selection-2.rs new file mode 100644 index 000000000..921136775 --- /dev/null +++ b/tests/ui/codegen/subtyping-impacts-selection-2.rs @@ -0,0 +1,12 @@ +// run-pass +// revisions: mir codegen +//[mir] compile-flags: -Zmir-opt-level=3 +//[codegen] compile-flags: -Zmir-opt-level=0 + +// A regression test for #107205 + +const X: for<'b> fn(&'b ()) = |&()| (); +fn main() { + let dyn_debug = Box::new(X) as Box as Box; + drop(dyn_debug) +} diff --git a/tests/ui/coercion/issue-3794.rs b/tests/ui/coercion/issue-3794.rs new file mode 100644 index 000000000..b1f028fbc --- /dev/null +++ b/tests/ui/coercion/issue-3794.rs @@ -0,0 +1,32 @@ +// run-pass +#![allow(dead_code)] + +trait T { + fn print(&self); +} + +#[derive(Debug)] +struct S { + s: isize, +} + +impl T for S { + fn print(&self) { + println!("{:?}", self); + } +} + +fn print_t(t: &dyn T) { + t.print(); +} + +fn print_s(s: &S) { + s.print(); +} + +pub fn main() { + let s: Box = Box::new(S { s: 5 }); + print_s(&*s); + let t: Box = s as Box; + print_t(&*t); +} diff --git a/tests/ui/coherence/coherence-inherited-subtyping.old.stderr b/tests/ui/coherence/coherence-inherited-subtyping.old.stderr deleted file mode 100644 index 4701bc0b1..000000000 --- a/tests/ui/coherence/coherence-inherited-subtyping.old.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0592]: duplicate definitions with name `method1` - --> $DIR/coherence-inherited-subtyping.rs:14:5 - | -LL | fn method1(&self) {} - | ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1` -... -LL | fn method1(&self) {} - | ----------------- other definition for `method1` - | - = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0592`. diff --git a/tests/ui/coherence/coherence-inherited-subtyping.re.stderr b/tests/ui/coherence/coherence-inherited-subtyping.re.stderr deleted file mode 100644 index 4701bc0b1..000000000 --- a/tests/ui/coherence/coherence-inherited-subtyping.re.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0592]: duplicate definitions with name `method1` - --> $DIR/coherence-inherited-subtyping.rs:14:5 - | -LL | fn method1(&self) {} - | ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1` -... -LL | fn method1(&self) {} - | ----------------- other definition for `method1` - | - = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0592`. diff --git a/tests/ui/coherence/coherence-inherited-subtyping.rs b/tests/ui/coherence/coherence-inherited-subtyping.rs index 8587eb779..f35cd2103 100644 --- a/tests/ui/coherence/coherence-inherited-subtyping.rs +++ b/tests/ui/coherence/coherence-inherited-subtyping.rs @@ -4,8 +4,6 @@ // Note: This scenario is currently accepted, but as part of the // universe transition (#56105) may eventually become an error. -// revisions: old re - struct Foo { t: T, } diff --git a/tests/ui/coherence/coherence-inherited-subtyping.stderr b/tests/ui/coherence/coherence-inherited-subtyping.stderr new file mode 100644 index 000000000..f60b2aa27 --- /dev/null +++ b/tests/ui/coherence/coherence-inherited-subtyping.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `method1` + --> $DIR/coherence-inherited-subtyping.rs:12:5 + | +LL | fn method1(&self) {} + | ^^^^^^^^^^^^^^^^^ duplicate definitions for `method1` +... +LL | fn method1(&self) {} + | ----------------- other definition for `method1` + | + = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/tests/ui/coinduction/canonicalization-rerun.rs b/tests/ui/coinduction/canonicalization-rerun.rs index b10ba3a81..c68895fc4 100644 --- a/tests/ui/coinduction/canonicalization-rerun.rs +++ b/tests/ui/coinduction/canonicalization-rerun.rs @@ -1,6 +1,6 @@ // check-pass -// revisions: old new -//[new] compile-flags: -Ztrait-solver=next +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next // If we use canonical goals during trait solving we have to reevaluate // the root goal of a cycle until we hit a fixpoint. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr index de5704ee4..48910b82a 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr @@ -11,6 +11,10 @@ note: required by a bound in `check` | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: use parentheses to call this function + | +LL | check(main()); + | ++ error[E0277]: `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:8:11 @@ -25,6 +29,10 @@ note: required by a bound in `check` | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: use parentheses to call this closure + | +LL | check(|| {}()); + | ++ error[E0277]: `fn()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:9:11 @@ -39,6 +47,10 @@ note: required by a bound in `check` | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: use parentheses to call this function pointer + | +LL | check(main as fn()()); + | ++ error[E0277]: `&mut ()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:10:11 @@ -48,11 +60,17 @@ LL | check(&mut ()); | | | required by a bound introduced by this call | + = note: `ConstParamTy` is implemented for `&()`, but not for `&mut ()` note: required by a bound in `check` --> $DIR/const_param_ty_bad.rs:4:18 | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: consider removing the leading `&`-reference + | +LL - check(&mut ()); +LL + check(()); + | error[E0277]: `*mut ()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:11:11 @@ -62,6 +80,7 @@ LL | check(&mut () as *mut ()); | | | required by a bound introduced by this call | + = help: the trait `ConstParamTy` is implemented for `()` note: required by a bound in `check` --> $DIR/const_param_ty_bad.rs:4:18 | @@ -76,6 +95,7 @@ LL | check(&() as *const ()); | | | required by a bound introduced by this call | + = help: the trait `ConstParamTy` is implemented for `()` note: required by a bound in `check` --> $DIR/const_param_ty_bad.rs:4:18 | diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs index 87ae83dd9..100ab332a 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs @@ -49,5 +49,7 @@ fn main() { check::>(); check::>(); - // FIXME: test tuples + check::<()>(); + check::<(i32,)>(); + check::<(D, D)>(); } diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs index 37986de48..08f7c5cb5 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs @@ -9,9 +9,11 @@ struct CantParam(ImplementsConstParamTy); impl std::marker::ConstParamTy for CantParam {} //~^ error: the type `CantParam` does not `#[derive(Eq)]` +//~| error: the type `CantParam` does not `#[derive(PartialEq)]` #[derive(std::marker::ConstParamTy)] //~^ error: the type `CantParamDerive` does not `#[derive(Eq)]` +//~| error: the type `CantParamDerive` does not `#[derive(PartialEq)]` struct CantParamDerive(ImplementsConstParamTy); fn check() {} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr index 52701d559..43c5b96dc 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr @@ -1,3 +1,12 @@ +error[E0277]: the type `CantParam` does not `#[derive(PartialEq)]` + --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 + | +LL | impl std::marker::ConstParamTy for CantParam {} + | ^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParam` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + error[E0277]: the type `CantParam` does not `#[derive(Eq)]` --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 | @@ -7,8 +16,18 @@ LL | impl std::marker::ConstParamTy for CantParam {} note: required by a bound in `ConstParamTy` --> $SRC_DIR/core/src/marker.rs:LL:COL +error[E0277]: the type `CantParamDerive` does not `#[derive(PartialEq)]` + --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 + | +LL | #[derive(std::marker::ConstParamTy)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParamDerive` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0277]: the type `CantParamDerive` does not `#[derive(Eq)]` - --> $DIR/const_param_ty_impl_no_structural_eq.rs:13:10 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 | LL | #[derive(std::marker::ConstParamTy)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParamDerive` @@ -17,6 +36,6 @@ note: required by a bound in `ConstParamTy` --> $SRC_DIR/core/src/marker.rs:LL:COL = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs index d70377a20..c04e96c56 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs @@ -14,6 +14,7 @@ impl Eq for Union {} impl std::marker::StructuralEq for Union {} impl std::marker::ConstParamTy for Union {} +//~^ ERROR the type `Union` does not `#[derive(PartialEq)]` #[derive(std::marker::ConstParamTy)] //~^ ERROR this trait cannot be derived for unions diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr index 293703046..985b933c4 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr @@ -1,8 +1,18 @@ error: this trait cannot be derived for unions - --> $DIR/const_param_ty_impl_union.rs:18:10 + --> $DIR/const_param_ty_impl_union.rs:19:10 | LL | #[derive(std::marker::ConstParamTy)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0277]: the type `Union` does not `#[derive(PartialEq)]` + --> $DIR/const_param_ty_impl_union.rs:16:36 + | +LL | impl std::marker::ConstParamTy for Union {} + | ^^^^^ the trait `StructuralPartialEq` is not implemented for `Union` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/const-argument-if-length.full.stderr b/tests/ui/const-generics/const-argument-if-length.full.stderr index 2ceba59cf..7997026df 100644 --- a/tests/ui/const-generics/const-argument-if-length.full.stderr +++ b/tests/ui/const-generics/const-argument-if-length.full.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/const-argument-if-length.rs:15:12 | LL | pub struct AtLeastByte { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | value: T, | ^ doesn't have a size known at compile-time | diff --git a/tests/ui/const-generics/const-argument-if-length.min.stderr b/tests/ui/const-generics/const-argument-if-length.min.stderr index f85e60f63..3ba9ffebd 100644 --- a/tests/ui/const-generics/const-argument-if-length.min.stderr +++ b/tests/ui/const-generics/const-argument-if-length.min.stderr @@ -11,7 +11,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/const-argument-if-length.rs:15:12 | LL | pub struct AtLeastByte { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | value: T, | ^ doesn't have a size known at compile-time | diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr index 938fb08b7..e508890dd 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr @@ -6,16 +6,6 @@ LL | pub struct Dependent([(); X]); | = note: type parameters may not be used in the type of const parameters -error[E0392]: parameter `T` is never used - --> $DIR/const-param-type-depends-on-type-param.rs:11:22 - | -LL | pub struct Dependent([(); X]); - | ^ unused parameter - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - = help: if you intended `T` to be a const parameter, use `const T: usize` instead - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0392, E0770. -For more information about an error, try `rustc --explain E0392`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr index 938fb08b7..e508890dd 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr @@ -6,16 +6,6 @@ LL | pub struct Dependent([(); X]); | = note: type parameters may not be used in the type of const parameters -error[E0392]: parameter `T` is never used - --> $DIR/const-param-type-depends-on-type-param.rs:11:22 - | -LL | pub struct Dependent([(); X]); - | ^ unused parameter - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - = help: if you intended `T` to be a const parameter, use `const T: usize` instead - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0392, E0770. -For more information about an error, try `rustc --explain E0392`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.rs b/tests/ui/const-generics/const-param-type-depends-on-type-param.rs index 71d91fd7e..fc3aa9cbc 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.rs +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.rs @@ -10,6 +10,5 @@ pub struct Dependent([(); X]); //~^ ERROR: the type of const parameters must not depend on other generic parameters -//~| ERROR: parameter `T` is never used fn main() {} diff --git a/tests/ui/const-generics/const-param-with-additional-obligations.rs b/tests/ui/const-generics/const-param-with-additional-obligations.rs new file mode 100644 index 000000000..f53cf85cd --- /dev/null +++ b/tests/ui/const-generics/const-param-with-additional-obligations.rs @@ -0,0 +1,17 @@ +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +#[derive(Eq, PartialEq)] +struct Foo(T); + +trait Other {} + +impl ConstParamTy for Foo where T: Other + ConstParamTy {} + +fn foo>() {} +//~^ ERROR `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter +//~| NOTE `u8` must implement `Other`, but it does not + +fn main() {} diff --git a/tests/ui/const-generics/const-param-with-additional-obligations.stderr b/tests/ui/const-generics/const-param-with-additional-obligations.stderr new file mode 100644 index 000000000..f7ec4d574 --- /dev/null +++ b/tests/ui/const-generics/const-param-with-additional-obligations.stderr @@ -0,0 +1,11 @@ +error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-param-with-additional-obligations.rs:13:17 + | +LL | fn foo>() {} + | ^^^^^^^ + | + = note: `u8` must implement `Other`, but it does not + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr new file mode 100644 index 000000000..4259ce2b6 --- /dev/null +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/default-param-wf-concrete.rs:4:28 + | +LL | struct Foo; + | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr new file mode 100644 index 000000000..4259ce2b6 --- /dev/null +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/default-param-wf-concrete.rs:4:28 + | +LL | struct Foo; + | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs index 41a52c7eb..09a00dd8e 100644 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.rs +++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.rs @@ -1,3 +1,6 @@ +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next + struct Foo; //~^ ERROR evaluation of constant value failed fn main() {} diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.stderr deleted file mode 100644 index e8ebddade..000000000 --- a/tests/ui/const-generics/defaults/default-param-wf-concrete.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/default-param-wf-concrete.rs:1:28 - | -LL | struct Foo; - | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/const-generics/exhaustive-value.stderr b/tests/ui/const-generics/exhaustive-value.stderr index 76a83ba67..4a26e0977 100644 --- a/tests/ui/const-generics/exhaustive-value.stderr +++ b/tests/ui/const-generics/exhaustive-value.stderr @@ -6,13 +6,13 @@ LL | <() as Foo>::test() | = help: the following other types implement trait `Foo`: <() as Foo<0>> - <() as Foo<100>> - <() as Foo<101>> - <() as Foo<102>> - <() as Foo<103>> - <() as Foo<104>> - <() as Foo<105>> - <() as Foo<106>> + <() as Foo<1>> + <() as Foo<2>> + <() as Foo<3>> + <() as Foo<4>> + <() as Foo<5>> + <() as Foo<6>> + <() as Foo<7>> and 248 others error: aborting due to previous error diff --git a/tests/ui/const-generics/float-generic.adt_const_params.stderr b/tests/ui/const-generics/float-generic.adt_const_params.stderr index fef5ef0d1..6fe539047 100644 --- a/tests/ui/const-generics/float-generic.adt_const_params.stderr +++ b/tests/ui/const-generics/float-generic.adt_const_params.stderr @@ -3,8 +3,6 @@ error[E0741]: `f32` is forbidden as the type of a const generic parameter | LL | fn foo() {} | ^^^ - | - = note: floats do not derive `Eq` or `Ord`, which are required for const parameters error: aborting due to previous error diff --git a/tests/ui/const-generics/forbid-non-structural_match-types.rs b/tests/ui/const-generics/forbid-non-structural_match-types.rs index 6ae9d5cfb..4fec2a9f3 100644 --- a/tests/ui/const-generics/forbid-non-structural_match-types.rs +++ b/tests/ui/const-generics/forbid-non-structural_match-types.rs @@ -1,13 +1,15 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] struct A; struct B; // ok struct C; -struct D; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]` +struct D; //~ ERROR `C` must implement `ConstParamTy` to be used as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/forbid-non-structural_match-types.stderr b/tests/ui/const-generics/forbid-non-structural_match-types.stderr index 81b9bdfbd..0efb9e9d3 100644 --- a/tests/ui/const-generics/forbid-non-structural_match-types.stderr +++ b/tests/ui/const-generics/forbid-non-structural_match-types.stderr @@ -1,8 +1,14 @@ -error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/forbid-non-structural_match-types.rs:11:19 +error[E0741]: `C` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/forbid-non-structural_match-types.rs:13:19 | LL | struct D; - | ^ `C` doesn't derive both `PartialEq` and `Eq` + | ^ + | +help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct + | +LL + #[derive(ConstParamTy, PartialEq, Eq)] +LL | struct C; + | error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_arg_infer/in-signature.rs b/tests/ui/const-generics/generic_arg_infer/in-signature.rs index 1f60b2242..cd852a269 100644 --- a/tests/ui/const-generics/generic_arg_infer/in-signature.rs +++ b/tests/ui/const-generics/generic_arg_infer/in-signature.rs @@ -33,15 +33,15 @@ static TY_STATIC_MIXED: Bar<_, _> = Bar::(0); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables trait ArrAssocConst { const ARR: [u8; _]; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } trait TyAssocConst { const ARR: Bar; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } trait TyAssocConstMixed { const ARR: Bar<_, _>; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } trait AssocTy { diff --git a/tests/ui/const-generics/generic_arg_infer/in-signature.stderr b/tests/ui/const-generics/generic_arg_infer/in-signature.stderr index 52d1b29f9..b32018a6a 100644 --- a/tests/ui/const-generics/generic_arg_infer/in-signature.stderr +++ b/tests/ui/const-generics/generic_arg_infer/in-signature.stderr @@ -74,19 +74,19 @@ LL | static TY_STATIC_MIXED: Bar<_, _> = Bar::(0); | not allowed in type signatures | help: replace with the correct type: `Bar` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/in-signature.rs:35:21 | LL | const ARR: [u8; _]; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/in-signature.rs:39:25 | LL | const ARR: Bar; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/in-signature.rs:43:20 | LL | const ARR: Bar<_, _>; diff --git a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr index 13ea4a295..0096d4ee2 100644 --- a/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr +++ b/tests/ui/const-generics/generic_arg_infer/issue-91614.stderr @@ -6,11 +6,11 @@ LL | let y = Mask::<_, _>::splat(false); | = note: cannot satisfy `_: MaskElement` = help: the following types implement trait `MaskElement`: + isize + i8 i16 i32 i64 - i8 - isize note: required by a bound in `Mask::::splat` --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/masks.rs:LL:COL help: consider giving `y` an explicit type, where the type for type parameter `T` is specified diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr index 1d10dfdf1..c478718b4 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr @@ -7,7 +7,7 @@ LL | struct ArithArrayLen([u32; 0 + N]); = help: try adding a `where` bound using this expression: `where [(); 0 + N]:` error: overly complex generic constant - --> $DIR/array-size-in-generic-struct-param.rs:19:15 + --> $DIR/array-size-in-generic-struct-param.rs:23:15 | LL | arr: [u8; CFG.arr_size], | ^^^^^^^^^^^^ field access is not supported in generic constants diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr index 18e9135d0..956e9c9c9 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr @@ -8,7 +8,7 @@ LL | struct ArithArrayLen([u32; 0 + N]); = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/array-size-in-generic-struct-param.rs:19:15 + --> $DIR/array-size-in-generic-struct-param.rs:23:15 | LL | arr: [u8; CFG.arr_size], | ^^^ cannot perform const operation using `CFG` @@ -17,7 +17,7 @@ LL | arr: [u8; CFG.arr_size], = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: `Config` is forbidden as the type of a const generic parameter - --> $DIR/array-size-in-generic-struct-param.rs:17:21 + --> $DIR/array-size-in-generic-struct-param.rs:21:21 | LL | struct B { | ^^^^^^ diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs index 7d3fe413c..33ca6dcb3 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs @@ -9,7 +9,11 @@ struct ArithArrayLen([u32; 0 + N]); //[full]~^ ERROR unconstrained generic constant //[min]~^^ ERROR generic parameters may not be used in const operations +#[cfg(full)] +use std::marker::ConstParamTy; + #[derive(PartialEq, Eq)] +#[cfg_attr(full, derive(ConstParamTy))] struct Config { arr_size: usize, } diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs index 8023b998a..e5464a425 100644 --- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs +++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.rs @@ -1,6 +1,12 @@ #![crate_type = "lib"] #![feature(generic_const_exprs)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] +#![warn(private_interfaces)] + +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. pub struct Const; @@ -15,6 +21,7 @@ where { type AssocTy = Const<{ my_const_fn(U) }>; //~^ ERROR private type + //~| WARNING type `fn(u8) -> u8 {my_const_fn}` is more private than the item ` as Trait>::AssocTy` fn assoc_fn() -> Self::AssocTy { Const } diff --git a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr index 2d9de8805..16fae6b5c 100644 --- a/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr +++ b/tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr @@ -1,5 +1,5 @@ error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface - --> $DIR/eval-privacy.rs:16:5 + --> $DIR/eval-privacy.rs:22:5 | LL | type AssocTy = Const<{ my_const_fn(U) }>; | ^^^^^^^^^^^^ can't leak private type @@ -7,6 +7,23 @@ LL | type AssocTy = Const<{ my_const_fn(U) }>; LL | const fn my_const_fn(val: u8) -> u8 { | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private -error: aborting due to previous error +warning: type `fn(u8) -> u8 {my_const_fn}` is more private than the item ` as Trait>::AssocTy` + --> $DIR/eval-privacy.rs:22:5 + | +LL | type AssocTy = Const<{ my_const_fn(U) }>; + | ^^^^^^^^^^^^ associated type ` as Trait>::AssocTy` is reachable at visibility `pub` + | +note: but type `fn(u8) -> u8 {my_const_fn}` is only usable at visibility `pub(crate)` + --> $DIR/eval-privacy.rs:30:1 + | +LL | const fn my_const_fn(val: u8) -> u8 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/eval-privacy.rs:5:9 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs b/tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs new file mode 100644 index 000000000..d81cba627 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/inline-const-in-const-generic-defaults.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(generic_const_exprs)] +#![feature(inline_const)] +#![allow(incomplete_features)] + +pub struct ConstDefaultUnstable; + +pub fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-109141.rs b/tests/ui/const-generics/generic_const_exprs/issue-109141.rs new file mode 100644 index 000000000..148c3bda8 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/issue-109141.rs @@ -0,0 +1,13 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +impl EntriesBuffer { + fn a(&self) -> impl Iterator { + self.0.iter_mut() //~ ERROR: cannot borrow `*self.0` as mutable, as it is behind a `&` reference + } +} + +struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>); +//~^ ERROR: cannot find value `HashesEntryLEN` in this scope + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr new file mode 100644 index 000000000..f61edd60e --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr @@ -0,0 +1,26 @@ +error[E0425]: cannot find value `HashesEntryLEN` in this scope + --> $DIR/issue-109141.rs:10:32 + | +LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>); + | ^^^^^^^^^^^^^^ not found in this scope + | +help: you might be missing a const parameter + | +LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>); + | ++++++++++++++++++++++++++++++++++ + +error[E0596]: cannot borrow `*self.0` as mutable, as it is behind a `&` reference + --> $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 + | +help: consider changing this to be a mutable reference + | +LL | fn a(&mut self) -> impl Iterator { + | ~~~~~~~~~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0425, E0596. +For more information about an error, try `rustc --explain E0425`. 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 6aa8ee13b..dc3a400cb 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -1,4 +1,4 @@ -error[E0080]: evaluation of `Inline::::{constant#0}` failed +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` @@ -35,7 +35,7 @@ help: consider relaxing the type parameter's implicit `Sized` bound LL | impl Inline | ++++++++ -error[E0080]: evaluation of `Inline::::{constant#0}` failed +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` diff --git a/tests/ui/const-generics/generic_const_exprs/issue-86710.rs b/tests/ui/const-generics/generic_const_exprs/issue-86710.rs index bdd8a21b3..281b12458 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-86710.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-86710.rs @@ -7,7 +7,7 @@ use std::marker::PhantomData; fn main() { let x = FooImpl::> { phantom: PhantomData }; - let _ = x.foo::>(); + x.foo::>(); } trait Foo diff --git a/tests/ui/const-generics/generic_const_exprs/issue-96699.rs b/tests/ui/const-generics/generic_const_exprs/issue-96699.rs new file mode 100644 index 000000000..83f329d2a --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/issue-96699.rs @@ -0,0 +1,87 @@ +// check-pass + +#![allow(dead_code, incomplete_features)] +#![feature(generic_const_exprs)] + +const fn min(a: usize, b: usize) -> usize { + if a < b { + a + } else { + b + } +} + +trait Trait1 +where + Self: Sized, +{ + fn crash_here() + where + Inner1: Default, + { + Inner1::default(); + } +} + +struct Struct1(T); +impl Trait1 for Struct1 {} + +trait Trait2 +where + Self: Sized, +{ + type Assoc: Trait1; + + fn call_crash() + where + Inner2: Default, + { + // if Inner2 implements Default, we can call crash_here. + Self::Assoc::crash_here(); + } +} + +struct Struct2 {} +/* +where + [(); min(SIZE1, SIZE2)]:, +{ + elem: [i32; min(SIZE1, SIZE2)], +} +*/ + +impl Trait2<[i32; min(SIZE1, SIZE2)]> + for Struct2 +{ + type Assoc = Struct1<[i32; min(SIZE1, SIZE2)]>; + // dose Struct1<[i32; min(SIZE1, SIZE2)]> implement Default? +} + +fn main() { + pattern2(); + + print_fully_name( as Trait2<[i32; min(1, 2)]>>::Assoc::crash_here); + // as compiler_bug2::Trait1<[i32; 1]>>::crash_here +} + +fn pattern1() { + // no crash + as Trait2<[i32; min(1, 2)]>>::Assoc::crash_here(); + as Trait2<[i32; min(1, 2)]>>::call_crash(); +} + +fn pattern2() { + // crash + as Trait2<[i32; min(1, 2)]>>::call_crash(); + + // undefined reference to `compiler_bug2::Trait1::crash_here' +} + +fn pattern3() { + // no crash + as Trait2<[i32; min(1, 2)]>>::Assoc::crash_here(); +} + +fn print_fully_name(_: T) { + let _ = std::any::type_name::(); +} diff --git a/tests/ui/const-generics/invalid-enum.rs b/tests/ui/const-generics/invalid-enum.rs index cb6d05349..fcfad300c 100644 --- a/tests/ui/const-generics/invalid-enum.rs +++ b/tests/ui/const-generics/invalid-enum.rs @@ -1,7 +1,9 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] enum CompileFlag { A, B, diff --git a/tests/ui/const-generics/invalid-enum.stderr b/tests/ui/const-generics/invalid-enum.stderr index 0d3643f6f..7e8a632b3 100644 --- a/tests/ui/const-generics/invalid-enum.stderr +++ b/tests/ui/const-generics/invalid-enum.stderr @@ -1,5 +1,5 @@ error[E0573]: expected type, found variant `CompileFlag::A` - --> $DIR/invalid-enum.rs:21:12 + --> $DIR/invalid-enum.rs:23:12 | LL | test_1::(); | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | test_1::(); | help: try using the variant's enum: `CompileFlag` error[E0573]: expected type, found variant `CompileFlag::A` - --> $DIR/invalid-enum.rs:25:15 + --> $DIR/invalid-enum.rs:27:15 | LL | test_2::<_, CompileFlag::A>(0); | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | test_2::<_, CompileFlag::A>(0); | help: try using the variant's enum: `CompileFlag` error[E0573]: expected type, found variant `CompileFlag::A` - --> $DIR/invalid-enum.rs:29:18 + --> $DIR/invalid-enum.rs:31:18 | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _: Example = Example { x: 0 }; | help: try using the variant's enum: `CompileFlag` error[E0747]: unresolved item provided when a constant was expected - --> $DIR/invalid-enum.rs:29:18 + --> $DIR/invalid-enum.rs:31:18 | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | let _: Example<{ CompileFlag::A }, _> = Example { x: 0 }; | + + error[E0747]: type provided when a constant was expected - --> $DIR/invalid-enum.rs:33:18 + --> $DIR/invalid-enum.rs:35:18 | LL | let _: Example = Example { x: 0 }; | ^^^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | let _: Example<{ Example::ASSOC_FLAG }, _> = Example { x: 0 }; | + + error[E0747]: unresolved item provided when a constant was expected - --> $DIR/invalid-enum.rs:21:12 + --> $DIR/invalid-enum.rs:23:12 | LL | test_1::(); | ^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | test_1::<{ CompileFlag::A }>(); | + + error[E0747]: unresolved item provided when a constant was expected - --> $DIR/invalid-enum.rs:25:15 + --> $DIR/invalid-enum.rs:27:15 | LL | test_2::<_, CompileFlag::A>(0); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/issue-112505-overflow.rs b/tests/ui/const-generics/issue-112505-overflow.rs new file mode 100644 index 000000000..0dd7776d5 --- /dev/null +++ b/tests/ui/const-generics/issue-112505-overflow.rs @@ -0,0 +1,7 @@ +#![feature(transmute_generic_consts)] + +fn overflow(v: [[[u32; 8888888]; 9999999]; 777777777]) -> [[[u32; 9999999]; 777777777]; 239] { + unsafe { std::mem::transmute(v) } //~ ERROR cannot transmute between types of different sizes +} + +fn main() { } diff --git a/tests/ui/const-generics/issue-112505-overflow.stderr b/tests/ui/const-generics/issue-112505-overflow.stderr new file mode 100644 index 000000000..bd8a4feef --- /dev/null +++ b/tests/ui/const-generics/issue-112505-overflow.stderr @@ -0,0 +1,12 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/issue-112505-overflow.rs:4:14 + | +LL | unsafe { 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]; 239]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/const-generics/issue-66451.rs b/tests/ui/const-generics/issue-66451.rs index 3335f7d59..c8d5515e9 100644 --- a/tests/ui/const-generics/issue-66451.rs +++ b/tests/ui/const-generics/issue-66451.rs @@ -1,13 +1,15 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(Debug, PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(Debug, PartialEq, Eq, ConstParamTy)] struct Foo { value: i32, nested: &'static Bar, } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, ConstParamTy)] struct Bar(T); struct Test; diff --git a/tests/ui/const-generics/issue-66451.stderr b/tests/ui/const-generics/issue-66451.stderr index e0cb0b661..946d51486 100644 --- a/tests/ui/const-generics/issue-66451.stderr +++ b/tests/ui/const-generics/issue-66451.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-66451.rs:27:10 + --> $DIR/issue-66451.rs:29:10 | LL | let y: Test<{ | ____________- diff --git a/tests/ui/const-generics/issue-80471.rs b/tests/ui/const-generics/issue-80471.rs index d0af8a5ea..fa6f1fde4 100644 --- a/tests/ui/const-generics/issue-80471.rs +++ b/tests/ui/const-generics/issue-80471.rs @@ -8,6 +8,6 @@ enum Nat { } fn foo() {} -//~^ ERROR `Box` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +//~^ ERROR `Nat` must implement `ConstParamTy` to be used as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/issue-80471.stderr b/tests/ui/const-generics/issue-80471.stderr index b89706710..3b7143de5 100644 --- a/tests/ui/const-generics/issue-80471.stderr +++ b/tests/ui/const-generics/issue-80471.stderr @@ -7,11 +7,17 @@ LL | #![feature(adt_const_params)] = note: see issue #95174 for more information = note: `#[warn(incomplete_features)]` on by default -error[E0741]: `Box` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +error[E0741]: `Nat` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/issue-80471.rs:10:17 | LL | fn foo() {} | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | enum Nat { + | error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr index 16fabd1e8..e2d8c5ca0 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr @@ -1,8 +1,10 @@ -error[E0741]: `(dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +error[E0741]: `&'static (dyn A + 'static)` can't be used as a const parameter type --> $DIR/issue-63322-forbid-dyn.rs:9:18 | LL | fn test() { | ^^^^^^^^^^^^^^ + | + = note: `(dyn A + 'static)` must implement `ConstParamTy`, but it does not error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs index 116c3fcfb..8bc35ab3d 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -7,7 +7,7 @@ struct B; impl A for B {} fn test() { - //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //[full]~^ ERROR `&'static (dyn A + 'static)` can't be used as a const parameter type //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden unimplemented!() } diff --git a/tests/ui/const-generics/issues/issue-67185-2.stderr b/tests/ui/const-generics/issues/issue-67185-2.stderr index 032b0c410..a2e5b8053 100644 --- a/tests/ui/const-generics/issues/issue-67185-2.stderr +++ b/tests/ui/const-generics/issues/issue-67185-2.stderr @@ -5,8 +5,8 @@ LL | ::Quaks: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -17,8 +17,8 @@ LL | [::Quaks; 2]: Bar, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable @@ -29,8 +29,8 @@ LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | @@ -47,8 +47,8 @@ LL | impl Foo for FooImpl {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -65,8 +65,8 @@ LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | @@ -83,8 +83,8 @@ LL | fn f(_: impl Foo) {} | ^^^ the trait `Bar` is not implemented for `[u16; 3]` | = help: the following other types implement trait `Bar`: - [[u16; 3]; 3] [u16; 4] + [[u16; 3]; 3] note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | diff --git a/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs b/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs index a76488249..f02ab355f 100644 --- a/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs +++ b/tests/ui/const-generics/issues/issue-70273-assoc-fn.rs @@ -10,5 +10,5 @@ impl T<0usize> for S { } fn main() { - let _err = >::f(); + >::f(); } diff --git a/tests/ui/const-generics/issues/issue-71381.full.stderr b/tests/ui/const-generics/issues/issue-71381.full.stderr index 962eaf75b..b6460e001 100644 --- a/tests/ui/const-generics/issues/issue-71381.full.stderr +++ b/tests/ui/const-generics/issues/issue-71381.full.stderr @@ -14,19 +14,6 @@ LL | const FN: unsafe extern "C" fn(Args), | = note: type parameters may not be used in the type of const parameters -error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:14:61 - | -LL | pub fn call_me(&self) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:23:19 - | -LL | const FN: unsafe extern "C" fn(Args), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0741, E0770. -For more information about an error, try `rustc --explain E0741`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-71381.rs b/tests/ui/const-generics/issues/issue-71381.rs index 66f819dbe..8a878efb4 100644 --- a/tests/ui/const-generics/issues/issue-71381.rs +++ b/tests/ui/const-generics/issues/issue-71381.rs @@ -12,8 +12,8 @@ unsafe extern "C" fn pass(args: PassArg) { impl Test { pub fn call_me(&self) { - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^ ERROR: using function pointers as const generic parameters is forbidden + //~^^ ERROR: the type of const parameters must not depend on other generic parameters self.0 = Self::trampiline:: as _ } @@ -21,8 +21,8 @@ impl Test { Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args), - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^ ERROR: using function pointers as const generic parameters is forbidden + //~^^ ERROR: the type of const parameters must not depend on other generic parameters >( args: Args, ) { @@ -31,6 +31,6 @@ impl Test { } fn main() { - let x = Test(); + let x = Test(std::ptr::null()); x.call_me::() } diff --git a/tests/ui/const-generics/issues/issue-71611.full.stderr b/tests/ui/const-generics/issues/issue-71611.full.stderr index e109459f2..b55f410a0 100644 --- a/tests/ui/const-generics/issues/issue-71611.full.stderr +++ b/tests/ui/const-generics/issues/issue-71611.full.stderr @@ -6,13 +6,6 @@ LL | fn func(outer: A) { | = note: type parameters may not be used in the type of const parameters -error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71611.rs:5:21 - | -LL | fn func(outer: A) { - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0741, E0770. -For more information about an error, try `rustc --explain E0741`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-71611.rs b/tests/ui/const-generics/issues/issue-71611.rs index fbb91ca18..c917f6681 100644 --- a/tests/ui/const-generics/issues/issue-71611.rs +++ b/tests/ui/const-generics/issues/issue-71611.rs @@ -3,8 +3,8 @@ #![cfg_attr(full, allow(incomplete_features))] fn func(outer: A) { - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^ ERROR: using function pointers as const generic parameters is forbidden + //~^^ ERROR: the type of const parameters must not depend on other generic parameters F(outer); } diff --git a/tests/ui/const-generics/issues/issue-74255.min.stderr b/tests/ui/const-generics/issues/issue-74255.min.stderr index b462d8448..bbcf8682b 100644 --- a/tests/ui/const-generics/issues/issue-74255.min.stderr +++ b/tests/ui/const-generics/issues/issue-74255.min.stderr @@ -1,5 +1,5 @@ error: `IceEnum` is forbidden as the type of a const generic parameter - --> $DIR/issue-74255.rs:14:31 + --> $DIR/issue-74255.rs:18:31 | LL | fn ice_struct_fn() {} | ^^^^^^^ diff --git a/tests/ui/const-generics/issues/issue-74255.rs b/tests/ui/const-generics/issues/issue-74255.rs index 0e523926f..60b2fd37c 100644 --- a/tests/ui/const-generics/issues/issue-74255.rs +++ b/tests/ui/const-generics/issues/issue-74255.rs @@ -3,7 +3,11 @@ #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] +#[cfg(full)] +use std::marker::ConstParamTy; + #[derive(PartialEq, Eq)] +#[cfg_attr(full, derive(ConstParamTy))] enum IceEnum { Variant } diff --git a/tests/ui/const-generics/issues/issue-74950.min.stderr b/tests/ui/const-generics/issues/issue-74950.min.stderr index 729ecc202..c37ee93d4 100644 --- a/tests/ui/const-generics/issues/issue-74950.min.stderr +++ b/tests/ui/const-generics/issues/issue-74950.min.stderr @@ -1,5 +1,5 @@ error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer; | ^^^^^ @@ -8,7 +8,7 @@ LL | struct Outer; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer; | ^^^^^ @@ -17,7 +17,7 @@ LL | struct Outer; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer; | ^^^^^ @@ -26,7 +26,7 @@ LL | struct Outer; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer; | ^^^^^ @@ -35,7 +35,7 @@ LL | struct Outer; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer; | ^^^^^ diff --git a/tests/ui/const-generics/issues/issue-74950.rs b/tests/ui/const-generics/issues/issue-74950.rs index 3e1ca4735..43bb32265 100644 --- a/tests/ui/const-generics/issues/issue-74950.rs +++ b/tests/ui/const-generics/issues/issue-74950.rs @@ -3,8 +3,11 @@ #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] +#[cfg(full)] +use std::marker::ConstParamTy; #[derive(PartialEq, Eq)] +#[cfg_attr(full, derive(ConstParamTy))] struct Inner; // Note: We emit the error 5 times if we don't deduplicate: diff --git a/tests/ui/const-generics/issues/issue-87076.rs b/tests/ui/const-generics/issues/issue-87076.rs index 8a567678b..a32c1f965 100644 --- a/tests/ui/const-generics/issues/issue-87076.rs +++ b/tests/ui/const-generics/issues/issue-87076.rs @@ -3,7 +3,9 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] pub struct UnitDims { pub time: u8, pub length: u8, diff --git a/tests/ui/const-generics/issues/issue-97278.rs b/tests/ui/const-generics/issues/issue-97278.rs index da0a9776f..8e7a1fcd9 100644 --- a/tests/ui/const-generics/issues/issue-97278.rs +++ b/tests/ui/const-generics/issues/issue-97278.rs @@ -9,6 +9,6 @@ enum Bar { } fn test() {} -//~^ ERROR `Arc` must be annotated with `#[derive(PartialEq, Eq)]` +//~^ ERROR `Bar` must implement `ConstParamTy` to be used as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/issues/issue-97278.stderr b/tests/ui/const-generics/issues/issue-97278.stderr index ff13cb505..31e92f840 100644 --- a/tests/ui/const-generics/issues/issue-97278.stderr +++ b/tests/ui/const-generics/issues/issue-97278.stderr @@ -1,8 +1,14 @@ -error[E0741]: `Arc` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +error[E0741]: `Bar` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/issue-97278.rs:11:20 | LL | fn test() {} | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | enum Bar { + | error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-99641.rs b/tests/ui/const-generics/issues/issue-99641.rs index fae6d3fc4..dd075a6ad 100644 --- a/tests/ui/const-generics/issues/issue-99641.rs +++ b/tests/ui/const-generics/issues/issue-99641.rs @@ -3,10 +3,10 @@ fn main() { pub struct Color; - //~^ ERROR using function pointers + //~^ ERROR `(fn(),)` can't be used as a const parameter type impl Color { - //~^ ERROR using function pointers + //~^ ERROR `(fn(),)` can't be used as a const parameter type pub fn new() -> Self { Color:: } diff --git a/tests/ui/const-generics/issues/issue-99641.stderr b/tests/ui/const-generics/issues/issue-99641.stderr index 349ebba08..800aec3ef 100644 --- a/tests/ui/const-generics/issues/issue-99641.stderr +++ b/tests/ui/const-generics/issues/issue-99641.stderr @@ -1,14 +1,18 @@ -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `(fn(),)` can't be used as a const parameter type --> $DIR/issue-99641.rs:5:35 | LL | pub struct Color; | ^^^^^^^ + | + = note: `fn()` must implement `ConstParamTy`, but it does not -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `(fn(),)` can't be used as a const parameter type --> $DIR/issue-99641.rs:8:23 | LL | impl Color { | ^^^^^^^ + | + = note: `fn()` must implement `ConstParamTy`, but it does not error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/overlapping_impls.rs b/tests/ui/const-generics/overlapping_impls.rs index e599eadd8..2ce6c4a82 100644 --- a/tests/ui/const-generics/overlapping_impls.rs +++ b/tests/ui/const-generics/overlapping_impls.rs @@ -2,7 +2,8 @@ #![allow(incomplete_features)] #![feature(adt_const_params)] #![feature(generic_const_exprs)] -use std::marker::PhantomData; + +use std::marker::{ConstParamTy, PhantomData}; struct Foo {} @@ -22,7 +23,7 @@ pub struct Foo2 { _marker: PhantomData, } -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, ConstParamTy)] pub enum Protocol { Variant1, Variant2, diff --git a/tests/ui/const-generics/std/const-generics-range.full.stderr b/tests/ui/const-generics/std/const-generics-range.full.stderr new file mode 100644 index 000000000..5bf48ad73 --- /dev/null +++ b/tests/ui/const-generics/std/const-generics-range.full.stderr @@ -0,0 +1,39 @@ +error[E0741]: `std::ops::Range` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:8:24 + | +LL | struct _Range>; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeFrom` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:13:28 + | +LL | struct _RangeFrom>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeFull` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:18:28 + | +LL | struct _RangeFull; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeInclusive` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:24:33 + | +LL | struct _RangeInclusive>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeTo` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:29:26 + | +LL | struct _RangeTo>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeToInclusive` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:34:35 + | +LL | struct _RangeToInclusive>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0741`. diff --git a/tests/ui/const-generics/std/const-generics-range.min.stderr b/tests/ui/const-generics/std/const-generics-range.min.stderr index d4b2ad6fd..53fca6e88 100644 --- a/tests/ui/const-generics/std/const-generics-range.min.stderr +++ b/tests/ui/const-generics/std/const-generics-range.min.stderr @@ -1,5 +1,5 @@ error: `std::ops::Range` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:7:24 + --> $DIR/const-generics-range.rs:8:24 | LL | struct _Range>; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | struct _Range>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeFrom` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:12:28 + --> $DIR/const-generics-range.rs:13:28 | LL | struct _RangeFrom>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | struct _RangeFrom>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeFull` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:17:28 + --> $DIR/const-generics-range.rs:18:28 | LL | struct _RangeFull; | ^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | struct _RangeFull; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeInclusive` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:23:33 + --> $DIR/const-generics-range.rs:24:33 | LL | struct _RangeInclusive>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | struct _RangeInclusive>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeTo` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:28:26 + --> $DIR/const-generics-range.rs:29:26 | LL | struct _RangeTo>; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | struct _RangeTo>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeToInclusive` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:33:35 + --> $DIR/const-generics-range.rs:34:35 | LL | struct _RangeToInclusive>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/std/const-generics-range.rs b/tests/ui/const-generics/std/const-generics-range.rs index 46c06f312..bda59f3ec 100644 --- a/tests/ui/const-generics/std/const-generics-range.rs +++ b/tests/ui/const-generics/std/const-generics-range.rs @@ -1,4 +1,5 @@ -// [full] check-pass +// [full] known-bug: unknown + // revisions: full min #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr index 3d1197afd..9e308620a 100644 --- a/tests/ui/const-generics/transmute-fail.stderr +++ b/tests/ui/const-generics/transmute-fail.stderr @@ -43,8 +43,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- LL | std::mem::transmute(v) | ^^^^^^^^^^^^^^^^^^^ | - = note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[[u32; 8888888]; 9999999]; 777777777]` are too big for the current architecture) - = note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[[u32; 9999999]; 777777777]; 8888888]` are too big for the current architecture) + = 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: aborting due to 6 previous errors diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 817cfb0ac..22c3dfa64 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -54,11 +54,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ 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 = 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[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:30:1 @@ -98,7 +98,7 @@ LL | from_raw_parts(ptr, 1) error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) | note: inside `ptr::const_ptr::::sub_ptr` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -156,11 +156,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 = 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[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:63:1 diff --git a/tests/ui/consts/assoc_const_generic_impl.rs b/tests/ui/consts/assoc_const_generic_impl.rs index 3475c862b..ba358628d 100644 --- a/tests/ui/consts/assoc_const_generic_impl.rs +++ b/tests/ui/consts/assoc_const_generic_impl.rs @@ -8,7 +8,7 @@ trait ZeroSized: Sized { impl ZeroSized for T { const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ ERROR evaluation of `::I_AM_ZERO_SIZED` failed fn requires_zero_size(self) { - let () = Self::I_AM_ZERO_SIZED; + Self::I_AM_ZERO_SIZED; println!("requires_zero_size called"); } } diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr index 05f33c339..06e398edc 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr @@ -12,10 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize]; | = help: the trait `Add` is not implemented for `i8` = help: the following other types implement trait `Add`: + + > <&'a i8 as Add> <&i8 as Add<&i8>> - > - error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr index d019f5920..07ef2ac09 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr @@ -12,10 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize] | = help: the trait `Add` is not implemented for `i8` = help: the following other types implement trait `Add`: + + > <&'a i8 as Add> <&i8 as Add<&i8>> - > - error[E0604]: only `u8` can be cast as `char`, not `i8` --> $DIR/const-eval-overflow-4b.rs:22:13 diff --git a/tests/ui/consts/const-eval/erroneous-const.rs b/tests/ui/consts/const-eval/erroneous-const.rs index e0fd057a2..74d44c525 100644 --- a/tests/ui/consts/const-eval/erroneous-const.rs +++ b/tests/ui/consts/const-eval/erroneous-const.rs @@ -10,7 +10,7 @@ const fn no_codegen() { if false { // This bad constant is only used in dead code in a no-codegen function... and yet we still // must make sure that the build fails. - let _ = PrintName::::VOID; //~ constant + PrintName::::VOID; //~ constant } } diff --git a/tests/ui/consts/const-eval/erroneous-const.stderr b/tests/ui/consts/const-eval/erroneous-const.stderr index 03030392a..770f95062 100644 --- a/tests/ui/consts/const-eval/erroneous-const.stderr +++ b/tests/ui/consts/const-eval/erroneous-const.stderr @@ -5,10 +5,10 @@ LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 note: erroneous constant used - --> $DIR/erroneous-const.rs:13:17 + --> $DIR/erroneous-const.rs:13:13 | -LL | let _ = PrintName::::VOID; - | ^^^^^^^^^^^^^^^^^^^^ +LL | PrintName::::VOID; + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/erroneous-const2.rs b/tests/ui/consts/const-eval/erroneous-const2.rs index 15c0f9107..61f2955f2 100644 --- a/tests/ui/consts/const-eval/erroneous-const2.rs +++ b/tests/ui/consts/const-eval/erroneous-const2.rs @@ -10,7 +10,7 @@ pub static FOO: () = { if false { // This bad constant is only used in dead code in a static initializer... and yet we still // must make sure that the build fails. - let _ = PrintName::::VOID; //~ constant + PrintName::::VOID; //~ constant } }; diff --git a/tests/ui/consts/const-eval/erroneous-const2.stderr b/tests/ui/consts/const-eval/erroneous-const2.stderr index 8626f4d78..082c28765 100644 --- a/tests/ui/consts/const-eval/erroneous-const2.stderr +++ b/tests/ui/consts/const-eval/erroneous-const2.stderr @@ -5,10 +5,10 @@ LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 note: erroneous constant used - --> $DIR/erroneous-const2.rs:13:17 + --> $DIR/erroneous-const2.rs:13:9 | -LL | let _ = PrintName::::VOID; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | PrintName::::VOID; + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 8f3b3d5f7..23ba2c2f5 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/alloc_intrinsic_errors.rs:9:17 | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 | note: inside `foo` --> $DIR/alloc_intrinsic_errors.rs:9:17 diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs index f746f2700..9ae906bbb 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs @@ -4,11 +4,11 @@ use std::intrinsics; const FOO: *const i32 = foo(); -//~^ ERROR untyped pointers are not allowed in constant +//~^ ERROR unsupported untyped pointer in constant const fn foo() -> &'static i32 { let t = unsafe { - let i = intrinsics::const_allocate(4, 4) as * mut i32; + let i = intrinsics::const_allocate(4, 4) as *mut i32; *i = 20; i }; diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr index 00ab0dfc5..2103f842b 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/alloc_intrinsic_nontransient_fail.rs:6:1 | LL | const FOO: *const i32 = foo(); | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs index 77871c394..1354b3c33 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs @@ -3,7 +3,7 @@ #![feature(const_mut_refs)] use std::intrinsics; -const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32}; -//~^ error: untyped pointers are not allowed in constant +const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; +//~^ error: unsupported untyped pointer in constant fn main() {} diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr index 36002b850..b62766473 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/alloc_intrinsic_untyped.rs:6:1 | -LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32}; +LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; | ^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index 650b409b1..4c23957a1 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | LL | intrinsics::const_deallocate(ptr, 4, 3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_deallocate`: 3 is not a power of 2 error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/infinite_loop.rs b/tests/ui/consts/const-eval/infinite_loop.rs index 4babc9a28..217814906 100644 --- a/tests/ui/consts/const-eval/infinite_loop.rs +++ b/tests/ui/consts/const-eval/infinite_loop.rs @@ -4,8 +4,8 @@ fn main() { let _ = [(); { let mut n = 113383; // #20 in https://oeis.org/A006884 while n != 0 { - //~^ ERROR evaluation of constant value failed - n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; + //~^ ERROR is taking a long time + n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; } n }]; diff --git a/tests/ui/consts/const-eval/infinite_loop.stderr b/tests/ui/consts/const-eval/infinite_loop.stderr index f30bfaf3f..f0434a847 100644 --- a/tests/ui/consts/const-eval/infinite_loop.stderr +++ b/tests/ui/consts/const-eval/infinite_loop.stderr @@ -1,12 +1,27 @@ -error[E0080]: evaluation of constant value failed +error: constant evaluation is taking a long time --> $DIR/infinite_loop.rs:6:9 | LL | / while n != 0 { LL | | -LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; +LL | | n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; LL | | } - | |_________^ exceeded interpreter step limit (see `#[const_eval_limit]`) + | |_________^ + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/infinite_loop.rs:4:18 + | +LL | let _ = [(); { + | __________________^ +LL | | let mut n = 113383; // #20 in https://oeis.org/A006884 +LL | | while n != 0 { +LL | | +... | +LL | | n +LL | | }]; + | |_____^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-52475.rs b/tests/ui/consts/const-eval/issue-52475.rs index 307c1a668..ee26d2800 100644 --- a/tests/ui/consts/const-eval/issue-52475.rs +++ b/tests/ui/consts/const-eval/issue-52475.rs @@ -2,7 +2,8 @@ fn main() { let _ = [(); { let mut x = &0; let mut n = 0; - while n < 5 { //~ ERROR evaluation of constant value failed [E0080] + while n < 5 { + //~^ ERROR: constant evaluation is taking a long time n = (n + 1) % 5; x = &0; // Materialize a new AllocId } diff --git a/tests/ui/consts/const-eval/issue-52475.stderr b/tests/ui/consts/const-eval/issue-52475.stderr index 3aa6bd277..ebf9d12a6 100644 --- a/tests/ui/consts/const-eval/issue-52475.stderr +++ b/tests/ui/consts/const-eval/issue-52475.stderr @@ -1,12 +1,28 @@ -error[E0080]: evaluation of constant value failed +error: constant evaluation is taking a long time --> $DIR/issue-52475.rs:5:9 | LL | / while n < 5 { +LL | | LL | | n = (n + 1) % 5; LL | | x = &0; // Materialize a new AllocId LL | | } - | |_________^ exceeded interpreter step limit (see `#[const_eval_limit]`) + | |_________^ + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/issue-52475.rs:2:18 + | +LL | let _ = [(); { + | __________________^ +LL | | let mut x = &0; +LL | | let mut n = 0; +LL | | while n < 5 { +... | +LL | | 0 +LL | | }]; + | |_____^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-70723.rs b/tests/ui/consts/const-eval/issue-70723.rs index 3c81afa67..c8c809a25 100644 --- a/tests/ui/consts/const-eval/issue-70723.rs +++ b/tests/ui/consts/const-eval/issue-70723.rs @@ -1,3 +1,3 @@ -static _X: () = loop {}; //~ ERROR could not evaluate static initializer +static _X: () = loop {}; //~ ERROR taking a long time fn main() {} diff --git a/tests/ui/consts/const-eval/issue-70723.stderr b/tests/ui/consts/const-eval/issue-70723.stderr index 09fb3e060..572a43072 100644 --- a/tests/ui/consts/const-eval/issue-70723.stderr +++ b/tests/ui/consts/const-eval/issue-70723.stderr @@ -1,9 +1,17 @@ -error[E0080]: could not evaluate static initializer +error: constant evaluation is taking a long time --> $DIR/issue-70723.rs:1:17 | LL | static _X: () = loop {}; - | ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) + | ^^^^^^^ + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/issue-70723.rs:1:1 + | +LL | static _X: () = loop {}; + | ^^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/promoted_errors.rs b/tests/ui/consts/const-eval/promoted_errors.rs index 2c42d0356..5e67dc6f6 100644 --- a/tests/ui/consts/const-eval/promoted_errors.rs +++ b/tests/ui/consts/const-eval/promoted_errors.rs @@ -48,5 +48,5 @@ const Y: () = { }; fn main() { - let _y = Y; + Y; } diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index a93b561e5..c0ddaceea 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -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 ..0: encountered a value of uninhabited type `Never` | = 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) { @@ -290,11 +290,11 @@ error[E0080]: it is undefined behavior to use this value LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } + = 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]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:152:1 @@ -529,11 +529,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ 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 = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } + = 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]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:221:1 @@ -574,11 +574,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } + = 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]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:242:1 diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index a32d4863a..20c905878 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -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 ..0: encountered a value of uninhabited type `Never` | = 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) { @@ -290,11 +290,11 @@ error[E0080]: it is undefined behavior to use this value LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } + = 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]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:152:1 @@ -529,11 +529,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ 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 = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } + = 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]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:221:1 @@ -574,11 +574,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } + = 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]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:242:1 diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs index c59596238..a30518170 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs @@ -25,7 +25,7 @@ const fn call_foo() -> u32 { foo(); foo(); foo(); - foo(); //~ ERROR evaluation of constant value failed [E0080] + foo(); //~ ERROR is taking a long time 0 } diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr index ed70975af..a3fd712ca 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr @@ -1,20 +1,17 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-fn-call.rs:28:5 - | -LL | foo(); - | ^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `call_foo` +error: constant evaluation is taking a long time --> $DIR/ctfe-fn-call.rs:28:5 | LL | foo(); | ^^^^^ -note: inside `X` - --> $DIR/ctfe-fn-call.rs:32:16 + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/ctfe-fn-call.rs:32:1 | LL | const X: u32 = call_foo(); - | ^^^^^^^^^^ + | ^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs index c10b8d837..f7cd04568 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs @@ -3,9 +3,10 @@ const fn labelled_loop(n: u32) -> u32 { let mut i = 0; - 'mylabel: loop { //~ ERROR evaluation of constant value failed [E0080] + 'mylabel: loop { + //~^ ERROR is taking a long time if i > n { - break 'mylabel + break 'mylabel; } i += 1; } diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr index d9404edd5..5808ee35a 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr @@ -1,30 +1,23 @@ -error[E0080]: evaluation of constant value failed +error: constant evaluation is taking a long time --> $DIR/ctfe-labelled-loop.rs:6:5 | LL | / 'mylabel: loop { +LL | | LL | | if i > n { -LL | | break 'mylabel -LL | | } -LL | | i += 1; -LL | | } - | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `labelled_loop` - --> $DIR/ctfe-labelled-loop.rs:6:5 - | -LL | / 'mylabel: loop { -LL | | if i > n { -LL | | break 'mylabel +LL | | break 'mylabel; LL | | } LL | | i += 1; LL | | } | |_____^ -note: inside `X` - --> $DIR/ctfe-labelled-loop.rs:15:16 + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/ctfe-labelled-loop.rs:16:1 | LL | const X: u32 = labelled_loop(19); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs index 80ff835f3..56a39fc45 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs @@ -1,11 +1,12 @@ // check-fail // compile-flags: -Z tiny-const-eval-limit +#[rustfmt::skip] const fn recurse(n: u32) -> u32 { if n == 0 { n } else { - recurse(n - 1) //~ ERROR evaluation of constant value failed [E0080] + recurse(n - 1) //~ ERROR is taking a long time } } diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr index ed9a31119..524c8e554 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr @@ -1,25 +1,17 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-recursion.rs:8:9 - | -LL | recurse(n - 1) - | ^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `recurse` - --> $DIR/ctfe-recursion.rs:8:9 +error: constant evaluation is taking a long time + --> $DIR/ctfe-recursion.rs:9:9 | LL | recurse(n - 1) | ^^^^^^^^^^^^^^ -note: [... 18 additional calls inside `recurse` ...] - --> $DIR/ctfe-recursion.rs:8:9 | -LL | recurse(n - 1) - | ^^^^^^^^^^^^^^ -note: inside `X` - --> $DIR/ctfe-recursion.rs:12:16 + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/ctfe-recursion.rs:13:1 | LL | const X: u32 = recurse(19); - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr new file mode 100644 index 000000000..30550f93a --- /dev/null +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr @@ -0,0 +1,19 @@ +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 1; +LL | | } + | |_____^ the const evaluator is currently interpreting this expression + | +help: the constant being evaluated + --> $DIR/ctfe-simple-loop.rs:19:1 + | +LL | const Y: u32 = simple_loop(35); + | ^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs index ca0eec93c..214f33dfb 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs @@ -1,14 +1,22 @@ -// check-fail +// check-pass +// revisions: warn allow +#![cfg_attr(warn, warn(long_running_const_eval))] +#![cfg_attr(allow, allow(long_running_const_eval))] + // compile-flags: -Z tiny-const-eval-limit const fn simple_loop(n: u32) -> u32 { let mut index = 0; - while index < n { //~ ERROR evaluation of constant value failed [E0080] + while index < n { + //~^ WARN is taking a long time + //[warn]~| WARN is taking a long time + //[warn]~| WARN is taking a long time index = index + 1; } 0 } const X: u32 = simple_loop(19); +const Y: u32 = simple_loop(35); fn main() { println!("{X}"); diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr deleted file mode 100644 index 83ff275de..000000000 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-simple-loop.rs:5:5 - | -LL | / while index < n { -LL | | index = index + 1; -LL | | } - | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `simple_loop` - --> $DIR/ctfe-simple-loop.rs:5:5 - | -LL | / while index < n { -LL | | index = index + 1; -LL | | } - | |_____^ -note: inside `X` - --> $DIR/ctfe-simple-loop.rs:11:16 - | -LL | const X: u32 = simple_loop(19); - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr new file mode 100644 index 000000000..40fc4a876 --- /dev/null +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr @@ -0,0 +1,62 @@ +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 1; +LL | | } + | |_____^ + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/ctfe-simple-loop.rs:18:1 + | +LL | const X: u32 = simple_loop(19); + | ^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/ctfe-simple-loop.rs:3:24 + | +LL | #![cfg_attr(warn, warn(long_running_const_eval))] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 1; +LL | | } + | |_____^ + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/ctfe-simple-loop.rs:19:1 + | +LL | const Y: u32 = simple_loop(35); + | ^^^^^^^^^^^^ + +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 1; +LL | | } + | |_____^ the const evaluator is currently interpreting this expression + | +help: the constant being evaluated + --> $DIR/ctfe-simple-loop.rs:19:1 + | +LL | const Y: u32 = simple_loop(35); + | ^^^^^^^^^^^^ + +warning: 3 warnings emitted + diff --git a/tests/ui/consts/const-eval/ub-enum.32bit.stderr b/tests/ui/consts/const-eval/ub-enum.32bit.stderr index 3ad1ac974..1810600b7 100644 --- a/tests/ui/consts/const-eval/ub-enum.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.32bit.stderr @@ -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 ..0: encountered a value of uninhabited type `Never` | = 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,7 +108,7 @@ 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 ..0.1: encountered a value of uninhabited type `Never` error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 diff --git a/tests/ui/consts/const-eval/ub-enum.64bit.stderr b/tests/ui/consts/const-eval/ub-enum.64bit.stderr index a66706d1a..fb40babb0 100644 --- a/tests/ui/consts/const-eval/ub-enum.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.64bit.stderr @@ -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 ..0: encountered a value of uninhabited type `Never` | = 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,7 +108,7 @@ 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 ..0.1: encountered a value of uninhabited type `Never` error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index 733975fc0..f1ad0f04d 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-uninhabit.rs:16:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` error[E0080]: it is undefined behavior to use this value --> $DIR/ub-uninhabit.rs:19:1 @@ -19,7 +19,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-uninhabit.rs:22:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index 2b0e58166..57959e7db 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -8,5 +8,5 @@ const _: () = foo(); // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully fn main() { - let _ = foo(); + foo(); } diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr index 74bc6317c..b423edbdc 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr @@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` warning: the type `empty::Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:21:42 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index 74bc6317c..b423edbdc 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` warning: the type `empty::Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:21:42 diff --git a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr new file mode 100644 index 000000000..d9208d070 --- /dev/null +++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr @@ -0,0 +1,15 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-len-underflow-separate-spans.rs:10:20 + | +LL | const LEN: usize = ONE - TWO; + | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + +note: erroneous constant used + --> $DIR/const-len-underflow-separate-spans.rs:14:17 + | +LL | let a: [i8; LEN] = unimplemented!(); + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr new file mode 100644 index 000000000..d9208d070 --- /dev/null +++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr @@ -0,0 +1,15 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-len-underflow-separate-spans.rs:10:20 + | +LL | const LEN: usize = ONE - TWO; + | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow + +note: erroneous constant used + --> $DIR/const-len-underflow-separate-spans.rs:14:17 + | +LL | let a: [i8; LEN] = unimplemented!(); + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs index 4544c8876..55704b641 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.rs +++ b/tests/ui/consts/const-len-underflow-separate-spans.rs @@ -2,6 +2,9 @@ // spot (where the underflow occurred), while also providing the // overall context for what caused the evaluation. +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next + const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; diff --git a/tests/ui/consts/const-len-underflow-separate-spans.stderr b/tests/ui/consts/const-len-underflow-separate-spans.stderr deleted file mode 100644 index 269553631..000000000 --- a/tests/ui/consts/const-len-underflow-separate-spans.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const-len-underflow-separate-spans.rs:7:20 - | -LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow - -note: erroneous constant used - --> $DIR/const-len-underflow-separate-spans.rs:11:17 - | -LL | let a: [i8; LEN] = unimplemented!(); - | ^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const_in_pattern/issue-73431.rs b/tests/ui/consts/const_in_pattern/issue-73431.rs index fa18a3af1..835f502b4 100644 --- a/tests/ui/consts/const_in_pattern/issue-73431.rs +++ b/tests/ui/consts/const_in_pattern/issue-73431.rs @@ -1,4 +1,5 @@ // run-pass +// unset-rustc-env:RUSTC_LOG_COLOR // Regression test for https://github.com/rust-lang/rust/issues/73431. diff --git a/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs b/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs deleted file mode 100644 index 629d1f02a..000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass - -#![feature(const_eval_limit)] - -// This needs to be higher than the number of loop iterations since each pass through the loop may -// hit more than one terminator. -#![const_eval_limit="4000"] - -const X: usize = { - let mut x = 0; - while x != 1000 { - x += 1; - } - - x -}; - -fn main() { - assert_eq!(X, 1000); -} diff --git a/tests/ui/consts/const_limit/const_eval_limit_overflow.rs b/tests/ui/consts/const_limit/const_eval_limit_overflow.rs deleted file mode 100644 index 1c49593cd..000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_overflow.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(const_eval_limit)] -#![const_eval_limit="18_446_744_073_709_551_615"] -//~^ ERROR `limit` must be a non-negative integer - -const CONSTANT: usize = limit(); - -fn main() { - assert_eq!(CONSTANT, 1764); -} - -const fn limit() -> usize { - let x = 42; - - x * 42 -} diff --git a/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr b/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr deleted file mode 100644 index 7f5d5e6cd..000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `limit` must be a non-negative integer - --> $DIR/const_eval_limit_overflow.rs:2:1 - | -LL | #![const_eval_limit="18_446_744_073_709_551_615"] - | ^^^^^^^^^^^^^^^^^^^^----------------------------^ - | | - | not a valid integer - -error: aborting due to previous error - diff --git a/tests/ui/consts/const_limit/const_eval_limit_reached.rs b/tests/ui/consts/const_limit/const_eval_limit_reached.rs deleted file mode 100644 index 3ce038c1d..000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_reached.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(const_eval_limit)] -#![const_eval_limit = "500"] - -const X: usize = { - let mut x = 0; - while x != 1000 { - //~^ ERROR evaluation of constant value failed - x += 1; - } - - x -}; - -fn main() { - assert_eq!(X, 1000); -} diff --git a/tests/ui/consts/const_limit/const_eval_limit_reached.stderr b/tests/ui/consts/const_limit/const_eval_limit_reached.stderr deleted file mode 100644 index a8e8ae9bb..000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_reached.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const_eval_limit_reached.rs:6:5 - | -LL | / while x != 1000 { -LL | | -LL | | x += 1; -LL | | } - | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs b/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs deleted file mode 100644 index 61119d751..000000000 --- a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![const_eval_limit="42"] -//~^ ERROR the `#[const_eval_limit]` attribute is an experimental feature [E0658] - -const CONSTANT: usize = limit(); - -fn main() { - assert_eq!(CONSTANT, 1764); -} - -const fn limit() -> usize { - let x = 42; - - x * 42 -} diff --git a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr b/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr deleted file mode 100644 index 5bd29c7df..000000000 --- a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: the `#[const_eval_limit]` attribute is an experimental feature - --> $DIR/feature-gate-const_eval_limit.rs:1:1 - | -LL | #![const_eval_limit="42"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #67217 for more information - = help: add `#![feature(const_eval_limit)]` 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/consts/issue-16538.mir.stderr b/tests/ui/consts/issue-16538.mir.stderr new file mode 100644 index 000000000..e320df4b7 --- /dev/null +++ b/tests/ui/consts/issue-16538.mir.stderr @@ -0,0 +1,29 @@ +error[E0015]: cannot call non-const fn `Y::foo` in statics + --> $DIR/issue-16538.rs:14:23 + | +LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-16538.rs:14:30 + | +LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); + | ^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/issue-16538.rs:14:21 + | +LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0015, E0133. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-16538.rs b/tests/ui/consts/issue-16538.rs new file mode 100644 index 000000000..270fa3014 --- /dev/null +++ b/tests/ui/consts/issue-16538.rs @@ -0,0 +1,19 @@ +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + +mod Y { + pub type X = usize; + extern "C" { + pub static x: *const usize; + } + pub fn foo(value: *const X) -> *const X { + value + } +} + +static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); +//~^ ERROR dereference of raw pointer +//~| ERROR E0015 +//~| ERROR use of extern static is unsafe and requires + +fn main() {} diff --git a/tests/ui/consts/issue-16538.thir.stderr b/tests/ui/consts/issue-16538.thir.stderr new file mode 100644 index 000000000..4a8628692 --- /dev/null +++ b/tests/ui/consts/issue-16538.thir.stderr @@ -0,0 +1,29 @@ +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/issue-16538.rs:14:22 + | +LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: use of extern static is unsafe and requires unsafe function or block + --> $DIR/issue-16538.rs:14:30 + | +LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); + | ^^^^ use of extern static + | + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error[E0015]: cannot call non-const fn `Y::foo` in statics + --> $DIR/issue-16538.rs:14:23 + | +LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0015, E0133. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-28822.rs b/tests/ui/consts/issue-28822.rs new file mode 100644 index 000000000..10e5d1dd0 --- /dev/null +++ b/tests/ui/consts/issue-28822.rs @@ -0,0 +1,7 @@ +// check-pass +#![allow(dead_code)] + +fn main() {} + +const fn size_ofs(_: usize) {} +const fn size_ofs2(_foo: usize) {} diff --git a/tests/ui/consts/issue-29798.rs b/tests/ui/consts/issue-29798.rs new file mode 100644 index 000000000..5eff5d191 --- /dev/null +++ b/tests/ui/consts/issue-29798.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:index out of bounds: the len is 5 but the index is 5 +// ignore-emscripten no processes + +const fn test(x: usize) -> i32 { + [42;5][x] +} + +fn main () { + let _ = test(5); +} diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr index 31a5b1df8..2fe84245b 100644 --- a/tests/ui/consts/issue-64506.stderr +++ b/tests/ui/consts/issue-64506.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-64506.rs:16:22 | LL | let x = unsafe { Foo { b: () }.a }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type AnonPipe + | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe` error: aborting due to previous error diff --git a/tests/ui/consts/issue-83182.stderr b/tests/ui/consts/issue-83182.stderr index 1d578f910..ca4e0f7aa 100644 --- a/tests/ui/consts/issue-83182.stderr +++ b/tests/ui/consts/issue-83182.stderr @@ -4,11 +4,11 @@ error[E0080]: it is undefined behavior to use this value LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 = 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 diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index fb758d406..67797e6fb 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed | = note: 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 note: inside `std::ptr::read::` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `ptr::const_ptr::::read` @@ -14,6 +12,8 @@ note: inside `C` | LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = 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 diff --git a/tests/ui/consts/large_const_alloc.rs b/tests/ui/consts/large_const_alloc.rs index 54abaab22..298ed38d1 100644 --- a/tests/ui/consts/large_const_alloc.rs +++ b/tests/ui/consts/large_const_alloc.rs @@ -13,6 +13,6 @@ static FOO2: () = { }; fn main() { - let _ = FOO; - let _ = FOO2; + FOO; + FOO2; } diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 8e22cb74b..d97097d35 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,4 +1,4 @@ -error[E0080]: evaluation of `, std::string::String>>::F` failed +error[E0080]: evaluation of `, String>>::F` failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | = note: calling non-const function ` as Drop>::drop` diff --git a/tests/ui/consts/miri_unleashed/raw_mutable_const.rs b/tests/ui/consts/miri_unleashed/raw_mutable_const.rs index 5f8ec4e6e..adb1f8bf3 100644 --- a/tests/ui/consts/miri_unleashed/raw_mutable_const.rs +++ b/tests/ui/consts/miri_unleashed/raw_mutable_const.rs @@ -3,6 +3,6 @@ use std::cell::UnsafeCell; const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; -//~^ ERROR: untyped pointers are not allowed in constant +//~^ ERROR: unsupported untyped pointer in constant fn main() {} diff --git a/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr b/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr index f8dc11d69..5acdcdd95 100644 --- a/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr +++ b/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/raw_mutable_const.rs:5:1 | LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported warning: skipping const checks | diff --git a/tests/ui/consts/missing-larger-array-impl.rs b/tests/ui/consts/missing-larger-array-impl.rs new file mode 100644 index 000000000..e6c879c8e --- /dev/null +++ b/tests/ui/consts/missing-larger-array-impl.rs @@ -0,0 +1,9 @@ +struct X; + +// Make sure that we show the impl trait refs in the help message with +// their evaluated constants, rather than `core::::array::{impl#30}::{constant#0}` + +fn main() { + <[X; 35] as Default>::default(); + //~^ ERROR the trait bound `[X; 35]: Default` is not satisfied +} diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr new file mode 100644 index 000000000..b8f6cb5ef --- /dev/null +++ b/tests/ui/consts/missing-larger-array-impl.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `[X; 35]: Default` is not satisfied + --> $DIR/missing-larger-array-impl.rs:7:5 + | +LL | <[X; 35] as Default>::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` + | + = help: the following other types implement trait `Default`: + [T; 0] + [T; 1] + [T; 2] + [T; 3] + [T; 4] + [T; 5] + [T; 6] + [T; 7] + and 27 others + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index e6d3d5199..fcfb9fbb3 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed | = note: unable to copy parts of a pointer from memory at ALLOC_ID | - = 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 note: inside `std::ptr::read::>>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `mem::swap_simple::>>` @@ -22,6 +20,8 @@ note: inside `X` 20 | | mem::size_of::<&i32>(), 21 | | ); | |_________^ + = 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 diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 6530084a5..97ff6efdd 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -27,31 +27,31 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:37:14 | LL | unsafe { ptr_offset_from(ptr, ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:44:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8[noalloc] is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: 0x8[noalloc] is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:53:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:62:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:70:14 | LL | unsafe { ptr_offset_from(end_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc23 has size 4, so pointer at offset 10 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:79:14 @@ -86,7 +86,7 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) | note: inside `ptr::const_ptr::::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -99,7 +99,7 @@ LL | unsafe { ptr2.offset_from(ptr1) } error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) | note: inside `ptr::const_ptr::::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/raw-ptr-const.rs b/tests/ui/consts/raw-ptr-const.rs index b9c542d03..fc774be54 100644 --- a/tests/ui/consts/raw-ptr-const.rs +++ b/tests/ui/consts/raw-ptr-const.rs @@ -3,6 +3,6 @@ // could also be allowed. const CONST_RAW: *const Vec = &Vec::new() as *const _; -//~^ ERROR untyped pointers are not allowed in constant +//~^ ERROR unsupported untyped pointer in constant fn main() {} diff --git a/tests/ui/consts/raw-ptr-const.stderr b/tests/ui/consts/raw-ptr-const.stderr index f7b53433b..82f782fab 100644 --- a/tests/ui/consts/raw-ptr-const.stderr +++ b/tests/ui/consts/raw-ptr-const.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/raw-ptr-const.rs:5:1 | LL | const CONST_RAW: *const Vec = &Vec::new() as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported error: aborting due to previous error diff --git a/tests/ui/consts/refs_check_const_eq-issue-88384.rs b/tests/ui/consts/refs_check_const_eq-issue-88384.rs index 1496b28bd..fb0405b65 100644 --- a/tests/ui/consts/refs_check_const_eq-issue-88384.rs +++ b/tests/ui/consts/refs_check_const_eq-issue-88384.rs @@ -8,10 +8,10 @@ struct CompileTimeSettings{ } struct Foo; -//~^ ERROR using function pointers as const generic parameters is forbidden +//~^ ERROR `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter impl Foo { - //~^ ERROR using function pointers as const generic parameters is forbidden + //~^ ERROR `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter fn call_hooks(){ } } diff --git a/tests/ui/consts/refs_check_const_eq-issue-88384.stderr b/tests/ui/consts/refs_check_const_eq-issue-88384.stderr index 3855b5f2a..c490cd053 100644 --- a/tests/ui/consts/refs_check_const_eq-issue-88384.stderr +++ b/tests/ui/consts/refs_check_const_eq-issue-88384.stderr @@ -7,17 +7,29 @@ LL | #![feature(adt_const_params)] = note: see issue #95174 for more information = note: `#[warn(incomplete_features)]` on by default -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/refs_check_const_eq-issue-88384.rs:10:21 | LL | struct Foo; | ^^^^^^^^^^^^^^^^^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct CompileTimeSettings{ + | -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/refs_check_const_eq-issue-88384.rs:13:15 | LL | impl Foo { | ^^^^^^^^^^^^^^^^^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct CompileTimeSettings{ + | error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/consts/timeout.rs b/tests/ui/consts/timeout.rs new file mode 100644 index 000000000..c9094999e --- /dev/null +++ b/tests/ui/consts/timeout.rs @@ -0,0 +1,25 @@ +//! This test checks that external macros don't hide +//! the const eval timeout lint and then subsequently +//! ICE. + +// compile-flags: --crate-type=lib -Ztiny-const-eval-limit +// error-pattern: constant evaluation is taking a long time + +static ROOK_ATTACKS_TABLE: () = { + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); + 0_u64.count_ones(); +}; diff --git a/tests/ui/consts/timeout.stderr b/tests/ui/consts/timeout.stderr new file mode 100644 index 000000000..799b5ec8d --- /dev/null +++ b/tests/ui/consts/timeout.stderr @@ -0,0 +1,15 @@ +error: constant evaluation is taking a long time + --> $SRC_DIR/core/src/num/mod.rs:LL:COL + | + = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. + If your compilation actually takes a long time, you can safely allow the lint. +help: the constant being evaluated + --> $DIR/timeout.rs:8:1 + | +LL | static ROOK_ATTACKS_TABLE: () = { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default + = note: this error originates in the macro `uint_impl` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/consts/too_generic_eval_ice.stderr b/tests/ui/consts/too_generic_eval_ice.stderr index 5af82a3e3..843d6d9e0 100644 --- a/tests/ui/consts/too_generic_eval_ice.stderr +++ b/tests/ui/consts/too_generic_eval_ice.stderr @@ -22,14 +22,14 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | = help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]` = help: the following other types implement trait `PartialEq`: - <&[B] as PartialEq<[A; N]>> - <&[T] as PartialEq>> - <&mut [B] as PartialEq<[A; N]>> - <&mut [T] as PartialEq>> - <[A; N] as PartialEq<&[B]>> - <[A; N] as PartialEq<&mut [B]>> <[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]>> + <&[T] as PartialEq>> and 3 others error: aborting due to 3 previous errors diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index 5bca83e87..d6a2c80cc 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -44,6 +44,7 @@ impl ::core::default::Default for Empty { } #[automatically_derived] impl ::core::hash::Hash for Empty { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } #[automatically_derived] @@ -113,6 +114,7 @@ impl ::core::default::Default for Point { } #[automatically_derived] impl ::core::hash::Hash for Point { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.x, state); ::core::hash::Hash::hash(&self.y, state) @@ -198,6 +200,7 @@ impl ::core::default::Default for PackedPoint { } #[automatically_derived] impl ::core::hash::Hash for PackedPoint { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&{ self.x }, state); ::core::hash::Hash::hash(&{ self.y }, state) @@ -301,6 +304,7 @@ impl ::core::default::Default for Big { } #[automatically_derived] impl ::core::hash::Hash for Big { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.b1, state); ::core::hash::Hash::hash(&self.b2, state); @@ -478,6 +482,7 @@ impl ::core::fmt::Debug for Unsized { } #[automatically_derived] impl ::core::hash::Hash for Unsized { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.0, state) } @@ -529,6 +534,7 @@ impl ::core::fmt::Debug for PackedUnsizedU8 { } #[automatically_derived] impl ::core::hash::Hash for PackedUnsizedU8 { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.0, state) } @@ -584,6 +590,7 @@ impl #[automatically_derived] impl ::core::hash::Hash for Generic where T::A: ::core::hash::Hash { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&self.t, state); ::core::hash::Hash::hash(&self.ta, state); @@ -701,6 +708,7 @@ impl ::core::hash::Hash for PackedGeneric where T::A: ::core::hash::Hash + ::core::marker::Copy { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { ::core::hash::Hash::hash(&{ self.0 }, state); ::core::hash::Hash::hash(&{ self.1 }, state); @@ -795,6 +803,7 @@ impl ::core::fmt::Debug for Enum0 { } #[automatically_derived] impl ::core::hash::Hash for Enum0 { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { unsafe { ::core::intrinsics::unreachable() } } @@ -861,6 +870,7 @@ impl ::core::fmt::Debug for Enum1 { } #[automatically_derived] impl ::core::hash::Hash for Enum1 { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { match self { Enum1::Single { x: __self_0 } => @@ -937,6 +947,7 @@ impl ::core::default::Default for Fieldless1 { } #[automatically_derived] impl ::core::hash::Hash for Fieldless1 { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {} } #[automatically_derived] @@ -1004,6 +1015,7 @@ impl ::core::default::Default for Fieldless { } #[automatically_derived] impl ::core::hash::Hash for Fieldless { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_tag = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_tag, state) @@ -1095,6 +1107,7 @@ impl ::core::default::Default for Mixed { } #[automatically_derived] impl ::core::hash::Hash for Mixed { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_tag = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_tag, state); @@ -1224,6 +1237,7 @@ impl ::core::fmt::Debug for Fielded { } #[automatically_derived] impl ::core::hash::Hash for Fielded { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_tag = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_tag, state); @@ -1345,6 +1359,7 @@ impl ::core::fmt::Debug for #[automatically_derived] impl ::core::hash::Hash for EnumGeneric { + #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { let __self_tag = ::core::intrinsics::discriminant_value(self); ::core::hash::Hash::hash(&__self_tag, state); diff --git a/tests/ui/deriving/issue-103157.stderr b/tests/ui/deriving/issue-103157.stderr index b18e1e509..01cce2a39 100644 --- a/tests/ui/deriving/issue-103157.stderr +++ b/tests/ui/deriving/issue-103157.stderr @@ -8,14 +8,14 @@ LL | Float(Option), | ^^^^^^^^^^^ the trait `Eq` is not implemented for `f64` | = help: the following other types implement trait `Eq`: - i128 + isize + i8 i16 i32 i64 - i8 - isize - u128 - u16 + i128 + usize + u8 and 4 others = note: required for `Option` to implement `Eq` note: required by a bound in `AssertParamIsEq` diff --git a/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr index 5e0e4a011..2d50c0964 100644 --- a/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr +++ b/tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr @@ -7,12 +7,12 @@ LL | f1.foo(1usize); | required by a bound introduced by this call | = help: the following other types implement trait `Foo`: + > > > - > + > > > - > error: aborting due to previous error diff --git a/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index 7229b9ac9..ae15e054f 100644 --- a/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/tests/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -8,10 +8,10 @@ LL | Foo::::bar(&1i8); | = help: the following other types implement trait `Foo`: > + > > > > - > error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:25:21 @@ -38,10 +38,10 @@ LL | Foo::::bar(&true); = help: the following other types implement trait `Foo`: > > + > > > > - > error: aborting due to 3 previous errors diff --git a/tests/ui/did_you_mean/issue-42599_available_fields_note.stderr b/tests/ui/did_you_mean/issue-42599_available_fields_note.stderr index dbd9dc1bc..c20bbce3f 100644 --- a/tests/ui/did_you_mean/issue-42599_available_fields_note.stderr +++ b/tests/ui/did_you_mean/issue-42599_available_fields_note.stderr @@ -10,7 +10,7 @@ error[E0560]: struct `Demo` has no field named `egregiously_nonexistent_field` LL | Self { secret_integer: 3, egregiously_nonexistent_field: () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Demo` does not have this field | - = note: available fields are: `favorite_integer`, `secret_integer`, `innocently_misspellable`, `another_field`, `yet_another_field` ... and 2 others + = note: available fields are: `favorite_integer`, `innocently_misspellable`, `another_field`, `yet_another_field`, `always_more_fields`, `and_ever` error[E0609]: no field `inocently_mispellable` on type `Demo` --> $DIR/issue-42599_available_fields_note.rs:32:41 diff --git a/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr b/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr index 26986684f..44bdbb93f 100644 --- a/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr +++ b/tests/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr @@ -23,14 +23,14 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹ | = help: the trait `Sub<{integer}>` is not implemented for `{float}` = help: the following other types implement trait `Sub`: - <&'a f32 as Sub> - <&'a f64 as Sub> - <&'a i128 as Sub> - <&'a i16 as Sub> - <&'a i32 as Sub> - <&'a i64 as Sub> - <&'a i8 as Sub> - <&'a isize as Sub> + + > + + > + + > + + > and 48 others error: aborting due to 3 previous errors diff --git a/tests/ui/discrim/discrim-ill-typed.rs b/tests/ui/discrim/discrim-ill-typed.rs deleted file mode 100644 index 3cf0ea0e6..000000000 --- a/tests/ui/discrim/discrim-ill-typed.rs +++ /dev/null @@ -1,114 +0,0 @@ -// When explicit discriminant value has -// a type that does not match the representation -// type, rustc should fail gracefully. - -// See also run-pass/discrim-explicit-23030.rs where the input types -// are correct. - -#![allow(dead_code, unused_variables, unused_imports)] - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo = 0_u8, - //~^ ERROR mismatched types - //~| expected `i8`, found `u8` - } - - let x = A::Ok; -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo = 0_i8, - //~^ ERROR mismatched types - //~| expected `u8`, found `i8` - } - - let x = A::Ok; -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo = 0_u16, - //~^ ERROR mismatched types - //~| expected `i16`, found `u16` - } - - let x = A::Ok; -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo = 0_i16, - //~^ ERROR mismatched types - //~| expected `u16`, found `i16` - } - - let x = A::Ok; -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo = 0_u32, - //~^ ERROR mismatched types - //~| expected `i32`, found `u32` - } - - let x = A::Ok; -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo = 0_i32, - //~^ ERROR mismatched types - //~| expected `u32`, found `i32` - } - - let x = A::Ok; -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo = 0_u64, - //~^ ERROR mismatched types - //~| expected `i64`, found `u64` - } - - let x = A::Ok; -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo = 0_i64, - //~^ ERROR mismatched types - //~| expected `u64`, found `i64` - } - - let x = A::Ok; -} - -fn main() { } diff --git a/tests/ui/discrim/discrim-ill-typed.stderr b/tests/ui/discrim/discrim-ill-typed.stderr deleted file mode 100644 index 27f516341..000000000 --- a/tests/ui/discrim/discrim-ill-typed.stderr +++ /dev/null @@ -1,91 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:15:16 - | -LL | OhNo = 0_u8, - | ^^^^ expected `i8`, found `u8` - | -help: change the type of the numeric literal from `u8` to `i8` - | -LL | OhNo = 0_i8, - | ~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:28:16 - | -LL | OhNo = 0_i8, - | ^^^^ expected `u8`, found `i8` - | -help: change the type of the numeric literal from `i8` to `u8` - | -LL | OhNo = 0_u8, - | ~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:41:16 - | -LL | OhNo = 0_u16, - | ^^^^^ expected `i16`, found `u16` - | -help: change the type of the numeric literal from `u16` to `i16` - | -LL | OhNo = 0_i16, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:54:16 - | -LL | OhNo = 0_i16, - | ^^^^^ expected `u16`, found `i16` - | -help: change the type of the numeric literal from `i16` to `u16` - | -LL | OhNo = 0_u16, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:67:16 - | -LL | OhNo = 0_u32, - | ^^^^^ expected `i32`, found `u32` - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL | OhNo = 0_i32, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:80:16 - | -LL | OhNo = 0_i32, - | ^^^^^ expected `u32`, found `i32` - | -help: change the type of the numeric literal from `i32` to `u32` - | -LL | OhNo = 0_u32, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:93:16 - | -LL | OhNo = 0_u64, - | ^^^^^ expected `i64`, found `u64` - | -help: change the type of the numeric literal from `u64` to `i64` - | -LL | OhNo = 0_i64, - | ~~~ - -error[E0308]: mismatched types - --> $DIR/discrim-ill-typed.rs:106:16 - | -LL | OhNo = 0_i64, - | ^^^^^ expected `u64`, found `i64` - | -help: change the type of the numeric literal from `i64` to `u64` - | -LL | OhNo = 0_u64, - | ~~~ - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/discrim/discrim-overflow-2.rs b/tests/ui/discrim/discrim-overflow-2.rs deleted file mode 100644 index ca24317c5..000000000 --- a/tests/ui/discrim/discrim-overflow-2.rs +++ /dev/null @@ -1,80 +0,0 @@ -// Issue 23030: Detect overflowing discriminant -// -// Check that we detect the overflow even if enum is not used. - -// See also run-pass/discrim-explicit-23030.rs where the suggested -// workaround is tested. - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } -} - -fn main() { } diff --git a/tests/ui/discrim/discrim-overflow-2.stderr b/tests/ui/discrim/discrim-overflow-2.stderr deleted file mode 100644 index 3ca84c667..000000000 --- a/tests/ui/discrim/discrim-overflow-2.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:13:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 127 - | - = note: explicitly set `OhNo = -128` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:22:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 255 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:31:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 32767 - | - = note: explicitly set `OhNo = -32768` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:40:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 65535 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:49:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 2147483647 - | - = note: explicitly set `OhNo = -2147483648` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:58:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 4294967295 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:67:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 9223372036854775807 - | - = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow-2.rs:76:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 18446744073709551615 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0370`. diff --git a/tests/ui/discrim/discrim-overflow.rs b/tests/ui/discrim/discrim-overflow.rs deleted file mode 100644 index 774ced93c..000000000 --- a/tests/ui/discrim/discrim-overflow.rs +++ /dev/null @@ -1,99 +0,0 @@ -// Issue 23030: Detect overflowing discriminant - -// See also run-pass/discrim-explicit-23030.rs where the suggested -// workaround is tested. - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } - - let x = A::Ok; -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } - - let x = A::Ok; -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - } - - let x = A::Ok; -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 65535 - } - - let x = A::Ok; -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 2147483647 - } - - let x = A::Ok; -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 4294967295 - } - - let x = A::Ok; -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 9223372036854775807 - } - - let x = A::Ok; -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo, //~ ERROR enum discriminant overflowed [E0370] - //~| overflowed on value after 18446744073709551615 - } - - let x = A::Ok; -} - -fn main() { } diff --git a/tests/ui/discrim/discrim-overflow.stderr b/tests/ui/discrim/discrim-overflow.stderr deleted file mode 100644 index 1b331bb1b..000000000 --- a/tests/ui/discrim/discrim-overflow.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:11:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 127 - | - = note: explicitly set `OhNo = -128` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:22:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 255 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:33:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 32767 - | - = note: explicitly set `OhNo = -32768` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:44:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 65535 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:56:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 2147483647 - | - = note: explicitly set `OhNo = -2147483648` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:68:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 4294967295 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:80:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 9223372036854775807 - | - = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome - -error[E0370]: enum discriminant overflowed - --> $DIR/discrim-overflow.rs:92:9 - | -LL | OhNo, - | ^^^^ overflowed on value after 18446744073709551615 - | - = note: explicitly set `OhNo = 0` if that is desired outcome - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0370`. diff --git a/tests/ui/dst/dst-object-from-unsized-type.stderr b/tests/ui/dst/dst-object-from-unsized-type.stderr index d5e464aed..cbb7dc5e9 100644 --- a/tests/ui/dst/dst-object-from-unsized-type.stderr +++ b/tests/ui/dst/dst-object-from-unsized-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/dst-object-from-unsized-type.rs:8:23 | LL | fn test1(t: &T) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | let u: &dyn Foo = t; | ^ doesn't have a size known at compile-time | @@ -17,7 +17,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/dst-object-from-unsized-type.rs:13:23 | LL | fn test2(t: &T) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | let v: &dyn Foo = t as &dyn Foo; | ^ doesn't have a size known at compile-time | diff --git a/tests/ui/duplicate/dupe-symbols-7.rs b/tests/ui/duplicate/dupe-symbols-7.rs index 633ca4c31..498387472 100644 --- a/tests/ui/duplicate/dupe-symbols-7.rs +++ b/tests/ui/duplicate/dupe-symbols-7.rs @@ -3,9 +3,6 @@ // // error-pattern: entry symbol `main` declared multiple times -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" #![allow(warnings)] #[no_mangle] diff --git a/tests/ui/duplicate/dupe-symbols-7.stderr b/tests/ui/duplicate/dupe-symbols-7.stderr index 1455f0e75..cd5147c0e 100644 --- a/tests/ui/duplicate/dupe-symbols-7.stderr +++ b/tests/ui/duplicate/dupe-symbols-7.stderr @@ -1,5 +1,5 @@ error: entry symbol `main` declared multiple times - --> $DIR/dupe-symbols-7.rs:12:1 + --> $DIR/dupe-symbols-7.rs:9:1 | LL | fn main(){} | ^^^^^^^^^ diff --git a/tests/ui/dyn-star/box.rs b/tests/ui/dyn-star/box.rs index d1f1819d9..87c8356a1 100644 --- a/tests/ui/dyn-star/box.rs +++ b/tests/ui/dyn-star/box.rs @@ -1,5 +1,7 @@ // run-pass -// compile-flags: -C opt-level=0 +// revisions: current next +//[current] compile-flags: -C opt-level=0 +//[next] compile-flags: -Ztrait-solver=next -C opt-level=0 #![feature(dyn_star)] #![allow(incomplete_features)] diff --git a/tests/ui/dyn-star/param-env-infer.current.stderr b/tests/ui/dyn-star/param-env-infer.current.stderr deleted file mode 100644 index b3af7be79..000000000 --- a/tests/ui/dyn-star/param-env-infer.current.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/param-env-infer.rs:5:12 - | -LL | #![feature(dyn_star, pointer_like_trait)] - | ^^^^^^^^ - | - = note: see issue #102425 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0282]: type annotations needed - --> $DIR/param-env-infer.rs:13:10 - | -LL | t as _ - | ^ cannot infer type - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-infer.next.stderr b/tests/ui/dyn-star/param-env-infer.next.stderr deleted file mode 100644 index 64d76bb04..000000000 --- a/tests/ui/dyn-star/param-env-infer.next.stderr +++ /dev/null @@ -1,73 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/param-env-infer.rs:5:12 - | -LL | #![feature(dyn_star, pointer_like_trait)] - | ^^^^^^^^ - | - = note: see issue #102425 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}` - --> $DIR/param-env-infer.rs:11:60 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires borrow-checking `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires preparing `make_dyn_star` for borrow checking... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires unsafety-checking `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires match-checking `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building THIR for `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -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-infer.rs:11: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-infer.rs:5:1 - | -LL | / #![feature(dyn_star, pointer_like_trait)] -LL | | -LL | | -LL | | use std::fmt::Debug; -... | -LL | | -LL | | fn main() {} - | |____________^ - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/dyn-star/param-env-infer.rs b/tests/ui/dyn-star/param-env-infer.rs deleted file mode 100644 index 1fb16d768..000000000 --- a/tests/ui/dyn-star/param-env-infer.rs +++ /dev/null @@ -1,17 +0,0 @@ -// revisions: current next -//[next] compile-flags: -Ztrait-solver=next -// incremental - -#![feature(dyn_star, pointer_like_trait)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; -use std::marker::PointerLike; - -fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - //[next]~^ ERROR cycle detected when computing type of `make_dyn_star::{opaque#0}` - t as _ - //[current]~^ ERROR type annotations needed -} - -fn main() {} diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr new file mode 100644 index 000000000..902053ecf --- /dev/null +++ b/tests/ui/dyn-star/param-env-region-infer.current.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/param-env-region-infer.rs:18:10 + | +LL | t as _ + | ^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-region-infer.next.stderr b/tests/ui/dyn-star/param-env-region-infer.next.stderr new file mode 100644 index 000000000..dd724a659 --- /dev/null +++ b/tests/ui/dyn-star/param-env-region-infer.next.stderr @@ -0,0 +1,29 @@ +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 new file mode 100644 index 000000000..537473abc --- /dev/null +++ b/tests/ui/dyn-star/param-env-region-infer.rs @@ -0,0 +1,22 @@ +// 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 +// incremental + +// checks that we don't ICE if there are region inference variables in the environment +// when computing `PointerLike` builtin candidates. + +#![feature(dyn_star, pointer_like_trait)] +#![allow(incomplete_features)] + +use std::fmt::Debug; +use std::marker::PointerLike; + +fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { + //[next]~^ ERROR cycle detected when computing + t as _ + //[current]~^ ERROR type annotations needed +} + +fn main() {} diff --git a/tests/ui/empty-allocation-rvalue-non-null.rs b/tests/ui/empty-allocation-rvalue-non-null.rs index 2f5a5c4bb..ad0f22031 100644 --- a/tests/ui/empty-allocation-rvalue-non-null.rs +++ b/tests/ui/empty-allocation-rvalue-non-null.rs @@ -4,5 +4,5 @@ // pretty-expanded FIXME #23616 pub fn main() { - let x = *Box::new(()); + let x: () = *Box::new(()); } diff --git a/tests/ui/empty/empty-macro-use.stderr b/tests/ui/empty/empty-macro-use.stderr index e0b3b8685..5d552e4c4 100644 --- a/tests/ui/empty/empty-macro-use.stderr +++ b/tests/ui/empty/empty-macro-use.stderr @@ -4,8 +4,10 @@ error: cannot find macro `macro_two` in this scope LL | macro_two!(); | ^^^^^^^^^ | - = help: consider importing this macro: - two_macros::macro_two +help: consider importing this macro + | +LL + use two_macros::macro_two; + | error: aborting due to previous error diff --git a/tests/ui/enum-discriminant/discriminant-ill-typed.rs b/tests/ui/enum-discriminant/discriminant-ill-typed.rs new file mode 100644 index 000000000..3cf0ea0e6 --- /dev/null +++ b/tests/ui/enum-discriminant/discriminant-ill-typed.rs @@ -0,0 +1,114 @@ +// When explicit discriminant value has +// a type that does not match the representation +// type, rustc should fail gracefully. + +// See also run-pass/discrim-explicit-23030.rs where the input types +// are correct. + +#![allow(dead_code, unused_variables, unused_imports)] + +fn f_i8() { + #[repr(i8)] + enum A { + Ok = i8::MAX - 1, + Ok2, + OhNo = 0_u8, + //~^ ERROR mismatched types + //~| expected `i8`, found `u8` + } + + let x = A::Ok; +} + +fn f_u8() { + #[repr(u8)] + enum A { + Ok = u8::MAX - 1, + Ok2, + OhNo = 0_i8, + //~^ ERROR mismatched types + //~| expected `u8`, found `i8` + } + + let x = A::Ok; +} + +fn f_i16() { + #[repr(i16)] + enum A { + Ok = i16::MAX - 1, + Ok2, + OhNo = 0_u16, + //~^ ERROR mismatched types + //~| expected `i16`, found `u16` + } + + let x = A::Ok; +} + +fn f_u16() { + #[repr(u16)] + enum A { + Ok = u16::MAX - 1, + Ok2, + OhNo = 0_i16, + //~^ ERROR mismatched types + //~| expected `u16`, found `i16` + } + + let x = A::Ok; +} + +fn f_i32() { + #[repr(i32)] + enum A { + Ok = i32::MAX - 1, + Ok2, + OhNo = 0_u32, + //~^ ERROR mismatched types + //~| expected `i32`, found `u32` + } + + let x = A::Ok; +} + +fn f_u32() { + #[repr(u32)] + enum A { + Ok = u32::MAX - 1, + Ok2, + OhNo = 0_i32, + //~^ ERROR mismatched types + //~| expected `u32`, found `i32` + } + + let x = A::Ok; +} + +fn f_i64() { + #[repr(i64)] + enum A { + Ok = i64::MAX - 1, + Ok2, + OhNo = 0_u64, + //~^ ERROR mismatched types + //~| expected `i64`, found `u64` + } + + let x = A::Ok; +} + +fn f_u64() { + #[repr(u64)] + enum A { + Ok = u64::MAX - 1, + Ok2, + OhNo = 0_i64, + //~^ ERROR mismatched types + //~| expected `u64`, found `i64` + } + + let x = A::Ok; +} + +fn main() { } diff --git a/tests/ui/enum-discriminant/discriminant-ill-typed.stderr b/tests/ui/enum-discriminant/discriminant-ill-typed.stderr new file mode 100644 index 000000000..275714528 --- /dev/null +++ b/tests/ui/enum-discriminant/discriminant-ill-typed.stderr @@ -0,0 +1,91 @@ +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:15:16 + | +LL | OhNo = 0_u8, + | ^^^^ expected `i8`, found `u8` + | +help: change the type of the numeric literal from `u8` to `i8` + | +LL | OhNo = 0_i8, + | ~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:28:16 + | +LL | OhNo = 0_i8, + | ^^^^ expected `u8`, found `i8` + | +help: change the type of the numeric literal from `i8` to `u8` + | +LL | OhNo = 0_u8, + | ~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:41:16 + | +LL | OhNo = 0_u16, + | ^^^^^ expected `i16`, found `u16` + | +help: change the type of the numeric literal from `u16` to `i16` + | +LL | OhNo = 0_i16, + | ~~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:54:16 + | +LL | OhNo = 0_i16, + | ^^^^^ expected `u16`, found `i16` + | +help: change the type of the numeric literal from `i16` to `u16` + | +LL | OhNo = 0_u16, + | ~~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:67:16 + | +LL | OhNo = 0_u32, + | ^^^^^ expected `i32`, found `u32` + | +help: change the type of the numeric literal from `u32` to `i32` + | +LL | OhNo = 0_i32, + | ~~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:80:16 + | +LL | OhNo = 0_i32, + | ^^^^^ expected `u32`, found `i32` + | +help: change the type of the numeric literal from `i32` to `u32` + | +LL | OhNo = 0_u32, + | ~~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:93:16 + | +LL | OhNo = 0_u64, + | ^^^^^ expected `i64`, found `u64` + | +help: change the type of the numeric literal from `u64` to `i64` + | +LL | OhNo = 0_i64, + | ~~~ + +error[E0308]: mismatched types + --> $DIR/discriminant-ill-typed.rs:106:16 + | +LL | OhNo = 0_i64, + | ^^^^^ expected `u64`, found `i64` + | +help: change the type of the numeric literal from `i64` to `u64` + | +LL | OhNo = 0_u64, + | ~~~ + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/enum-discriminant/discriminant-overflow-2.rs b/tests/ui/enum-discriminant/discriminant-overflow-2.rs new file mode 100644 index 000000000..ca24317c5 --- /dev/null +++ b/tests/ui/enum-discriminant/discriminant-overflow-2.rs @@ -0,0 +1,80 @@ +// Issue 23030: Detect overflowing discriminant +// +// Check that we detect the overflow even if enum is not used. + +// See also run-pass/discrim-explicit-23030.rs where the suggested +// workaround is tested. + +fn f_i8() { + #[repr(i8)] + enum A { + Ok = i8::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_u8() { + #[repr(u8)] + enum A { + Ok = u8::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_i16() { + #[repr(i16)] + enum A { + Ok = i16::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_u16() { + #[repr(u16)] + enum A { + Ok = u16::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_i32() { + #[repr(i32)] + enum A { + Ok = i32::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_u32() { + #[repr(u32)] + enum A { + Ok = u32::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_i64() { + #[repr(i64)] + enum A { + Ok = i64::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn f_u64() { + #[repr(u64)] + enum A { + Ok = u64::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } +} + +fn main() { } diff --git a/tests/ui/enum-discriminant/discriminant-overflow-2.stderr b/tests/ui/enum-discriminant/discriminant-overflow-2.stderr new file mode 100644 index 000000000..5f7387c59 --- /dev/null +++ b/tests/ui/enum-discriminant/discriminant-overflow-2.stderr @@ -0,0 +1,67 @@ +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:13:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 127 + | + = note: explicitly set `OhNo = -128` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:22:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 255 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:31:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 32767 + | + = note: explicitly set `OhNo = -32768` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:40:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 65535 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:49:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 2147483647 + | + = note: explicitly set `OhNo = -2147483648` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:58:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 4294967295 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:67:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 9223372036854775807 + | + = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow-2.rs:76:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 18446744073709551615 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0370`. diff --git a/tests/ui/enum-discriminant/discriminant-overflow.rs b/tests/ui/enum-discriminant/discriminant-overflow.rs new file mode 100644 index 000000000..774ced93c --- /dev/null +++ b/tests/ui/enum-discriminant/discriminant-overflow.rs @@ -0,0 +1,99 @@ +// Issue 23030: Detect overflowing discriminant + +// See also run-pass/discrim-explicit-23030.rs where the suggested +// workaround is tested. + +fn f_i8() { + #[repr(i8)] + enum A { + Ok = i8::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } + + let x = A::Ok; +} + +fn f_u8() { + #[repr(u8)] + enum A { + Ok = u8::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } + + let x = A::Ok; +} + +fn f_i16() { + #[repr(i16)] + enum A { + Ok = i16::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + } + + let x = A::Ok; +} + +fn f_u16() { + #[repr(u16)] + enum A { + Ok = u16::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + //~| overflowed on value after 65535 + } + + let x = A::Ok; +} + +fn f_i32() { + #[repr(i32)] + enum A { + Ok = i32::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + //~| overflowed on value after 2147483647 + } + + let x = A::Ok; +} + +fn f_u32() { + #[repr(u32)] + enum A { + Ok = u32::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + //~| overflowed on value after 4294967295 + } + + let x = A::Ok; +} + +fn f_i64() { + #[repr(i64)] + enum A { + Ok = i64::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + //~| overflowed on value after 9223372036854775807 + } + + let x = A::Ok; +} + +fn f_u64() { + #[repr(u64)] + enum A { + Ok = u64::MAX - 1, + Ok2, + OhNo, //~ ERROR enum discriminant overflowed [E0370] + //~| overflowed on value after 18446744073709551615 + } + + let x = A::Ok; +} + +fn main() { } diff --git a/tests/ui/enum-discriminant/discriminant-overflow.stderr b/tests/ui/enum-discriminant/discriminant-overflow.stderr new file mode 100644 index 000000000..2ecc1839f --- /dev/null +++ b/tests/ui/enum-discriminant/discriminant-overflow.stderr @@ -0,0 +1,67 @@ +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:11:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 127 + | + = note: explicitly set `OhNo = -128` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:22:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 255 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:33:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 32767 + | + = note: explicitly set `OhNo = -32768` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:44:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 65535 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:56:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 2147483647 + | + = note: explicitly set `OhNo = -2147483648` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:68:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 4294967295 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:80:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 9223372036854775807 + | + = note: explicitly set `OhNo = -9223372036854775808` if that is desired outcome + +error[E0370]: enum discriminant overflowed + --> $DIR/discriminant-overflow.rs:92:9 + | +LL | OhNo, + | ^^^^ overflowed on value after 18446744073709551615 + | + = note: explicitly set `OhNo = 0` if that is desired outcome + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0370`. diff --git a/tests/ui/enum-discriminant/issue-50689.rs b/tests/ui/enum-discriminant/issue-50689.rs new file mode 100644 index 000000000..b49f29500 --- /dev/null +++ b/tests/ui/enum-discriminant/issue-50689.rs @@ -0,0 +1,9 @@ +// run-pass +#![allow(unused_variables)] +enum Foo { + Bar = (|x: i32| { }, 42).1, +} + +fn main() { + assert_eq!(Foo::Bar as usize, 42); +} diff --git a/tests/ui/enum/suggest-default-attribute.stderr b/tests/ui/enum/suggest-default-attribute.stderr index fb830d3f7..b56d599a7 100644 --- a/tests/ui/enum/suggest-default-attribute.stderr +++ b/tests/ui/enum/suggest-default-attribute.stderr @@ -7,7 +7,7 @@ LL | #[default] help: consider adding a derive | LL + #[derive(Default)] -LL ~ pub enum Test { +LL | pub enum Test { | error: aborting due to previous error diff --git a/tests/ui/error-codes/E0283.stderr b/tests/ui/error-codes/E0283.stderr index 90316c6e9..89e634a70 100644 --- a/tests/ui/error-codes/E0283.stderr +++ b/tests/ui/error-codes/E0283.stderr @@ -9,8 +9,8 @@ LL | let cont: u32 = Generator::create(); | help: use a fully-qualified path to a specific available implementation (2 found) | -LL | let cont: u32 = ::create(); - | ++++++++ + +LL | let cont: u32 = ::create(); + | +++++++++++++++++++ + error[E0283]: type annotations needed --> $DIR/E0283.rs:35:24 diff --git a/tests/ui/error-codes/E0445.rs b/tests/ui/error-codes/E0445.rs index a9a3aee25..9f29c8167 100644 --- a/tests/ui/error-codes/E0445.rs +++ b/tests/ui/error-codes/E0445.rs @@ -1,12 +1,23 @@ +#![feature(type_privacy_lints)] +#[warn(private_bounds)] +#[warn(private_interfaces)] + +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. + trait Foo { fn dummy(&self) { } } pub trait Bar : Foo {} //~^ ERROR private trait `Foo` in public interface [E0445] +//~| WARNING trait `Foo` is more private than the item `Bar` pub struct Bar2(pub T); //~^ ERROR private trait `Foo` in public interface [E0445] +//~| WARNING trait `Foo` is more private than the item `Bar2` pub fn foo (t: T) {} //~^ ERROR private trait `Foo` in public interface [E0445] +//~| WARNING trait `Foo` is more private than the item `foo` fn main() {} diff --git a/tests/ui/error-codes/E0445.stderr b/tests/ui/error-codes/E0445.stderr index 23b7a3350..4f940868f 100644 --- a/tests/ui/error-codes/E0445.stderr +++ b/tests/ui/error-codes/E0445.stderr @@ -1,5 +1,5 @@ error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:5:1 + --> $DIR/E0445.rs:13:1 | LL | trait Foo { | --------- `Foo` declared as private @@ -7,8 +7,25 @@ LL | trait Foo { LL | pub trait Bar : Foo {} | ^^^^^^^^^^^^^^^^^^^ can't leak private trait +warning: trait `Foo` is more private than the item `Bar` + --> $DIR/E0445.rs:13:1 + | +LL | pub trait Bar : Foo {} + | ^^^^^^^^^^^^^^^^^^^ trait `Bar` is reachable at visibility `pub` + | +note: but trait `Foo` is only usable at visibility `pub(crate)` + --> $DIR/E0445.rs:9:1 + | +LL | trait Foo { + | ^^^^^^^^^ +note: the lint level is defined here + --> $DIR/E0445.rs:2:8 + | +LL | #[warn(private_bounds)] + | ^^^^^^^^^^^^^^ + error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:7:1 + --> $DIR/E0445.rs:16:1 | LL | trait Foo { | --------- `Foo` declared as private @@ -16,15 +33,39 @@ LL | trait Foo { LL | pub struct Bar2(pub T); | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait -error[E0445]: private trait `Foo` in public interface +warning: trait `Foo` is more private than the item `Bar2` + --> $DIR/E0445.rs:16:1 + | +LL | pub struct Bar2(pub T); + | ^^^^^^^^^^^^^^^^^^^^^^^ struct `Bar2` is reachable at visibility `pub` + | +note: but trait `Foo` is only usable at visibility `pub(crate)` --> $DIR/E0445.rs:9:1 | +LL | trait Foo { + | ^^^^^^^^^ + +error[E0445]: private trait `Foo` in public interface + --> $DIR/E0445.rs:19:1 + | LL | trait Foo { | --------- `Foo` declared as private ... LL | pub fn foo (t: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait -error: aborting due to 3 previous errors +warning: trait `Foo` is more private than the item `foo` + --> $DIR/E0445.rs:19:1 + | +LL | pub fn foo (t: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ function `foo` is reachable at visibility `pub` + | +note: but trait `Foo` is only usable at visibility `pub(crate)` + --> $DIR/E0445.rs:9:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error: aborting due to 3 previous errors; 3 warnings emitted For more information about this error, try `rustc --explain E0445`. diff --git a/tests/ui/error-codes/E0560.stderr b/tests/ui/error-codes/E0560.stderr index 6b634f185..bb5ce478a 100644 --- a/tests/ui/error-codes/E0560.stderr +++ b/tests/ui/error-codes/E0560.stderr @@ -4,7 +4,7 @@ error[E0560]: struct `Simba` has no field named `father` LL | let s = Simba { mother: 1, father: 0 }; | ^^^^^^ `Simba` does not have this field | - = note: available fields are: `mother` + = note: all struct fields are already assigned error: aborting due to previous error diff --git a/tests/ui/error-codes/E0637.stderr b/tests/ui/error-codes/E0637.stderr index 78341735e..d9db89ddb 100644 --- a/tests/ui/error-codes/E0637.stderr +++ b/tests/ui/error-codes/E0637.stderr @@ -22,11 +22,10 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here LL | T: Into<&u32>, | ^ explicit lifetime name needed here | -help: consider introducing a higher-ranked lifetime here with `for<'a>` - --> $DIR/E0637.rs:13:8 +help: consider introducing a higher-ranked lifetime here | -LL | T: Into<&u32>, - | ^ +LL | T: for<'a> Into<&'a u32>, + | +++++++ ++ error: aborting due to 3 previous errors diff --git a/tests/ui/error-codes/E0790.stderr b/tests/ui/error-codes/E0790.stderr index fc025a3fc..724876628 100644 --- a/tests/ui/error-codes/E0790.stderr +++ b/tests/ui/error-codes/E0790.stderr @@ -65,8 +65,8 @@ LL | MyTrait2::my_fn(); | help: use a fully-qualified path to a specific available implementation (2 found) | -LL | ::my_fn(); - | +++++++++ + +LL | ::my_fn(); + | +++++++++++++++++++ + error: aborting due to 5 previous errors diff --git a/tests/ui/explicit-tail-calls/become-outside.array.stderr b/tests/ui/explicit-tail-calls/become-outside.array.stderr new file mode 100644 index 000000000..839c20509 --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-outside.array.stderr @@ -0,0 +1,9 @@ +error[E0572]: become statement outside of function body + --> $DIR/become-outside.rs:11:17 + | +LL | struct Bad([(); become f()]); + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0572`. diff --git a/tests/ui/explicit-tail-calls/become-outside.constant.stderr b/tests/ui/explicit-tail-calls/become-outside.constant.stderr new file mode 100644 index 000000000..9b67f08af --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-outside.constant.stderr @@ -0,0 +1,9 @@ +error[E0572]: become statement outside of function body + --> $DIR/become-outside.rs:7:5 + | +LL | become f(); + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0572`. diff --git a/tests/ui/explicit-tail-calls/become-outside.rs b/tests/ui/explicit-tail-calls/become-outside.rs new file mode 100644 index 000000000..51b4389c8 --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-outside.rs @@ -0,0 +1,15 @@ +// revisions: constant array +#![allow(incomplete_features)] +#![feature(explicit_tail_calls)] + +#[cfg(constant)] +const _: () = { + become f(); //[constant]~ error: become statement outside of function body +}; + +#[cfg(array)] +struct Bad([(); become f()]); //[array]~ error: become statement outside of function body + +fn f() {} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/return-lifetime-sub.rs b/tests/ui/explicit-tail-calls/return-lifetime-sub.rs new file mode 100644 index 000000000..8a3f43d4b --- /dev/null +++ b/tests/ui/explicit-tail-calls/return-lifetime-sub.rs @@ -0,0 +1,13 @@ +// check-pass +#![allow(incomplete_features)] +#![feature(explicit_tail_calls)] + +fn _f<'a>() -> &'a [u8] { + become _g(); +} + +fn _g() -> &'static [u8] { + &[0, 1, 2, 3] +} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/return-mismatches.rs b/tests/ui/explicit-tail-calls/return-mismatches.rs new file mode 100644 index 000000000..935a1a1d2 --- /dev/null +++ b/tests/ui/explicit-tail-calls/return-mismatches.rs @@ -0,0 +1,28 @@ +#![allow(incomplete_features)] +#![feature(explicit_tail_calls)] + +fn _f0<'a>() -> &'static [u8] { + become _g0(); //~ error: mismatched types +} + +fn _g0() -> &'static [u8; 1] { + &[0] +} + +fn _f1() { + become _g1(); //~ error: mismatched types +} + +fn _g1() -> ! { + become _g1(); +} + +fn _f2() -> u32 { + become _g2(); //~ error: mismatched types +} + +fn _g2() -> u16 { + 0 +} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/return-mismatches.stderr b/tests/ui/explicit-tail-calls/return-mismatches.stderr new file mode 100644 index 000000000..1dcc35797 --- /dev/null +++ b/tests/ui/explicit-tail-calls/return-mismatches.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/return-mismatches.rs:5:5 + | +LL | become _g0(); + | ^^^^^^^^^^^^ expected `&[u8]`, found `&[u8; 1]` + | + = note: expected reference `&'static [u8]` + found reference `&'static [u8; 1]` + +error[E0308]: mismatched types + --> $DIR/return-mismatches.rs:13:5 + | +LL | become _g1(); + | ^^^^^^^^^^^^ expected `()`, found `!` + | + = note: expected unit type `()` + found type `!` + +error[E0308]: mismatched types + --> $DIR/return-mismatches.rs:21:5 + | +LL | become _g2(); + | ^^^^^^^^^^^^ expected `u32`, found `u16` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/extern/extern-crate-visibility.stderr b/tests/ui/extern/extern-crate-visibility.stderr index 9eeb83ae1..b23972709 100644 --- a/tests/ui/extern/extern-crate-visibility.stderr +++ b/tests/ui/extern/extern-crate-visibility.stderr @@ -9,6 +9,10 @@ note: the crate import `core` is defined here | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ +help: consider importing this module instead + | +LL | use std::cell; + | ~~~~~~~~~ error[E0603]: crate import `core` is private --> $DIR/extern-crate-visibility.rs:9:10 @@ -21,6 +25,10 @@ note: the crate import `core` is defined here | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ +help: consider importing this struct instead + | +LL | std::cell::Cell::new(0); + | ~~~~~~~~~~~~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.rs b/tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.rs new file mode 100644 index 000000000..17e08f511 --- /dev/null +++ b/tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.rs @@ -0,0 +1,10 @@ +extern "C" { + type Item = [T] where [T]: Sized; + //~^ incorrect `type` inside `extern` block + //~| `type`s inside `extern` blocks cannot have `where` clauses + //~| cannot find type `T` in this scope + //~| cannot find type `T` in this scope + //~| extern types are experimental +} + +fn main() {} diff --git a/tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.stderr b/tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.stderr new file mode 100644 index 000000000..bdc675503 --- /dev/null +++ b/tests/ui/extern/issue-112363-extern-item-where-clauses-debug-ice.stderr @@ -0,0 +1,47 @@ +error: incorrect `type` inside `extern` block + --> $DIR/issue-112363-extern-item-where-clauses-debug-ice.rs:2:10 + | +LL | extern "C" { + | ---------- `extern` blocks define existing foreign types and types inside of them cannot have a body +LL | type Item = [T] where [T]: Sized; + | ^^^^ --- the invalid body + | | + | cannot have a body + | + = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html + +error: `type`s inside `extern` blocks cannot have `where` clauses + --> $DIR/issue-112363-extern-item-where-clauses-debug-ice.rs:2:21 + | +LL | extern "C" { + | ---------- `extern` block begins here +LL | type Item = [T] where [T]: Sized; + | ^^^^^^^^^^^^^^^^ help: remove the `where` clause + | + = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html + +error[E0412]: cannot find type `T` in this scope + --> $DIR/issue-112363-extern-item-where-clauses-debug-ice.rs:2:28 + | +LL | type Item = [T] where [T]: Sized; + | ^ not found in this scope + +error[E0412]: cannot find type `T` in this scope + --> $DIR/issue-112363-extern-item-where-clauses-debug-ice.rs:2:18 + | +LL | type Item = [T] where [T]: Sized; + | ^ not found in this scope + +error[E0658]: extern types are experimental + --> $DIR/issue-112363-extern-item-where-clauses-debug-ice.rs:2:5 + | +LL | type Item = [T] where [T]: Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #43467 for more information + = help: add `#![feature(extern_types)]` to the crate attributes to enable + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0412, E0658. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/extern/issue-1251.rs b/tests/ui/extern/issue-1251.rs new file mode 100644 index 000000000..c2c047c79 --- /dev/null +++ b/tests/ui/extern/issue-1251.rs @@ -0,0 +1,16 @@ +// build-pass +#![allow(unused_attributes)] +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +// ignore-wasm32-bare no libc to test ffi with +#![feature(rustc_private)] + +mod rustrt { + extern crate libc; + + extern "C" { + pub fn rust_get_test_int() -> libc::intptr_t; + } +} + +pub fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-explicit_tail_calls.rs b/tests/ui/feature-gates/feature-gate-explicit_tail_calls.rs new file mode 100644 index 000000000..856a7f393 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-explicit_tail_calls.rs @@ -0,0 +1,9 @@ +pub fn you() -> T { + become bottom(); //~ error: `become` expression is experimental +} + +pub fn bottom() -> T { + become you(); //~ error: `become` expression is experimental +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-explicit_tail_calls.stderr b/tests/ui/feature-gates/feature-gate-explicit_tail_calls.stderr new file mode 100644 index 000000000..b58da19c1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-explicit_tail_calls.stderr @@ -0,0 +1,21 @@ +error[E0658]: `become` expression is experimental + --> $DIR/feature-gate-explicit_tail_calls.rs:2:5 + | +LL | become bottom(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112788 for more information + = help: add `#![feature(explicit_tail_calls)]` to the crate attributes to enable + +error[E0658]: `become` expression is experimental + --> $DIR/feature-gate-explicit_tail_calls.rs:6:5 + | +LL | become you(); + | ^^^^^^^^^^^^ + | + = note: see issue #112788 for more information + = help: add `#![feature(explicit_tail_calls)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs index afd14b784..be66560fd 100644 --- a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs +++ b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs @@ -19,5 +19,5 @@ fn bar() { fn main() { let _x = foo::<_>([1,2]); //[normal]~^ ERROR: type provided when a constant was expected - let _y = bar(); + bar(); } diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg_current.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg_current.stderr new file mode 100644 index 000000000..ce39f6b29 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg_current.stderr @@ -0,0 +1,27 @@ +error[E0658]: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + +error: parenthesized generic arguments cannot be used in associated type constraints + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^-- + | | + | help: remove these parentheses + +error[E0220]: associated type `m` not found for `Trait` + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^ associated type `m` not found + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0220, E0658. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg_next.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg_next.stderr new file mode 100644 index 000000000..ce39f6b29 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg_next.stderr @@ -0,0 +1,27 @@ +error[E0658]: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + +error: parenthesized generic arguments cannot be used in associated type constraints + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^-- + | | + | help: remove these parentheses + +error[E0220]: associated type `m` not found for `Trait` + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^ associated type `m` not found + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0220, E0658. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no_current.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no_current.stderr new file mode 100644 index 000000000..d11359e7f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no_current.stderr @@ -0,0 +1,13 @@ +warning: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 + +warning: 1 warning emitted + diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no_next.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no_next.stderr new file mode 100644 index 000000000..d11359e7f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no_next.stderr @@ -0,0 +1,13 @@ +warning: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:17:17 + | +LL | fn foo>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 + +warning: 1 warning emitted + 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 d9bcb65fe..7e8c1eb95 100644 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -1,7 +1,10 @@ // edition: 2021 -// revisions: cfg no +// 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 -//[no] check-pass +// [no_current] check-pass +// [no_next] check-pass // Since we're not adding new syntax, `cfg`'d out RTN must pass. #![feature(async_fn_in_trait)] @@ -10,12 +13,17 @@ trait Trait { async fn m(); } -#[cfg(cfg)] +#[cfg(any(cfg_current, cfg_next))] fn foo>() {} -//[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! +//[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! fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs index 6dfd7f684..3f49020bb 100644 --- a/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs +++ b/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -1,4 +1,3 @@ -// ignore-compare-mode-chalk // check-pass #![feature(type_alias_impl_trait)] use std::fmt::Debug; @@ -12,7 +11,7 @@ fn define() -> Bar { type Foo2 = impl Debug; -fn define2() { +fn define2(_: Foo2) { let x = || -> Foo2 { 42 }; } @@ -21,13 +20,13 @@ type Foo3 = impl Debug; fn define3(x: Foo3) { let y: i32 = x; } -fn define3_1() { +fn define3_1(_: Foo3) { define3(42) } type Foo4 = impl Debug; -fn define4() { +fn define4(_: Foo4) { let y: Foo4 = 42; } diff --git a/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs b/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs new file mode 100644 index 000000000..aad64c9d0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_privacy_lints.rs @@ -0,0 +1,12 @@ +// check-pass + +#![warn(private_interfaces)] //~ WARN unknown lint + //~| WARN unknown lint + //~| WARN unknown lint +#![warn(private_bounds)] //~ WARN unknown lint + //~| WARN unknown lint + //~| WARN unknown lint +#![warn(unnameable_types)] //~ WARN unknown lint + //~| WARN unknown lint + //~| WARN unknown lint +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr b/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr new file mode 100644 index 000000000..79cc974cc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_privacy_lints.stderr @@ -0,0 +1,93 @@ +warning: unknown lint: `private_interfaces` + --> $DIR/feature-gate-type_privacy_lints.rs:3:1 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_interfaces` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + = note: `#[warn(unknown_lints)]` on by default + +warning: unknown lint: `private_bounds` + --> $DIR/feature-gate-type_privacy_lints.rs:6:1 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_bounds` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `unnameable_types` + --> $DIR/feature-gate-type_privacy_lints.rs:9:1 + | +LL | #![warn(unnameable_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `unnameable_types` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_interfaces` + --> $DIR/feature-gate-type_privacy_lints.rs:3:1 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_interfaces` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_bounds` + --> $DIR/feature-gate-type_privacy_lints.rs:6:1 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_bounds` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `unnameable_types` + --> $DIR/feature-gate-type_privacy_lints.rs:9:1 + | +LL | #![warn(unnameable_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `unnameable_types` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_interfaces` + --> $DIR/feature-gate-type_privacy_lints.rs:3:1 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_interfaces` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `private_bounds` + --> $DIR/feature-gate-type_privacy_lints.rs:6:1 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `private_bounds` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: unknown lint: `unnameable_types` + --> $DIR/feature-gate-type_privacy_lints.rs:9:1 + | +LL | #![warn(unnameable_types)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `unnameable_types` lint is unstable + = note: see issue #48054 for more information + = help: add `#![feature(type_privacy_lints)]` to the crate attributes to enable + +warning: 9 warnings emitted + diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index b0dddd3b1..4c0ac5286 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -7,14 +7,14 @@ LL | format!("{:X}", "3"); | required by a bound introduced by this call | = help: the following other types implement trait `UpperHex`: - &T - &mut T - NonZeroI128 - NonZeroI16 - NonZeroI32 - NonZeroI64 - NonZeroI8 - NonZeroIsize + isize + i8 + i16 + i32 + i64 + i128 + usize + u8 and 20 others = note: required for `&str` to implement `UpperHex` note: required by a bound in `core::fmt::rt::Argument::<'a>::new_upper_hex` diff --git a/tests/ui/for-loop-while/issue-1257.rs b/tests/ui/for-loop-while/issue-1257.rs new file mode 100644 index 000000000..de5a6d359 --- /dev/null +++ b/tests/ui/for-loop-while/issue-1257.rs @@ -0,0 +1,11 @@ +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main () { + let mut line = "".to_string(); + let mut i = 0; + while line != "exit".to_string() { + line = if i == 9 { "exit".to_string() } else { "notexit".to_string() }; + i += 1; + } +} diff --git a/tests/ui/for-loop-while/loop-break-value.rs b/tests/ui/for-loop-while/loop-break-value.rs index d7209fc4d..65207fb7f 100644 --- a/tests/ui/for-loop-while/loop-break-value.rs +++ b/tests/ui/for-loop-while/loop-break-value.rs @@ -64,7 +64,7 @@ pub fn main() { }; assert_eq!(trait_unified_3, ["Yes"]); - let regular_break = loop { + let regular_break: () = loop { if true { break; } else { @@ -73,7 +73,7 @@ pub fn main() { }; assert_eq!(regular_break, ()); - let regular_break_2 = loop { + let regular_break_2: () = loop { if true { break Default::default(); } else { @@ -82,7 +82,7 @@ pub fn main() { }; assert_eq!(regular_break_2, ()); - let regular_break_3 = loop { + let regular_break_3: () = loop { break if true { Default::default() } else { @@ -91,13 +91,13 @@ pub fn main() { }; assert_eq!(regular_break_3, ()); - let regular_break_4 = loop { + let regular_break_4: () = loop { break (); break; }; assert_eq!(regular_break_4, ()); - let regular_break_5 = loop { + let regular_break_5: () = loop { break; break (); }; diff --git a/tests/ui/for/issue-20605.current.stderr b/tests/ui/for/issue-20605.current.stderr new file mode 100644 index 000000000..b9a53cbd4 --- /dev/null +++ b/tests/ui/for/issue-20605.current.stderr @@ -0,0 +1,16 @@ +error[E0277]: the size for values of type `dyn Iterator` cannot be known at compilation time + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator` + | + = note: the trait bound `dyn Iterator: IntoIterator` is not satisfied + = note: required for `dyn Iterator` to implement `IntoIterator` +help: consider mutably borrowing here + | +LL | for item in &mut *things { *item = 0 } + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr new file mode 100644 index 000000000..d55efedfc --- /dev/null +++ b/tests/ui/for/issue-20605.next.stderr @@ -0,0 +1,72 @@ +error[E0277]: the trait bound `dyn Iterator: IntoIterator` is not satisfied + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator` + +error[E0277]: the size for values of type ` as IntoIterator>::IntoIter` cannot be known at compilation time + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for ` as IntoIterator>::IntoIter` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error: the type ` as IntoIterator>::IntoIter` is not well-formed + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ + +error[E0277]: ` as IntoIterator>::IntoIter` is not an iterator + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ ` as IntoIterator>::IntoIter` is not an iterator + | + = help: the trait `Iterator` is not implemented for ` as IntoIterator>::IntoIter` + +error: the type `&mut as IntoIterator>::IntoIter` is not well-formed + --> $DIR/issue-20605.rs:5:17 + | +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 + | +LL | for item in *things { *item = 0 } + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `< as IntoIterator>::IntoIter as Iterator>::Item` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error: the type `Option<< as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed + --> $DIR/issue-20605.rs:5:17 + | +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:5 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `< as IntoIterator>::IntoIter as Iterator>::Item` +note: required by a bound in `None` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0277, E0614. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/for/issue-20605.rs b/tests/ui/for/issue-20605.rs new file mode 100644 index 000000000..50d4c3fdd --- /dev/null +++ b/tests/ui/for/issue-20605.rs @@ -0,0 +1,20 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +fn changer<'a>(mut things: Box>) { + for item in *things { *item = 0 } + //[current]~^ ERROR the size for values of type + //[next]~^^ ERROR the trait bound `dyn Iterator: IntoIterator` is not satisfied + //[next]~| ERROR the size for values of type ` as IntoIterator>::IntoIter` cannot be known at compilation time + //[next]~| ERROR the type ` as IntoIterator>::IntoIter` is not well-formed + //[next]~| ERROR ` as IntoIterator>::IntoIter` is not an iterator + //[next]~| ERROR the type `&mut as IntoIterator>::IntoIter` is not well-formed + //[next]~| ERROR the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time + //[next]~| ERROR the type `Option<< as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed + //[next]~| ERROR the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time + //[next]~| ERROR type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced + // FIXME(-Ztrait-solver=next): these error messages are horrible and have to be + // improved before we stabilize the new solver. +} + +fn main() {} diff --git a/tests/ui/generator/layout-error.rs b/tests/ui/generator/layout-error.rs index 7c3d18740..44cfc1d70 100644 --- a/tests/ui/generator/layout-error.rs +++ b/tests/ui/generator/layout-error.rs @@ -24,5 +24,6 @@ fn main() { type F = impl Future; // Check that statics are inhabited computes they layout. static POOL: Task = Task::new(); + //~^ ERROR: cannot check whether the hidden type of `layout_error[b009]::main::F::{opaque#0}` satisfies auto traits Task::spawn(&POOL, || cb()); } diff --git a/tests/ui/generator/layout-error.stderr b/tests/ui/generator/layout-error.stderr index b1a258f4f..ea3b25551 100644 --- a/tests/ui/generator/layout-error.stderr +++ b/tests/ui/generator/layout-error.stderr @@ -4,6 +4,24 @@ error[E0425]: cannot find value `Foo` in this scope LL | let a = Foo; | ^^^ not found in this scope -error: aborting due to previous error +error: cannot check whether the hidden type of `layout_error[b009]::main::F::{opaque#0}` satisfies auto traits + --> $DIR/layout-error.rs:26:18 + | +LL | static POOL: Task = Task::new(); + | ^^^^^^^ + | +note: opaque type is declared here + --> $DIR/layout-error.rs:24:14 + | +LL | type F = impl Future; + | ^^^^^^^^^^^ +note: required because it appears within the type `Task` + --> $DIR/layout-error.rs:9:12 + | +LL | pub struct Task(F); + | ^^^^ + = note: shared static variables must have a type that implements `Sync` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.rs b/tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.rs new file mode 100644 index 000000000..05d205266 --- /dev/null +++ b/tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.rs @@ -0,0 +1,29 @@ +// This test checks that we correctly reject the following unsound code. + +trait Lengthen { + fn lengthen(self) -> T; +} + +impl<'a> Lengthen<&'a str> for &'a str { + fn lengthen(self) -> &'a str { self } +} + +trait Gat { + type Gat<'a>: for<'b> Lengthen>; + + fn lengthen(s: Self::Gat<'_>) -> Self::Gat<'static> { + s.lengthen() + } +} + +impl Gat for () { + type Gat<'a> = &'a str; //~ ERROR: implementation of `Lengthen` is not general enough +} + +fn main() { + let s = "hello, garbage".to_string(); + let borrow: &'static str = <() as Gat>::lengthen(&s); + drop(s); + + println!("{borrow}"); +} diff --git a/tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.stderr b/tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.stderr new file mode 100644 index 000000000..7ea7a7b2d --- /dev/null +++ b/tests/ui/generic-associated-types/gat-bounds-not-checked-with-right-substitutions.stderr @@ -0,0 +1,11 @@ +error: implementation of `Lengthen` is not general enough + --> $DIR/gat-bounds-not-checked-with-right-substitutions.rs:20:20 + | +LL | type Gat<'a> = &'a str; + | ^^^^^^^ implementation of `Lengthen` is not general enough + | + = note: `Lengthen<&'0 str>` would have to be implemented for the type `&'a str`, for any lifetime `'0`... + = note: ...but `Lengthen<&'1 str>` is actually implemented for the type `&'1 str`, for some specific lifetime `'1` + +error: aborting due to previous error + diff --git a/tests/ui/generic-associated-types/issue-88287.stderr b/tests/ui/generic-associated-types/issue-88287.stderr index 1b84cce62..d77076a28 100644 --- a/tests/ui/generic-associated-types/issue-88287.stderr +++ b/tests/ui/generic-associated-types/issue-88287.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/issue-88287.rs:34:9 | LL | type SearchFutureTy<'f, A, B: 'f> - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | async move { todo!() } | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/generic-associated-types/issue-88595.rs b/tests/ui/generic-associated-types/issue-88595.rs index 7de906e7e..5a40a6129 100644 --- a/tests/ui/generic-associated-types/issue-88595.rs +++ b/tests/ui/generic-associated-types/issue-88595.rs @@ -19,5 +19,4 @@ impl<'a> A<'a> for C { type B<'b> = impl Clone; fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope - //~^ ERROR: mismatched types } diff --git a/tests/ui/generic-associated-types/issue-88595.stderr b/tests/ui/generic-associated-types/issue-88595.stderr index d6caed854..2b1a25acf 100644 --- a/tests/ui/generic-associated-types/issue-88595.stderr +++ b/tests/ui/generic-associated-types/issue-88595.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-88595.rs:21:5 + --> $DIR/issue-88595.rs:21:23 | LL | fn a(&'a self) -> Self::B<'a> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ generic argument `'a` used twice + | ^^^^^^^^^^^ generic argument `'a` used twice | note: for this opaque type --> $DIR/issue-88595.rs:19:18 @@ -10,25 +10,5 @@ note: for this opaque type LL | type B<'b> = impl Clone; | ^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/issue-88595.rs:21:23 - | -LL | type B<'b> = impl Clone; - | ---------- the expected opaque type -LL | -LL | fn a(&'a self) -> Self::B<'a> {} - | - ^^^^^^^^^^^ expected opaque type, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression - | - = note: expected opaque type `>::B<'a>` - found unit type `()` -note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/issue-88595.rs:21:5 - | -LL | fn a(&'a self) -> Self::B<'a> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generic-associated-types/issue-90014-tait.rs b/tests/ui/generic-associated-types/issue-90014-tait.rs new file mode 100644 index 000000000..bc3a4e129 --- /dev/null +++ b/tests/ui/generic-associated-types/issue-90014-tait.rs @@ -0,0 +1,23 @@ +//! This test is reporting the wrong error. We need +//! more inherent associated type tests that use opaque types +//! in general. Some variant of this test should compile successfully. +// known-bug: unknown +// edition:2018 + +#![feature(impl_trait_in_assoc_type, inherent_associated_types)] +#![allow(incomplete_features)] + +use std::future::Future; + +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 { () } + } +} + +fn main() {} diff --git a/tests/ui/generic-associated-types/issue-90014-tait.stderr b/tests/ui/generic-associated-types/issue-90014-tait.stderr new file mode 100644 index 000000000..8330a387e --- /dev/null +++ b/tests/ui/generic-associated-types/issue-90014-tait.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/issue-90014-tait.rs:19:9 + | +LL | type Fut<'a> = impl Future; + | ------------------------ the expected future +... +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]` +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 + | +LL | fn make_fut<'a>(&'a self) -> Self::Fut<'a> { + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/generic-associated-types/issue-90014-tait2.rs b/tests/ui/generic-associated-types/issue-90014-tait2.rs new file mode 100644 index 000000000..dacbc93de --- /dev/null +++ b/tests/ui/generic-associated-types/issue-90014-tait2.rs @@ -0,0 +1,46 @@ +//! 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" +// edition:2018 + +#![feature(type_alias_impl_trait)] +#![allow(incomplete_features)] + +use std::future::Future; + +struct Foo<'a>(&'a mut ()); + +type Fut<'a> = impl Future; + +trait Trait<'x> { + type Thing; +} + +impl<'x, T: 'x> Trait<'x> for (T,) { + type Thing = T; +} + +impl Foo<'_> { + fn make_fut(&self) -> Box Trait<'a, Thing = Fut<'a>>> { + Box::new((async { () },)) + } +} + +fn main() {} diff --git a/tests/ui/generic-associated-types/issue-90014-tait2.stderr b/tests/ui/generic-associated-types/issue-90014-tait2.stderr new file mode 100644 index 000000000..3187be333 --- /dev/null +++ b/tests/ui/generic-associated-types/issue-90014-tait2.stderr @@ -0,0 +1,12 @@ +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: aborting due to previous error + diff --git a/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr b/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr index faf4c9eb8..bcd1fbc55 100644 --- a/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr +++ b/tests/ui/generics/issue-65285-incorrect-explicit-lifetime-name-needed.stderr @@ -4,11 +4,10 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here LL | fn should_error() where T : Into<&u32> {} | ^ explicit lifetime name needed here | -help: consider introducing a higher-ranked lifetime here with `for<'a>` - --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:5:32 +help: consider introducing a higher-ranked lifetime here | -LL | fn should_error() where T : Into<&u32> {} - | ^ +LL | fn should_error() where T : for<'a> Into<&'a u32> {} + | +++++++ ++ error[E0106]: missing lifetime specifier --> $DIR/issue-65285-incorrect-explicit-lifetime-name-needed.rs:9:20 diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index 1fd9b6b3b..a13166880 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -11,7 +11,7 @@ fn assert_zst() { //~| NOTE: in this expansion of assert! //~| NOTE: the evaluated program panicked } - let _ = F::::V; + F::::V; } fn foo() { diff --git a/tests/ui/hashmap/hashmap-memory.rs b/tests/ui/hashmap/hashmap-memory.rs index 87f8b6ad5..bd364b349 100644 --- a/tests/ui/hashmap/hashmap-memory.rs +++ b/tests/ui/hashmap/hashmap-memory.rs @@ -1,5 +1,6 @@ // run-pass +#![allow(improper_ctypes_definitions)] #![allow(non_camel_case_types)] #![allow(dead_code)] #![allow(unused_mut)] diff --git a/tests/ui/higher-lifetime-bounds.rs b/tests/ui/higher-lifetime-bounds.rs deleted file mode 100644 index f3393347d..000000000 --- a/tests/ui/higher-lifetime-bounds.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![allow(dead_code, non_camel_case_types)] - -// Test that bounds on higher-kinded lifetime binders are rejected. - -fn bar1<'a, 'b>( - x: &'a i32, - y: &'b i32, - f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) - //~^ ERROR lifetime bounds cannot be used in this context -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( - //~^ ERROR lifetime bounds cannot be used in this context - x: &'a i32, - y: &'b i32, - f: F) -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -fn bar3<'a, 'b, F>( - x: &'a i32, - y: &'b i32, - f: F) - where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 - //~^ ERROR lifetime bounds cannot be used in this context -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -fn bar4<'a, 'b, F>( - x: &'a i32, - y: &'b i32, - f: F) - where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 - //~^ ERROR lifetime bounds cannot be used in this context -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); -//~^ ERROR lifetime bounds cannot be used in this context -struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; -//~^ ERROR lifetime bounds cannot be used in this context -struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; -//~^ ERROR lifetime bounds cannot be used in this context - -struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); -//~^ ERROR lifetime bounds cannot be used in this context - -type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; -//~^ ERROR lifetime bounds cannot be used in this context - -fn main() { - let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; - //~^ ERROR lifetime bounds cannot be used in this context - let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - //~^ ERROR lifetime bounds cannot be used in this context -} diff --git a/tests/ui/higher-lifetime-bounds.stderr b/tests/ui/higher-lifetime-bounds.stderr deleted file mode 100644 index bc6d2288c..000000000 --- a/tests/ui/higher-lifetime-bounds.stderr +++ /dev/null @@ -1,68 +0,0 @@ -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:8:22 - | -LL | f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) - | ^^^ ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:16:34 - | -LL | fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:31:28 - | -LL | where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:43:25 - | -LL | where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:51:28 - | -LL | struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:53:40 - | -LL | struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:55:37 - | -LL | struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:58:29 - | -LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:61:33 - | -LL | type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:65:34 - | -LL | let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:67:42 - | -LL | let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - | ^^^ - -error: aborting due to 11 previous errors - diff --git a/tests/ui/higher-rank-trait-bounds/complex.rs b/tests/ui/higher-rank-trait-bounds/complex.rs deleted file mode 100644 index 8cdfe247e..000000000 --- a/tests/ui/higher-rank-trait-bounds/complex.rs +++ /dev/null @@ -1,28 +0,0 @@ -// check-pass - -trait A<'a> {} -trait B<'b> {} -fn foo() where for<'a> T: A<'a> + 'a {} -trait C<'c>: for<'a> A<'a> + for<'b> B<'b> { - type As; -} -struct D where T: for<'c> C<'c, As=&'c ()> { - t: std::marker::PhantomData, -} -trait E<'e, 'g> { - type As; -} -trait F<'f>: for<'a> A<'a> + for<'e> E<'e, 'f> {} -struct G where T: for<'f> F<'f, As=&'f ()> { - t: std::marker::PhantomData, -} -trait H<'a, 'b> { - type As; -} -trait I<'a>: for<'b> H<'a, 'b> {} - -struct J where T: for<'i> I<'i, As=&'i ()> { - t: std::marker::PhantomData, -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/due-to-where-clause.rs b/tests/ui/higher-rank-trait-bounds/due-to-where-clause.rs deleted file mode 100644 index 1afd15613..000000000 --- a/tests/ui/higher-rank-trait-bounds/due-to-where-clause.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn main() { - test::(&mut 42); //~ ERROR implementation of `Foo` is not general enough -} - -trait Foo<'a> {} - -struct FooS<'a> { - data: &'a mut u32, -} - -impl<'a, 'b: 'a> Foo<'b> for FooS<'a> {} - -fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {} diff --git a/tests/ui/higher-rank-trait-bounds/due-to-where-clause.stderr b/tests/ui/higher-rank-trait-bounds/due-to-where-clause.stderr deleted file mode 100644 index 520938a63..000000000 --- a/tests/ui/higher-rank-trait-bounds/due-to-where-clause.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: implementation of `Foo` is not general enough - --> $DIR/due-to-where-clause.rs:2:5 - | -LL | test::(&mut 42); - | ^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`... - = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1` - -error: aborting due to previous error - diff --git a/tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr b/tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr deleted file mode 100644 index 9af6bc45c..000000000 --- a/tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` - --> $DIR/fn-ptr.rs:12:5 - | -LL | ice(); - | ^^^ expected an `Fn<(&'w (),)>` closure, found `fn(&'w ())` - | - = help: the trait `for<'w> Fn<(&'w (),)>` is not implemented for `fn(&'w ())` -note: required by a bound in `ice` - --> $DIR/fn-ptr.rs:7:25 - | -LL | fn ice() - | --- required by a bound in this function -LL | where -LL | for<'w> fn(&'w ()): Fn(&'w ()), - | ^^^^^^^^^^ required by this bound in `ice` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/fn-ptr.rs b/tests/ui/higher-rank-trait-bounds/fn-ptr.rs deleted file mode 100644 index 853160f96..000000000 --- a/tests/ui/higher-rank-trait-bounds/fn-ptr.rs +++ /dev/null @@ -1,14 +0,0 @@ -// revisions: classic next -//[next] compile-flags: -Ztrait-solver=next -//[next] check-pass - -fn ice() -where - for<'w> fn(&'w ()): Fn(&'w ()), -{ -} - -fn main() { - ice(); - //[classic]~^ ERROR expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` -} diff --git a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.rs b/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.rs deleted file mode 100644 index d34b7a296..000000000 --- a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.rs +++ /dev/null @@ -1,16 +0,0 @@ -// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" - -fn id( - f: &dyn Fn(u32), -) -> &dyn Fn( - &dyn Fn( - &dyn Fn( - &dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(u32))))))))), - ), - ), -) { - f - //~^ ERROR mismatched types -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr b/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr deleted file mode 100644 index 3662cbfb9..000000000 --- a/tests/ui/higher-rank-trait-bounds/hang-on-deeply-nested-dyn.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/hang-on-deeply-nested-dyn.rs:12:5 - | -LL | ) -> &dyn Fn( - | ______- -LL | | &dyn Fn( -LL | | &dyn Fn( -LL | | &dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(u32))))))))), -LL | | ), -LL | | ), -LL | | ) { - | |_- expected `&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))` because of return type -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-rank-trait-bounds/hang-on-deeply-nested-dyn/hang-on-deeply-nested-dyn.long-type-hash.txt' - found reference `&dyn Fn(u32)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs b/tests/ui/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs deleted file mode 100644 index cc766c060..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs +++ /dev/null @@ -1,29 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_variables)] -// Test that we handle binder levels in object types correctly. -// Initially, the reference to `'tcx` in the object type -// `&Typer<'tcx>` was getting an incorrect binder level, yielding -// weird compilation ICEs and so forth. - -// pretty-expanded FIXME #23616 - -trait Typer<'tcx> { - fn method(&self, data: &'tcx isize) -> &'tcx isize { data } -} - -struct Tcx<'tcx> { - fields: &'tcx isize -} - -impl<'tcx> Typer<'tcx> for Tcx<'tcx> { -} - -fn g<'tcx>(typer: &dyn Typer<'tcx>) { -} - -fn check_static_type<'x>(tcx: &Tcx<'x>) { - g(tcx) -} - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.rs b/tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.rs deleted file mode 100644 index a20d03c77..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Regression test for #54302. -// -// We were incorrectly using the "evaluation cache" (which ignored -// region results) to conclude that `&'static str: Deserialize`, even -// though it would require that `for<'de> 'de: 'static`, which is -// clearly false. - -trait Deserialize<'de> {} - -trait DeserializeOwned: for<'de> Deserialize<'de> {} -impl DeserializeOwned for T where T: for<'de> Deserialize<'de> {} - -// Based on this impl, `&'static str` only implements Deserialize<'static>. -// It does not implement for<'de> Deserialize<'de>. -impl<'de: 'a, 'a> Deserialize<'de> for &'a str {} - -fn main() { - fn assert_deserialize_owned() {} - assert_deserialize_owned::<&'static str>(); //~ ERROR - - // It correctly does not implement for<'de> Deserialize<'de>. - // fn assert_hrtb Deserialize<'de>>() {} - // assert_hrtb::<&'static str>(); -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.stderr deleted file mode 100644 index f014eab86..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-cache-issue-54302.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: implementation of `Deserialize` is not general enough - --> $DIR/hrtb-cache-issue-54302.rs:19:5 - | -LL | assert_deserialize_owned::<&'static str>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough - | - = note: `&'static str` must implement `Deserialize<'0>`, for any lifetime `'0`... - = note: ...but `&str` actually implements `Deserialize<'1>`, for some specific lifetime `'1` - -error: aborting due to previous error - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.rs b/tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.rs deleted file mode 100644 index e83686404..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Test that an impl with only one bound region `'a` cannot be used to -// satisfy a constraint where there are two bound regions. - -trait Foo { - fn foo(&self, x: X) { } -} - -fn want_foo2() - where T : for<'a,'b> Foo<(&'a isize, &'b isize)> -{ -} - -fn want_foo1() - where T : for<'z> Foo<(&'z isize, &'z isize)> -{ -} - -// Expressed as a where clause - -struct SomeStruct; - -impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct -{ -} - -fn a() { want_foo1::(); } // OK -- foo wants just one region -fn b() { want_foo2::(); } -//~^ ERROR implementation of -//~| ERROR implementation of - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.stderr deleted file mode 100644 index 46f5308dd..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-conflate-regions.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 - | -LL | fn b() { want_foo2::(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... - = note: ...but it actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` - -error: implementation of `Foo` is not general enough - --> $DIR/hrtb-conflate-regions.rs:27:10 - | -LL | fn b() { want_foo2::(); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... - = note: ...but it actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.rs b/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.rs deleted file mode 100644 index 05d3e1a43..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Test the case where the `Self` type has a bound lifetime that must -// be adjusted in the fn signature. Issue #19537. - -use std::collections::HashMap; - -struct Foo<'a> { - map: HashMap -} - -impl<'a> Foo<'a> { - fn new() -> Foo<'a> { panic!() } - fn insert(&'a mut self) { } -} -fn main() { - let mut foo = Foo::new(); - foo.insert(); - foo.insert(); //~ ERROR cannot borrow -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.stderr deleted file mode 100644 index fa391ecba..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-in-receiver.stderr +++ /dev/null @@ -1,14 +0,0 @@ -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 -LL | foo.insert(); - | ^^^^^^^^^^^^ - | | - | second mutable borrow occurs here - | first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs b/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs deleted file mode 100644 index 8431226a3..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass -#![allow(dead_code)] -// pretty-expanded FIXME #23616 - -trait Typer<'tcx> { - fn method(&self, data: &'tcx isize) -> &'tcx isize { data } - fn dummy(&self) { } -} - -fn g(_: F) where F: FnOnce(&dyn Typer) {} - -fn h() { - g(|typer| typer.dummy()) -} - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.rs b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.rs deleted file mode 100644 index 567802376..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Test an `exists<'a> { forall<'b> { 'a = 'b } }` pattern -- which should not compile! -// -// In particular, we test this pattern in trait solving, where it is not connected -// to any part of the source code. - -fn foo<'a>() -> fn(&'a u32) { - panic!() -} - -fn main() { - // Here, proving that `fn(&'a u32) <: for<'b> fn(&'b u32)`: - // - // - instantiates `'b` with a placeholder `!b`, - // - requires that `&!b u32 <: &'a u32` and hence that `!b: 'a`, - // - but we can never know this. - - let _: for<'b> fn(&'b u32) = foo(); //~ ERROR mismatched types -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.stderr deleted file mode 100644 index 9914783d9..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-fn.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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 - | - = note: expected fn pointer `for<'b> fn(&'b u32)` - found fn pointer `fn(&u32)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.rs b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.rs deleted file mode 100644 index 921061916..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Test a case where variance and higher-ranked types interact in surprising ways. -// -// In particular, we test this pattern in trait solving, where it is not connected -// to any part of the source code. - -trait Trait {} - -fn foo() -where - T: Trait fn(&'b u32)>, -{ -} - -impl<'a> Trait for () {} - -fn main() { - // Here, proving that `(): Trait fn(&'b u32)>` uses the impl: - // - // - The impl provides the clause `forall<'a> { (): Trait }` - // - We instantiate `'a` existentially to get `(): Trait` - // - We unify `fn(&?a u32)` with `for<'b> fn(&'b u32)` -- this does a - // "bidirectional" subtyping check, so we wind up with: - // - `fn(&?a u32) <: for<'b> fn(&'b u32)` :- - // - `&'!b u32 <: &?a u32` - // - `!'b: ?a` -- solveable if `?a` is inferred to `'empty` - // - `for<'b> fn(&'b u32) <: fn(&?a u32)` :- - // - `&?a u32 u32 <: &?b u32` - // - `?a: ?b` -- solveable if `?b` is also inferred to `'empty` - // - So the subtyping check succeeds, somewhat surprisingly. - // This is because we can use `'empty`. - // - // NB. *However*, the reinstated leak-check gives an error here. - - foo::<()>(); - //~^ ERROR implementation of `Trait` is not general enough -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.stderr deleted file mode 100644 index 364b613fc..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-contravariant.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 - | -LL | foo::<()>(); - | ^^^^^^^^^^^ implementation of `Trait` is not general enough - | - = note: `()` must implement `Trait fn(&'b u32)>` - = note: ...but it actually implements `Trait`, for some specific lifetime `'0` - -error: aborting due to previous error - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-covariant.rs b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-covariant.rs deleted file mode 100644 index f95496a6c..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-covariant.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Test a case where variance and higher-ranked types interact in surprising ways. -// -// In particular, we test this pattern in trait solving, where it is not connected -// to any part of the source code. -// -// check-pass - -trait Trait {} - -fn foo() -where - T: Trait fn(fn(&'b u32))>, -{ -} - -impl<'a> Trait for () {} - -fn main() { - // Here, proving that `(): Trait fn(&'b u32)>` uses the impl: - // - // - The impl provides the clause `forall<'a> { (): Trait }` - // - We instantiate `'a` existentially to get `(): Trait` - // - We unify `fn(fn(&?a u32))` with `for<'b> fn(fn(&'b u32))` -- this does a - // "bidirectional" subtyping check, so we wind up with: - // - `fn(fn(&?a u32)) <: for<'b> fn(fn(&'b u32))` :- - // - `fn(&!b u32) <: fn(&?a u32)` - // - `&?a u32 <: &!b u32` - // - `?a: !'b` -- solveable if `?a` is inferred to `'static` - // - `for<'b> fn(fn(&'b u32)) <: fn(fn(&?a u32))` :- - // - `fn(&?a u32) <: fn(&?b u32)` - // - `&?b u32 <: &?a u32` - // - `?b: ?a` -- solveable if `?b` is inferred to `'static` - // - So the subtyping check succeeds, somewhat surprisingly. - // This is because we can use `'static`. - - foo::<()>(); -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.rs b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.rs deleted file mode 100644 index 9b9e4496a..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Test an `exists<'a> { forall<'b> { 'a = 'b } }` pattern -- which should not compile! -// -// In particular, we test this pattern in trait solving, where it is not connected -// to any part of the source code. - -use std::cell::Cell; - -trait Trait {} - -fn foo() -where - T: Trait fn(Cell<&'b u32>)>, -{ -} - -impl<'a> Trait)> for () {} - -fn main() { - // Here, proving that `(): Trait fn(&'b u32)>` uses the impl: - // - // - The impl provides the clause `forall<'a> { (): Trait }` - // - We instantiate `'a` existentially to get `(): Trait` - // - We unify `fn(&?a u32)` with `for<'b> fn(&'b u32)` - // - This requires (among other things) instantiating `'b` universally, - // yielding `fn(&!b u32)`, in a fresh universe U1 - // - So we get `?a = !b` but the universe U0 assigned to `?a` cannot name `!b`. - - foo::<()>(); //~ ERROR implementation of `Trait` is not general enough -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.stderr deleted file mode 100644 index cb2ce8a41..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-exists-forall-trait-invariant.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 - | -LL | foo::<()>(); - | ^^^^^^^^^^^ implementation of `Trait` is not general enough - | - = note: `()` must implement `Trait fn(Cell<&'b u32>)>` - = note: ...but it actually implements `Trait)>`, for some specific lifetime `'0` - -error: aborting due to previous error - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs b/tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs deleted file mode 100644 index ff84ad9d2..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs +++ /dev/null @@ -1,27 +0,0 @@ -// run-pass -// A basic test of using a higher-ranked trait bound. - - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b; - -struct Identity; - -impl<'a, T> FnLike<&'a T, &'a T> for Identity { - fn call(&self, arg: &'a T) -> &'a T { - arg - } -} - -fn call_repeatedly(f: &FnObject) { - let x = 3; - let y = f.call(&x); - assert_eq!(3, *y); -} - -fn main() { - call_repeatedly(&Identity); -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait.rs b/tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait.rs deleted file mode 100644 index afab9986c..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-fn-like-trait.rs +++ /dev/null @@ -1,27 +0,0 @@ -// run-pass -// A basic test of using a higher-ranked trait bound. - - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -struct Identity; - -impl<'a, T> FnLike<&'a T, &'a T> for Identity { - fn call(&self, arg: &'a T) -> &'a T { - arg - } -} - -fn call_repeatedly(f: F) - where F : for<'a> FnLike<&'a isize, &'a isize> -{ - let x = 3; - let y = f.call(&x); - assert_eq!(3, *y); -} - -fn main() { - call_repeatedly(Identity); -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs b/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs deleted file mode 100644 index f9ae1429e..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Test HRTB supertraits with several levels of expansion required. - -trait Foo<'tcx> -{ - fn foo(&'tcx self) -> &'tcx isize; -} - -trait Bar<'ccx> - : for<'tcx> Foo<'tcx> -{ - fn bar(&'ccx self) -> &'ccx isize; -} - -trait Baz - : for<'ccx> Bar<'ccx> -{ - fn dummy(&self); -} - -trait Qux - : Bar<'static> -{ - fn dummy(&self); -} - -fn want_foo_for_any_tcx(f: &F) - where F : for<'tcx> Foo<'tcx> -{ -} - -fn want_bar_for_any_ccx(b: &B) - where B : for<'ccx> Bar<'ccx> -{ -} - -fn want_baz(b: &B) - where B : Baz -{ - want_foo_for_any_tcx(b); - want_bar_for_any_ccx(b); -} - -fn want_qux(b: &B) - where B : Qux -{ - want_foo_for_any_tcx(b); - want_bar_for_any_ccx(b); //~ ERROR -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr deleted file mode 100644 index b1b8ffa8c..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied - --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26 - | -LL | want_bar_for_any_ccx(b); - | -------------------- ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` - | | - | required by a bound introduced by this call - | -note: required by a bound in `want_bar_for_any_ccx` - --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:32:15 - | -LL | fn want_bar_for_any_ccx(b: &B) - | -------------------- required by a bound in this function -LL | where B : for<'ccx> Bar<'ccx> - | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx` -help: consider further restricting this bound - | -LL | where B : Qux + for<'ccx> Bar<'ccx> - | +++++++++++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs b/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs deleted file mode 100644 index 48ebe5017..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Test a trait (`Bar`) with a higher-ranked supertrait. - -trait Foo<'tcx> -{ - fn foo(&'tcx self) -> &'tcx isize; -} - -trait Bar<'ccx> - : for<'tcx> Foo<'tcx> -{ - fn bar(&'ccx self) -> &'ccx isize; -} - -fn want_foo_for_some_tcx<'x,F>(f: &'x F) - where F : Foo<'x> -{ - want_foo_for_some_tcx(f); - want_foo_for_any_tcx(f); //~ ERROR not satisfied -} - -fn want_foo_for_any_tcx(f: &F) - where F : for<'tcx> Foo<'tcx> -{ - want_foo_for_some_tcx(f); - want_foo_for_any_tcx(f); -} - -fn want_bar_for_some_ccx<'x,B>(b: &B) - where B : Bar<'x> -{ - want_foo_for_some_tcx(b); - want_foo_for_any_tcx(b); - - want_bar_for_some_ccx(b); - want_bar_for_any_ccx(b); //~ ERROR not satisfied -} - -fn want_bar_for_any_ccx(b: &B) - where B : for<'ccx> Bar<'ccx> -{ - want_foo_for_some_tcx(b); - want_foo_for_any_tcx(b); - - want_bar_for_some_ccx(b); - want_bar_for_any_ccx(b); -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.stderr deleted file mode 100644 index 7f96909b6..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-higher-ranker-supertraits.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0277]: the trait bound `for<'tcx> F: Foo<'tcx>` is not satisfied - --> $DIR/hrtb-higher-ranker-supertraits.rs:18:26 - | -LL | want_foo_for_any_tcx(f); - | -------------------- ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` - | | - | required by a bound introduced by this call - | -note: required by a bound in `want_foo_for_any_tcx` - --> $DIR/hrtb-higher-ranker-supertraits.rs:22:15 - | -LL | fn want_foo_for_any_tcx(f: &F) - | -------------------- required by a bound in this function -LL | where F : for<'tcx> Foo<'tcx> - | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_foo_for_any_tcx` -help: consider further restricting this bound - | -LL | where F : Foo<'x> + for<'tcx> Foo<'tcx> - | +++++++++++++++++++++ - -error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied - --> $DIR/hrtb-higher-ranker-supertraits.rs:35:26 - | -LL | want_bar_for_any_ccx(b); - | -------------------- ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` - | | - | required by a bound introduced by this call - | -note: required by a bound in `want_bar_for_any_ccx` - --> $DIR/hrtb-higher-ranker-supertraits.rs:39:15 - | -LL | fn want_bar_for_any_ccx(b: &B) - | -------------------- required by a bound in this function -LL | where B : for<'ccx> Bar<'ccx> - | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx` -help: consider further restricting this bound - | -LL | where B : Bar<'x> + for<'ccx> Bar<'ccx> - | +++++++++++++++++++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.rs b/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.rs deleted file mode 100644 index 89fc4705a..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Test that the `'a` in the where clause correctly links the region -// of the output to the region of the input. - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -fn call_repeatedly(f: F) - where F : for<'a> FnLike<&'a isize, &'a isize> -{ - // Result is stored: cannot re-assign `x` - let mut x = 3; - let y = f.call(&x); - x = 5; //~ ERROR cannot assign to `x` because it is borrowed - - // Result is not stored: can re-assign `x` - let mut x = 3; - f.call(&x); - f.call(&x); - f.call(&x); - x = 5; - drop(y); -} - -fn main() { -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr deleted file mode 100644 index 25af011e3..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-identity-fn-borrows.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:14:5 - | -LL | let y = f.call(&x); - | -- `x` is borrowed here -LL | x = 5; - | ^^^^^ `x` is assigned to here but it was already borrowed -... -LL | drop(y); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.rs b/tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.rs deleted file mode 100644 index 8fb4218f8..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Test a case where you have an impl of `Foo` for all `X` that -// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. - -trait Foo { - fn foo(&self, x: X) { } -} - -fn want_hrtb() - where T : for<'a> Foo<&'a isize> -{ -} - -// AnyInt implements Foo<&'a isize> for any 'a, so it is a match. -struct AnyInt; -impl<'a> Foo<&'a isize> for AnyInt { } -fn give_any() { - want_hrtb::() -} - -// StaticInt only implements Foo<&'static isize>, so it is an error. -struct StaticInt; -impl Foo<&'static isize> for StaticInt { } -fn give_static() { - want_hrtb::() //~ ERROR -} - -// &'a u32 only implements Foo<&'a isize> for specific 'a, so it is an error. -impl<'a> Foo<&'a isize> for &'a u32 { } -fn give_some<'a>() { - want_hrtb::<&'a u32>() - //~^ ERROR lifetime may not live long enough - //~| ERROR implementation of `Foo` is not general enough -} - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr deleted file mode 100644 index 31e11e128..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:24:5 - | -LL | want_hrtb::() - | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`... - = note: ...but it actually implements `Foo<&'static isize>` - -error: lifetime may not live long enough - --> $DIR/hrtb-just-for-static.rs:30:5 - | -LL | fn give_some<'a>() { - | -- lifetime `'a` defined here -LL | want_hrtb::<&'a u32>() - | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-just-for-static.rs:9:15 - | -LL | where T : for<'a> Foo<&'a isize> - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:30:5 - | -LL | want_hrtb::<&'a u32>() - | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo<&'0 isize>` would have to be implemented for the type `&u32`, for any lifetime `'0`... - = note: ...but `Foo<&'1 isize>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` - -error: aborting due to 3 previous errors - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.rs b/tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.rs deleted file mode 100644 index 4b096be59..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Test that Fn-family traits with lifetime parameters shouldn't compile and -// we suggest the usage of higher-rank trait bounds instead. - -fn fa(_: impl Fn<'a>(&'a str) -> bool) {} -//~^ ERROR `Fn` traits cannot take lifetime parameters - -fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {} -//~^ ERROR `Fn` traits cannot take lifetime parameters - -fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {} -//~^ ERROR `Fn` traits cannot take lifetime parameters - -use std::ops::Fn as AliasedFn; -fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {} -//~^ ERROR `Fn` traits cannot take lifetime parameters - -fn fe(_: F) where F: Fn<'a>(&'a str) -> bool {} -//~^ ERROR `Fn` traits cannot take lifetime parameters - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.stderr deleted file mode 100644 index e8f6d63b5..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-malformed-lifetime-generics.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error: `Fn` traits cannot take lifetime parameters - --> $DIR/hrtb-malformed-lifetime-generics.rs:4:17 - | -LL | fn fa(_: impl Fn<'a>(&'a str) -> bool) {} - | ^^^^ - | -help: consider using a higher-ranked trait bound instead - | -LL - fn fa(_: impl Fn<'a>(&'a str) -> bool) {} -LL + fn fa(_: impl for<'a> Fn(&'a str) -> bool) {} - | - -error: `Fn` traits cannot take lifetime parameters - --> $DIR/hrtb-malformed-lifetime-generics.rs:7:20 - | -LL | fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {} - | ^^^^^^^^ - | -help: consider using a higher-ranked trait bound instead - | -LL - fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {} -LL + fn fb(_: impl for<'a, 'b> FnMut(&'a str, &'b str) -> bool) {} - | - -error: `Fn` traits cannot take lifetime parameters - --> $DIR/hrtb-malformed-lifetime-generics.rs:10:41 - | -LL | fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {} - | ^^^^ - | -help: consider using a higher-ranked trait bound instead - | -LL - fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {} -LL + fn fc(_: impl std::fmt::Display + for<'a> FnOnce(&'a str) -> bool + std::fmt::Debug) {} - | - -error: `Fn` traits cannot take lifetime parameters - --> $DIR/hrtb-malformed-lifetime-generics.rs:14:24 - | -LL | fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {} - | ^^^^ - | -help: consider using a higher-ranked trait bound instead - | -LL - fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {} -LL + fn fd(_: impl for<'a> AliasedFn(&'a str) -> bool) {} - | - -error: `Fn` traits cannot take lifetime parameters - --> $DIR/hrtb-malformed-lifetime-generics.rs:17:27 - | -LL | fn fe(_: F) where F: Fn<'a>(&'a str) -> bool {} - | ^^^^ - | -help: consider using a higher-ranked trait bound instead - | -LL - fn fe(_: F) where F: Fn<'a>(&'a str) -> bool {} -LL + fn fe(_: F) where F: for<'a> Fn(&'a str) -> bool {} - | - -error: aborting due to 5 previous errors - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-opt-in-copy.rs b/tests/ui/higher-rank-trait-bounds/hrtb-opt-in-copy.rs deleted file mode 100644 index 04519f116..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-opt-in-copy.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -// Test that we handle binder levels correctly when checking whether a -// type can implement `Copy`. In particular, we had a bug where we failed to -// liberate the late-bound regions from the impl, and thus wound up -// searching for an impl of `for<'tcx> Foo<&'tcx T>`. The impl that -// exists however is `impl Copy for Foo` and the current rules -// did not consider that a match (something I would like to revise in -// a later PR). - -#![allow(dead_code)] - -use std::marker::PhantomData; - -#[derive(Copy, Clone)] -struct Foo { x: T } - -type Ty<'tcx> = &'tcx TyS<'tcx>; - -enum TyS<'tcx> { - Boop(PhantomData<*mut &'tcx ()>) -} - -#[derive(Copy, Clone)] -enum Bar<'tcx> { - Baz(Foo>) -} - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-parse.rs b/tests/ui/higher-rank-trait-bounds/hrtb-parse.rs deleted file mode 100644 index 1fab9758c..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-parse.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-pass -// Test that we can parse all the various places that a `for` keyword -// can appear representing universal quantification. - -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] -#![allow(dead_code)] - -trait Get { - fn get(&self, arg: A) -> R; -} - -// Parse HRTB with explicit `for` in a where-clause: - -fn foo00(t: T) - where T : for<'a> Get<&'a i32, &'a i32> -{ -} - -fn foo01 Get<&'a i32, &'a i32>>(t: T) -{ -} - -// Parse HRTB with explicit `for` in various sorts of types: - -fn foo10(t: Box Get>) { } -fn foo11(t: Box Fn(i32) -> i32>) { } - -fn foo20(t: for<'a> fn(i32) -> i32) { } -fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } -fn foo22(t: for<'a> extern "C" fn(i32) -> i32) { } -fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { } - -fn main() { -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.polonius.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.polonius.stderr deleted file mode 100644 index a94c80eb3..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.polonius.stderr +++ /dev/null @@ -1,71 +0,0 @@ -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:16:1 - | -LL | / fn no_hrtb<'b, T>(mut t: T) -LL | | where -LL | | T: Bar<&'b isize>, -LL | | { -... | -LL | | no_hrtb(&mut t); - | | --------------- recursive call site -LL | | } - | |_^ cannot return without recursing - | - = note: `#[warn(unconditional_recursion)]` on by default - = help: a `loop` may express intention better if this is on purpose - -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:25:1 - | -LL | / fn bar_hrtb(mut t: T) -LL | | where -LL | | T: for<'b> Bar<&'b isize>, -LL | | { -... | -LL | | bar_hrtb(&mut t); - | | ---------------- recursive call site -LL | | } - | |_^ cannot return without recursing - | - = help: a `loop` may express intention better if this is on purpose - -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:35:1 - | -LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T) -LL | | where -LL | | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, -LL | | { -... | -LL | | foo_hrtb_bar_not(&mut t); - | | ------------------------ recursive call site -LL | | -LL | | -LL | | } - | |_^ cannot return without recursing - | - = help: a `loop` may express intention better if this is on purpose - -error: higher-ranked subtype error - --> $DIR/hrtb-perfect-forwarding.rs:43:5 - | -LL | foo_hrtb_bar_not(&mut t); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:48:1 - | -LL | / fn foo_hrtb_bar_hrtb(mut t: T) -LL | | where -LL | | T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, -LL | | { -LL | | // OK -- now we have `T : for<'b> Bar<&'b isize>`. -LL | | foo_hrtb_bar_hrtb(&mut t); - | | ------------------------- recursive call site -LL | | } - | |_^ cannot return without recursing - | - = help: a `loop` may express intention better if this is on purpose - -error: aborting due to previous error; 4 warnings emitted - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.rs b/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.rs deleted file mode 100644 index d45fa183c..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Test a case where you have an impl of `Foo` for all `X` that -// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. - -trait Foo { - fn foo(&mut self, x: X) {} -} - -trait Bar { - fn bar(&mut self, x: X) {} -} - -impl<'a, X, F> Foo for &'a mut F where F: Foo + Bar {} - -impl<'a, X, F> Bar for &'a mut F where F: Bar {} - -fn no_hrtb<'b, T>(mut t: T) //~ WARN function cannot return -where - T: Bar<&'b isize>, -{ - // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that - // `&mut T : Bar<&'b isize>`. - no_hrtb(&mut t); -} - -fn bar_hrtb(mut t: T) //~ WARN function cannot return -where - T: for<'b> Bar<&'b isize>, -{ - // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above - // ensures that `&mut T : for<'b> Bar<&'b isize>`. This is an - // example of a "perfect forwarding" impl. - bar_hrtb(&mut t); -} - -fn foo_hrtb_bar_not<'b, T>(mut t: T) //~ WARN function cannot return -where - T: for<'a> Foo<&'a isize> + Bar<&'b isize>, -{ - // Not OK -- The forwarding impl for `Foo` requires that `Bar` also - // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a - // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where - // clause only specifies `T : Bar<&'b isize>`. - foo_hrtb_bar_not(&mut t); - //~^ ERROR implementation of `Bar` is not general enough - //~^^ ERROR lifetime may not live long enough -} - -fn foo_hrtb_bar_hrtb(mut t: T) //~ WARN function cannot return -where - T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, -{ - // OK -- now we have `T : for<'b> Bar<&'b isize>`. - foo_hrtb_bar_hrtb(&mut t); -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr deleted file mode 100644 index 727b9e6be..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr +++ /dev/null @@ -1,79 +0,0 @@ -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:16:1 - | -LL | / fn no_hrtb<'b, T>(mut t: T) -LL | | where -LL | | T: Bar<&'b isize>, - | |______________________^ cannot return without recursing -... -LL | no_hrtb(&mut t); - | --------------- recursive call site - | - = help: a `loop` may express intention better if this is on purpose - = note: `#[warn(unconditional_recursion)]` on by default - -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:25:1 - | -LL | / fn bar_hrtb(mut t: T) -LL | | where -LL | | T: for<'b> Bar<&'b isize>, - | |______________________________^ cannot return without recursing -... -LL | bar_hrtb(&mut t); - | ---------------- recursive call site - | - = help: a `loop` may express intention better if this is on purpose - -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:35:1 - | -LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T) -LL | | where -LL | | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, - | |_______________________________________________^ cannot return without recursing -... -LL | foo_hrtb_bar_not(&mut t); - | ------------------------ recursive call site - | - = help: a `loop` may express intention better if this is on purpose - -error: lifetime may not live long enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 - | -LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) - | -- lifetime `'b` defined here -... -LL | foo_hrtb_bar_not(&mut t); - | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` - | -note: due to current limitations in the borrow checker, this implies a `'static` lifetime - --> $DIR/hrtb-perfect-forwarding.rs:37:8 - | -LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: implementation of `Bar` is not general enough - --> $DIR/hrtb-perfect-forwarding.rs:43:5 - | -LL | foo_hrtb_bar_not(&mut t); - | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough - | - = note: `T` must implement `Bar<&'0 isize>`, for any lifetime `'0`... - = note: ...but it actually implements `Bar<&'1 isize>`, for some specific lifetime `'1` - -warning: function cannot return without recursing - --> $DIR/hrtb-perfect-forwarding.rs:48:1 - | -LL | / fn foo_hrtb_bar_hrtb(mut t: T) -LL | | where -LL | | T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, - | |_______________________________________________________^ cannot return without recursing -... -LL | foo_hrtb_bar_hrtb(&mut t); - | ------------------------- recursive call site - | - = help: a `loop` may express intention better if this is on purpose - -error: aborting due to 2 previous errors; 4 warnings emitted - diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs b/tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs deleted file mode 100644 index 42247798f..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_variables)] -// pretty-expanded FIXME #23616 - -// Test that `F : Fn(isize) -> isize + Send` is interpreted as two -// distinct bounds on `F`. - -fn foo1(f: F) - where F : FnOnce(isize) -> isize + Send -{ - bar(f); -} - -fn foo2(f: F) - where F : FnOnce(isize) -> isize + Send -{ - baz(f); -} - -fn bar(f: F) { } - -fn baz isize>(f: F) { } - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs b/tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs deleted file mode 100644 index 6834c392d..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass -#![allow(dead_code)] -// pretty-expanded FIXME #23616 - -// Test that `Fn(isize) -> isize + 'static` parses as `(Fn(isize) -> isize) + -// 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would -// cause a compilation error. Issue #18772. - -fn adder(y: isize) -> Box isize + 'static> { - Box::new(move |x| y + x) -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs b/tests/ui/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs deleted file mode 100644 index b97fdf4df..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -#![allow(dead_code)] -// A basic test of using a higher-ranked trait bound. - -// pretty-expanded FIXME #23616 - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b; - -fn main() { -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs b/tests/ui/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs deleted file mode 100644 index d8c726cdd..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs +++ /dev/null @@ -1,26 +0,0 @@ -// run-pass -// A basic test of using a higher-ranked trait bound. - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -type FnObject<'b> = dyn for<'a> FnLike<(&'a i32,), &'a i32> + 'b; - -struct Identity; - -impl<'a, T> FnLike<(&'a T,), &'a T> for Identity { - fn call(&self, (arg,): (&'a T,)) -> &'a T { - arg - } -} - -fn call_repeatedly(f: &FnObject) { - let x = 3; - let y = f.call((&x,)); - assert_eq!(3, *y); -} - -fn main() { - call_repeatedly(&Identity); -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs b/tests/ui/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs deleted file mode 100644 index 41ebb3f5a..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-pass -#![allow(dead_code)] -// Test that `&PrinterSupport`, which is really short for `&'a -// PrinterSupport<'b>`, gets properly expanded when it appears in a -// closure type. This used to result in messed up De Bruijn indices. - -// pretty-expanded FIXME #23616 - -trait PrinterSupport<'ast> { - fn ast_map(&self) -> Option<&'ast usize> { None } -} - -struct NoAnn<'ast> { - f: Option<&'ast usize> -} - -impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> { -} - -fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&dyn PrinterSupport) { - let annotation = NoAnn { f: f }; - g(&annotation) -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-type-outlives.rs b/tests/ui/higher-rank-trait-bounds/hrtb-type-outlives.rs deleted file mode 100644 index 88d396101..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-type-outlives.rs +++ /dev/null @@ -1,46 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_variables)] -// Test what happens when a HR obligation is applied to an impl with -// "outlives" bounds. Currently we're pretty conservative here; this -// will probably improve in time. - -trait Foo { - fn foo(&self, x: X) { } -} - -fn want_foo() - where T : for<'a> Foo<&'a isize> -{ -} - -// Expressed as a where clause - -struct SomeStruct { - x: X -} - -impl<'a,X> Foo<&'a isize> for SomeStruct - where X : 'a -{ -} - -fn one() { - want_foo::>(); -} - -// Expressed as shorthand - -struct AnotherStruct { - x: X -} - -impl<'a,X:'a> Foo<&'a isize> for AnotherStruct -{ -} - -fn two() { - want_foo::>(); -} - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs b/tests/ui/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs deleted file mode 100644 index a4a8a5ac6..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass -// Test HRTB used with the `Fn` trait. - -fn foo(f: F) { - let x = 22; - f(&x); -} - -fn main() { - foo(|x: &isize| println!("{}", *x)); -} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.rs b/tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.rs deleted file mode 100644 index 1a9bb2523..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn a() where for T: Copy {} -//~^ ERROR only lifetime parameters can be used in this context - -fn b() where for [(); C]: Copy {} -//~^ ERROR only lifetime parameters can be used in this context - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.stderr b/tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.stderr deleted file mode 100644 index 765ea9f78..000000000 --- a/tests/ui/higher-rank-trait-bounds/hrtb-wrong-kind.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: only lifetime parameters can be used in this context - --> $DIR/hrtb-wrong-kind.rs:1:18 - | -LL | fn a() where for T: Copy {} - | ^ - | - = note: see issue #108185 for more information - = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable - -error[E0658]: only lifetime parameters can be used in this context - --> $DIR/hrtb-wrong-kind.rs:4:24 - | -LL | fn b() where for [(); C]: Copy {} - | ^ - | - = note: see issue #108185 for more information - = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-100689.rs b/tests/ui/higher-rank-trait-bounds/issue-100689.rs deleted file mode 100644 index 2db7f8a35..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-100689.rs +++ /dev/null @@ -1,29 +0,0 @@ -// check-pass - -struct Foo<'a> { - foo: &'a mut usize, -} - -trait Bar<'a> { - type FooRef<'b> - where - 'a: 'b; - fn uwu(foo: Foo<'a>, f: impl for<'b> FnMut(Self::FooRef<'b>)); -} -impl<'a> Bar<'a> for () { - type FooRef<'b> - = - &'b Foo<'a> - where - 'a : 'b, - ; - - fn uwu( - foo: Foo<'a>, - mut f: impl for<'b> FnMut(&'b Foo<'a>), //relevant part - ) { - f(&foo); - } -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-102899.rs b/tests/ui/higher-rank-trait-bounds/issue-102899.rs deleted file mode 100644 index 952b81584..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-102899.rs +++ /dev/null @@ -1,32 +0,0 @@ -// check-pass - -pub trait BufferTrait<'buffer> { - type Subset<'channel> - where - 'buffer: 'channel; - - fn for_each_subset(&self, f: F) - where - F: for<'channel> Fn(Self::Subset<'channel>); -} - -pub struct SomeBuffer<'buffer> { - samples: &'buffer [()], -} - -impl<'buffer> BufferTrait<'buffer> for SomeBuffer<'buffer> { - type Subset<'subset> = Subset<'subset> where 'buffer: 'subset; - - fn for_each_subset(&self, _f: F) - where - F: for<'subset> Fn(Subset<'subset>), - { - todo!() - } -} - -pub struct Subset<'subset> { - buffer: &'subset [()], -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-30786.rs b/tests/ui/higher-rank-trait-bounds/issue-30786.rs deleted file mode 100644 index 4a6399c8f..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-30786.rs +++ /dev/null @@ -1,136 +0,0 @@ -// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" - -// rust-lang/rust#30786: the use of `for<'b> &'b mut A: Stream Option; -} - -// Example stream -pub struct Repeat(u64); - -impl<'a> Stream for &'a mut Repeat { - type Item = &'a u64; - fn next(self) -> Option { - Some(&self.0) - } -} - -pub struct Map { - stream: S, - func: F, -} - -impl<'a, A, F, T> Stream for &'a mut Map -where - &'a mut A: Stream, - F: FnMut(<&'a mut A as Stream>::Item) -> T, -{ - type Item = T; - fn next(self) -> Option { - match self.stream.next() { - Some(item) => Some((self.func)(item)), - None => None, - } - } -} - -pub struct Filter { - stream: S, - func: F, -} - -impl<'a, A, F, T> Stream for &'a mut Filter -where - for<'b> &'b mut A: Stream, // <---- BAD - F: FnMut(&T) -> bool, -{ - type Item = <&'a mut A as Stream>::Item; - fn next(self) -> Option { - while let Some(item) = self.stream.next() { - if (self.func)(&item) { - return Some(item); - } - } - None - } -} - -pub trait StreamExt -where - for<'b> &'b mut Self: Stream, -{ - fn mapx(self, func: F) -> Map - where - Self: Sized, - for<'a> &'a mut Map: Stream, - { - Map { func: func, stream: self } - } - - fn filterx(self, func: F) -> Filter - where - Self: Sized, - for<'a> &'a mut Filter: Stream, - { - Filter { func: func, stream: self } - } - - fn countx(mut self) -> usize - where - Self: Sized, - { - let mut count = 0; - while let Some(_) = self.next() { - count += 1; - } - count - } -} - -impl StreamExt for T where for<'a> &'a mut T: Stream {} - -fn identity(x: &T) -> &T { - x -} - -fn variant1() { - let source = Repeat(10); - - // Here, the call to `mapx` returns a type `T` to which `StreamExt` - // is not applicable, because `for<'b> &'b mut T: Stream`) doesn't hold. - // - // More concretely, the type `T` is `Map`, and - // the where clause doesn't hold because the signature of the - // closure gets inferred to a signature like `|&'_ Stream| -> &'_` - // for some specific `'_`, rather than a more generic - // signature. - // - // Why *exactly* we opt for this signature is a bit unclear to me, - // we deduce it somehow from a reuqirement that `Map: Stream` I - // guess. - let map = source.mapx(|x: &_| x); - let filter = map.filterx(|x: &_| true); - //~^ ERROR the method -} - -fn variant2() { - let source = Repeat(10); - - // Here, we use a function, which is not subject to the vagaries - // of closure signature inference. In this case, we get the error - // on `countx` as, I think, the test originally expected. - let map = source.mapx(identity); - let filter = map.filterx(|x: &_| true); - let count = filter.countx(); - //~^ ERROR the method -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-30786.stderr b/tests/ui/higher-rank-trait-bounds/issue-30786.stderr deleted file mode 100644 index 6ec34d11a..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-30786.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:120:22 - | -LL | pub struct Map { - | -------------------- - | | - | method `filterx` not found for this struct - | doesn't satisfy `_: StreamExt` -... -LL | let filter = map.filterx(|x: &_| true); - | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds - | -note: the following trait bounds were not satisfied: - `&'a mut &Map: Stream` - `&'a mut &mut Map: Stream` - `&'a mut Map: Stream` - --> $DIR/issue-30786.rs:98:50 - | -LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} - | --------- - ^^^^^^ unsatisfied trait bound introduced here - -error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, [closure@issue-30786.rs:131:30]>`, but its trait bounds were not satisfied - --> $DIR/issue-30786.rs:132:24 - | -LL | pub struct Filter { - | ----------------------- - | | - | method `countx` not found for this struct - | doesn't satisfy `_: StreamExt` -... -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-rank-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` - `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` - --> $DIR/issue-30786.rs:98:50 - | -LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} - | --------- - ^^^^^^ unsatisfied trait bound introduced here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-36139-normalize-closure-sig.rs b/tests/ui/higher-rank-trait-bounds/issue-36139-normalize-closure-sig.rs deleted file mode 100644 index 2d49151ff..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-36139-normalize-closure-sig.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -// Previously the closure's argument would be inferred to -// >::Item, causing an error in MIR type -// checking - -trait ITrait<'a> {type Item;} - -struct S {} - -impl<'a> ITrait<'a> for S { type Item = &'a mut usize; } - -fn m(_: F) - where I: for<'a> ITrait<'a>, - F: for<'a> FnMut(>::Item) { } - - -fn main() { - m::(|x| { *x += 1; }); -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-39292.rs b/tests/ui/higher-rank-trait-bounds/issue-39292.rs deleted file mode 100644 index 968cf0891..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-39292.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -// Regression test for issue #39292. The object vtable was being -// incorrectly left with a null pointer. - -trait Foo { - fn print<'a>(&'a self) where T: 'a { println!("foo"); } -} - -impl<'a> Foo<&'a ()> for () { } - -trait Bar: for<'a> Foo<&'a ()> { } - -impl Bar for () {} - -fn main() { - (&() as &dyn Bar).print(); // Segfault -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-42114.rs b/tests/ui/higher-rank-trait-bounds/issue-42114.rs deleted file mode 100644 index 01515fdc9..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-42114.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass - -fn lifetime<'a>() -where - &'a (): 'a, -{ - /* do nothing */ -} - -fn doesnt_work() -where - for<'a> &'a (): 'a, -{ - /* do nothing */ -} - -fn main() { - lifetime(); - doesnt_work(); -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-43623.rs b/tests/ui/higher-rank-trait-bounds/issue-43623.rs deleted file mode 100644 index cedcf7c36..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-43623.rs +++ /dev/null @@ -1,21 +0,0 @@ -// check-pass - -pub trait Trait<'a> { - type Assoc; -} - -pub struct Type; - -impl<'a> Trait<'a> for Type { - type Assoc = (); -} - -pub fn break_me(f: F) -where - T: for<'b> Trait<'b>, - F: for<'b> FnMut(>::Assoc), -{ - break_me::; -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-46989.rs b/tests/ui/higher-rank-trait-bounds/issue-46989.rs deleted file mode 100644 index 4a09f4be1..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-46989.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Regression test for #46989: -// -// In the move to universes, this test started passing. -// It is not necessarily WRONG to do so, but it was a bit -// surprising. The reason that it passed is that when we were -// asked to prove that -// -// for<'a> fn(&'a i32): Foo -// -// we were able to use the impl below to prove -// -// fn(&'empty i32): Foo -// -// and then we were able to prove that -// -// fn(&'empty i32) = for<'a> fn(&'a i32) -// -// This last fact is somewhat surprising, but essentially "falls out" -// from handling variance correctly. In particular, consider the subtyping -// relations. First: -// -// fn(&'empty i32) <: for<'a> fn(&'a i32) -// -// This holds because -- intuitively -- a fn that takes a reference but doesn't use -// it can be given a reference with any lifetime. Similarly, the opposite direction: -// -// for<'a> fn(&'a i32) <: fn(&'empty i32) -// -// holds because 'a can be instantiated to 'empty. - -trait Foo {} - -impl Foo for fn(A) {} - -fn assert_foo() {} - -fn main() { - assert_foo::(); - //~^ ERROR implementation of `Foo` is not general enough -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-46989.stderr b/tests/ui/higher-rank-trait-bounds/issue-46989.stderr deleted file mode 100644 index 3f874220a..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-46989.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: implementation of `Foo` is not general enough - --> $DIR/issue-46989.rs:38:5 - | -LL | assert_foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `for<'a> fn(&'a i32)` - = note: ...but `Foo` is actually implemented for the type `fn(&'0 i32)`, for some specific lifetime `'0` - -error: aborting due to previous error - diff --git a/tests/ui/higher-rank-trait-bounds/issue-57639.rs b/tests/ui/higher-rank-trait-bounds/issue-57639.rs deleted file mode 100644 index 392e7233b..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-57639.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Regression test for #57639: -// -// In the move to universes, this test stopped working. The problem -// was that when the trait solver was asked to prove `for<'a> T::Item: -// Foo<'a>` as part of WF checking, it wound up "eagerly committing" -// to the where clause, which says that `T::Item: Foo<'a>`, but it -// should instead have been using the bound found in the trait -// declaration. Pre-universe, this used to work out ok because we got -// "eager errors" due to the leak check. -// -// See [this comment on GitHub][c] for more details. -// -// check-pass -// -// [c]: https://github.com/rust-lang/rust/issues/57639#issuecomment-455685861 - -trait Foo<'a> {} - -trait Bar { - type Item: for<'a> Foo<'a>; -} - -fn foo<'a, T>(_: T) -where - T: Bar, - T::Item: Foo<'a>, -{} - -fn main() { } diff --git a/tests/ui/higher-rank-trait-bounds/issue-58451.rs b/tests/ui/higher-rank-trait-bounds/issue-58451.rs deleted file mode 100644 index 6006a108c..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-58451.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Regression test for #58451: -// -// Error reporting here encountered an ICE in the shift to universes. - -fn f(i: I) -where - I: IntoIterator, - I::Item: for<'a> Into<&'a ()>, -{} - -fn main() { - f(&[f()]); //~ ERROR function takes 1 argument -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-58451.stderr b/tests/ui/higher-rank-trait-bounds/issue-58451.stderr deleted file mode 100644 index 0f051be21..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-58451.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/issue-58451.rs:12:9 - | -LL | f(&[f()]); - | ^-- an argument is missing - | -note: function defined here - --> $DIR/issue-58451.rs:5:4 - | -LL | fn f(i: I) - | ^ ---- -help: provide the argument - | -LL | f(&[f(/* i */)]); - | ~~~~~~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-59311.rs b/tests/ui/higher-rank-trait-bounds/issue-59311.rs deleted file mode 100644 index 3ad548450..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-59311.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Regression test for #59311. The test is taken from -// rust-lang/rust/issues/71546#issuecomment-620638437 -// as they seem to have the same cause. - -// FIXME: It's not clear that this code ought to report -// an error, but the regression test is here to ensure -// that it does not ICE. See discussion on #74889 for details. - -pub trait T { - fn t(&self, _: F) {} -} - -pub fn crash(v: &V) -where - for<'a> &'a V: T + 'static, -{ - v.t(|| {}); - //~^ ERROR: higher-ranked lifetime error - //~| ERROR: higher-ranked lifetime error -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-59311.stderr b/tests/ui/higher-rank-trait-bounds/issue-59311.stderr deleted file mode 100644 index c01ab8e34..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-59311.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: higher-ranked lifetime error - --> $DIR/issue-59311.rs:17:5 - | -LL | v.t(|| {}); - | ^^^^^^^^^^ - | - = note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:11] well-formed` - -error: higher-ranked lifetime error - --> $DIR/issue-59311.rs:17:9 - | -LL | v.t(|| {}); - | ^^^^^ - | - = note: could not prove `for<'a> &'a V: 'static` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/higher-rank-trait-bounds/issue-60283.rs b/tests/ui/higher-rank-trait-bounds/issue-60283.rs deleted file mode 100644 index 05315b3f9..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-60283.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass - -pub trait Trait<'a> { - type Item; -} - -impl<'a> Trait<'a> for () { - type Item = (); -} - -pub fn foo(_: T, _: F) -where - T: for<'a> Trait<'a>, - F: for<'a> FnMut(>::Item), -{ -} - -fn main() { - foo((), drop) -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs b/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs deleted file mode 100644 index e70f6fc34..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.rs +++ /dev/null @@ -1,54 +0,0 @@ -trait T0<'a, A> { - type O; -} - -struct L { - f: T, -} - -// explicitly named variants of what one would normally denote by the -// unit type `()`. Why do this? So that we can differentiate them in -// the diagnostic output. -struct Unit1; -struct Unit2; -struct Unit3; -struct Unit4; - -impl<'a, A, T> T0<'a, A> for L -where - T: FnMut(A) -> Unit3, -{ - type O = T::Output; -} - -trait T1: for<'r> Ty<'r> { - fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 - where - F: for<'r> T0<'r, (>::V,), O = >::V>, - { - unimplemented!(); - } -} - -trait Ty<'a> { - type V; -} - -fn main() { - let v = Unit2.m( - L { - //~^ ERROR to be a closure that returns `Unit3`, but it returns `Unit4` - //~| ERROR type mismatch - f: |x| { - drop(x); - Unit4 - }, - }, - ); -} - -impl<'a> Ty<'a> for Unit2 { - type V = &'a u8; -} - -impl T1 for Unit2 {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr b/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr deleted file mode 100644 index 4d470ae70..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-62203-hrtb-ice.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error[E0271]: type mismatch resolving ` as T0<'r, (&u8,)>>::O == <_ as Ty<'r>>::V` - --> $DIR/issue-62203-hrtb-ice.rs:39:9 - | -LL | let v = Unit2.m( - | - required by a bound introduced by this call -LL | / L { -LL | | -LL | | -LL | | f: |x| { -... | -LL | | }, -LL | | }, - | |_________^ type mismatch resolving ` as T0<'r, (&u8,)>>::O == <_ as Ty<'r>>::V` - | -note: expected this to be `<_ as Ty<'_>>::V` - --> $DIR/issue-62203-hrtb-ice.rs:21:14 - | -LL | type O = T::Output; - | ^^^^^^^^^ - = note: expected associated type `<_ as Ty<'_>>::V` - found struct `Unit4` - = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html -note: required by a bound in `T1::m` - --> $DIR/issue-62203-hrtb-ice.rs:27:51 - | -LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 - | - required by a bound in this associated function -LL | where -LL | F: for<'r> T0<'r, (>::V,), O = >::V>, - | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` - -error[E0271]: expected `[closure@issue-62203-hrtb-ice.rs:42:16]` to be a closure that returns `Unit3`, but it returns `Unit4` - --> $DIR/issue-62203-hrtb-ice.rs:39:9 - | -LL | let v = Unit2.m( - | - required by a bound introduced by this call -LL | / L { -LL | | -LL | | -LL | | f: |x| { -... | -LL | | }, -LL | | }, - | |_________^ expected `Unit3`, found `Unit4` - | -note: required for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]>` to implement `for<'r> T0<'r, (&'r u8,)>` - --> $DIR/issue-62203-hrtb-ice.rs:17:16 - | -LL | impl<'a, A, T> T0<'a, A> for L - | ^^^^^^^^^ ^^^^ -LL | where -LL | T: FnMut(A) -> Unit3, - | ----- unsatisfied trait bound introduced here -note: required by a bound in `T1::m` - --> $DIR/issue-62203-hrtb-ice.rs:27:12 - | -LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 - | - required by a bound in this associated function -LL | where -LL | F: for<'r> T0<'r, (>::V,), O = >::V>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-88446.rs b/tests/ui/higher-rank-trait-bounds/issue-88446.rs deleted file mode 100644 index 571b85317..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-88446.rs +++ /dev/null @@ -1,35 +0,0 @@ -// check-pass - -trait Yokeable<'a> { - type Output: 'a; -} -impl<'a> Yokeable<'a> for () { - type Output = (); -} - -trait DataMarker<'data> { - type Yokeable: for<'a> Yokeable<'a>; -} -impl<'data> DataMarker<'data> for () { - type Yokeable = (); -} - -struct DataPayload<'data, M>(&'data M); - -impl DataPayload<'static, ()> { - pub fn map_project_with_capture( - _: for<'a> fn( - capture: T, - std::marker::PhantomData<&'a ()>, - ) -> >::Output, - ) -> DataPayload<'static, M2> - where - M2: DataMarker<'static>, - { - todo!() - } -} - -fn main() { - let _: DataPayload<()> = DataPayload::<()>::map_project_with_capture::<_, &()>(|_, _| todo!()); -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs b/tests/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs deleted file mode 100644 index 92b7c5deb..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Regression test for #88586: a higher-ranked outlives bound on Self in a trait -// definition caused an ICE when debug_assertions were enabled. -// -// Made to pass as part of fixing #98095. -// -// check-pass - -trait A where - for<'a> Self: 'a, -{ -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/issue-90177.rs b/tests/ui/higher-rank-trait-bounds/issue-90177.rs deleted file mode 100644 index b151a9d3a..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-90177.rs +++ /dev/null @@ -1,32 +0,0 @@ -// check-pass - -trait Base<'f> { - type Assoc; - - fn do_something(&self); -} - -trait ForAnyLifetime: for<'f> Base<'f> {} - -impl ForAnyLifetime for T where T: for<'f> Base<'f> {} - -trait CanBeDynamic: ForAnyLifetime + for<'f> Base<'f, Assoc = ()> {} - -fn foo(a: &dyn CanBeDynamic) { - a.do_something(); -} - -struct S; - -impl<'a> Base<'a> for S { - type Assoc = (); - - fn do_something(&self) {} -} - -impl CanBeDynamic for S {} - -fn main() { - let s = S; - foo(&s); -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-95034.rs b/tests/ui/higher-rank-trait-bounds/issue-95034.rs deleted file mode 100644 index af4946a18..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-95034.rs +++ /dev/null @@ -1,80 +0,0 @@ -// check-pass -// compile-flags: --edition=2021 --crate-type=lib - -use std::{ - future::Future, - marker::PhantomData, - pin::Pin, - task::{Context, Poll}, -}; - -mod object { - use super::*; - - pub trait Object<'a> { - type Error; - type Future: Future; - fn create() -> Self::Future; - } - - impl<'a> Object<'a> for u8 { - type Error = (); - type Future = Pin>>; - fn create() -> Self::Future { - unimplemented!() - } - } - - impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) { - type Error = (); - type Future = CustomFut<'a, E, A>; - fn create() -> Self::Future { - unimplemented!() - } - } - - pub struct CustomFut<'f, E, A: Object<'f, Error = E>> { - ph: PhantomData<(A::Future,)>, - } - - impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> { - type Output = (A,); - fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { - unimplemented!() - } - } -} - -mod async_fn { - use super::*; - - pub trait AsyncFn { - type Future: Future; - fn call(&self) -> Self::Future; - } - - impl AsyncFn for F - where - F: Fn() -> Fut, - Fut: Future, - { - type Future = Fut; - fn call(&self) -> Self::Future { - (self)() - } - } -} - -pub async fn test() { - use self::{async_fn::AsyncFn, object::Object}; - - async fn create>() { - T::create().await; - } - - async fn call_async_fn(inner: impl AsyncFn) { - inner.call().await; - } - - call_async_fn(create::<(u8,)>).await; -} diff --git a/tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr b/tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr deleted file mode 100644 index d4bc5b672..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0275]: overflow evaluating the requirement `for<'a> &'a mut Bar well-formed` - --> $DIR/issue-95230.rs:9:13 - | -LL | for<'a> &'a mut Self:; - | ^^^^^^^^^^^^ - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_95230`) -note: required by a bound in `Bar` - --> $DIR/issue-95230.rs:9:13 - | -LL | pub struct Bar - | --- required by a bound in this struct -LL | where -LL | for<'a> &'a mut Self:; - | ^^^^^^^^^^^^ required by this bound in `Bar` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-95230.rs b/tests/ui/higher-rank-trait-bounds/issue-95230.rs deleted file mode 100644 index 769b6a925..000000000 --- a/tests/ui/higher-rank-trait-bounds/issue-95230.rs +++ /dev/null @@ -1,11 +0,0 @@ -// revisions: old new -//[new] compile-flags: -Ztrait-solver=next -//[old] check-pass -//[new] known-bug: #109764 - - -pub struct Bar -where - for<'a> &'a mut Self:; - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-44005.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-44005.rs deleted file mode 100644 index f255eac0c..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-44005.rs +++ /dev/null @@ -1,31 +0,0 @@ -// check-pass - -pub trait Foo<'a> { - type Bar; - fn foo(&'a self) -> Self::Bar; -} - -impl<'a, 'b, T: 'a> Foo<'a> for &'b T { - type Bar = &'a T; - fn foo(&'a self) -> &'a T { - self - } -} - -pub fn uncallable(x: T, f: F) -where - T: for<'a> Foo<'a>, - F: for<'a> Fn(>::Bar), -{ - f(x.foo()); -} - -pub fn catalyst(x: &i32) { - broken(x, |_| {}) -} - -pub fn broken(x: &i32, f: F) { - uncallable(x, |y| f(y)); -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-56556.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-56556.rs deleted file mode 100644 index 4d38cb19e..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-56556.rs +++ /dev/null @@ -1,30 +0,0 @@ -// check-pass - -fn foo(t: T) -> usize -where - for<'a> &'a T: IntoIterator, - for<'a> <&'a T as IntoIterator>::IntoIter: ExactSizeIterator, -{ - t.into_iter().len() -} - -fn main() { - foo::>(vec![]); -} - -mod another { - use std::ops::Deref; - - fn test() - where - T: Deref, - TDeref: ?Sized, - for<'a> &'a TDeref: IntoIterator, - for<'a> <&'a TDeref as IntoIterator>::IntoIter: Clone, - { - } - - fn main() { - test::, _>(); - } -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs deleted file mode 100644 index c6f29fa59..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-1.rs +++ /dev/null @@ -1,88 +0,0 @@ -// check-pass - -// FamilyType (GAT workaround) -pub trait FamilyLt<'a> { - type Out; -} - -struct RefMutFamily(std::marker::PhantomData, ()); -impl<'a, T: 'a> FamilyLt<'a> for RefMutFamily { - type Out = &'a mut T; -} - -pub trait Execute { - type E: Inject; - fn execute(self, value: <::I as FamilyLt>::Out); -} - -pub trait Inject -where - Self: Sized, -{ - type I: for<'a> FamilyLt<'a>; - fn inject(_: &()) -> ::Out; -} - -impl Inject for RefMutFamily { - type I = Self; - fn inject(_: &()) -> ::Out { - unimplemented!() - } -} - -// This struct is only used to give a hint to the compiler about the type `Q` -struct Annotate(std::marker::PhantomData); -impl Annotate { - fn new() -> Self { - Self(std::marker::PhantomData) - } -} - -// This function annotate a closure so it can have Higher-Rank Lifetime Bounds -// -// See 'annotate' workaround: https://github.com/rust-lang/rust/issues/58052 -fn annotate(_q: Annotate, func: F) -> impl Execute + 'static -where - F: for<'r> FnOnce(<::I as FamilyLt<'r>>::Out) + 'static, - Q: Inject + 'static, -{ - let wrapper: Wrapper = Wrapper(std::marker::PhantomData, func); - wrapper -} - -struct Wrapper(std::marker::PhantomData, F); -impl Execute for Wrapper - where - Q: Inject, - F: for<'r> FnOnce(<::I as FamilyLt<'r>>::Out), -{ - type E = Q; - - fn execute(self, value: <::I as FamilyLt>::Out) { - (self.1)(value) - } -} - -struct Task { - _processor: Box, -} - -// This function consume the closure -fn task

>::Output, -) -> MiniYoke

-where - Y: for<'a> MiniYokeable<'a>, - P: for<'a> MiniYokeable<'a> -{ - unimplemented!() -} - -struct Bar<'a> { - string_1: &'a str, - string_2: &'a str, -} - -impl<'a> MiniYokeable<'a> for Bar<'static> { - type Output = Bar<'a>; -} - -impl<'a> MiniYokeable<'a> for &'static str { - type Output = &'a str; -} - -fn demo_broken(bar: MiniYoke>) -> MiniYoke<&'static str> { - map_project_broken(bar, |bar, _| bar.string_1) -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs deleted file mode 100644 index effc32945..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90612.rs +++ /dev/null @@ -1,41 +0,0 @@ -// check-pass - -use std::marker::PhantomData; - -trait Family: Sized { - type Item<'a>; - - fn apply_all(&self, f: F) - where - F: FamilyItemFn { } -} - -struct Array(PhantomData); - -impl Family for Array { - type Item<'a> = &'a T; -} - -trait FamilyItemFn { - fn apply(&self, item: T::Item<'_>); -} - -impl FamilyItemFn for F -where - T: Family, - for<'a> F: Fn(T::Item<'a>) -{ - fn apply(&self, item: T::Item<'_>) { - (*self)(item); - } -} - -fn process(array: Array) { - // Works - array.apply_all(|x: &T| { }); - - // ICE: NoSolution - array.apply_all(|x: as Family>::Item<'_>| { }); -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs deleted file mode 100644 index 628b5cba1..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90638.rs +++ /dev/null @@ -1,35 +0,0 @@ -//check-pass - -trait Yokeable<'a>: 'static { - type Output: 'a; -} - -trait IsCovariant<'a> {} - -struct Yoke Yokeable<'a>> { - data: Y, -} - -impl Yokeable<'a>> Yoke { - fn project Yokeable<'a>>(&self, _f: for<'a> fn(>::Output, &'a ()) - -> >::Output) -> Yoke { - - unimplemented!() - } -} - -fn _upcast(x: Yoke) -> Yoke + 'static>> where - Y: for<'a> Yokeable<'a>, - for<'a> >::Output: IsCovariant<'a> - { - x.project(|data, _| { - Box::new(data) - }) -} - - -impl<'a> Yokeable<'a> for Box + 'static> { - type Output = Box + 'a>; -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90875.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90875.rs deleted file mode 100644 index ffd6857d8..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90875.rs +++ /dev/null @@ -1,31 +0,0 @@ -// check-pass - -trait Variable<'a> { - type Type; -} - -impl Variable<'_> for () { - type Type = (); -} - -fn check(_: F) -where - F: Fn(T), // <- if removed, all fn_* then require type annotations - F: for<'a> Fn(>::Type), - T: for<'a> Variable<'a>, -{ -} - -fn test(arg: impl Fn(())) { - fn fn_1(_: ()) {} - let fn_2 = |_: ()| (); - let fn_3 = |a| fn_1(a); - let fn_4 = arg; - - check(fn_1); // Error - check(fn_2); // Ok - check(fn_3); // Ok - check(fn_4); // Error -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs deleted file mode 100644 index ab9d9a7ce..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.rs +++ /dev/null @@ -1,53 +0,0 @@ -// check-fail -// known-bug: #90950 - -trait Yokeable<'a>: 'static { - type Output: 'a; -} - - -trait IsCovariant<'a> {} - -struct Yoke Yokeable<'a>> { - data: Y, -} - - -// impl Yokeable<'a>> Yoke { -// fn project Yokeable<'a>>( -// &self, -// f: for<'a> fn(>::Output, &'a (), -// ) -> >::Output) -> Yoke { -// unimplemented!() -// } -// } - -fn upcast(x: Yoke) -> Yoke + 'static>> where - Y: for<'a> Yokeable<'a>, - for<'a> >::Output: IsCovariant<'a> - { - // x.project(|data, _| { - // Box::new(data) - // }) - unimplemented!() -} - - -impl<'a> Yokeable<'a> for Box + 'static> { - type Output = Box + 'a>; -} - -// this impl is mostly an example and unnecessary for the pure repro -use std::borrow::*; -impl<'a, T: ToOwned + ?Sized> Yokeable<'a> for Cow<'static, T> { - type Output = Cow<'a, T>; -} -impl<'a, T: ToOwned + ?Sized> IsCovariant<'a> for Cow<'a, T> {} - - - -fn upcast_yoke(y: Yoke>) -> Yoke + 'static>> { - upcast(y) -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr deleted file mode 100644 index 5be33bccd..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-90950.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `for<'a> <_ as Yokeable<'a>>::Output: IsCovariant<'a>` is not satisfied - --> $DIR/issue-90950.rs:50:12 - | -LL | upcast(y) - | ------ ^ the trait `for<'a> IsCovariant<'a>` is not implemented for `<_ as Yokeable<'a>>::Output` - | | - | required by a bound introduced by this call - | - = help: the trait `IsCovariant<'a>` is implemented for `std::borrow::Cow<'a, T>` -note: required by a bound in `upcast` - --> $DIR/issue-90950.rs:27:42 - | -LL | fn upcast(x: Yoke) -> Yoke + 'static>> where - | ------ required by a bound in this function -LL | Y: for<'a> Yokeable<'a>, -LL | for<'a> >::Output: IsCovariant<'a> - | ^^^^^^^^^^^^^^^ required by this bound in `upcast` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs deleted file mode 100644 index 7693b1182..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.rs +++ /dev/null @@ -1,23 +0,0 @@ -// check-fail -// known-bug: #89196 - -// Should pass, but we normalize and check bounds before we resolve the generics -// of the function (which we know because of the return type). - -trait Trait<'a> { - type Out; -} - -impl<'a, T> Trait<'a> for T { - type Out = T; -} - -fn weird_bound() -> X - where - for<'a> X: Trait<'a>, - for<'a> >::Out: Copy -{ todo!() } - -fn main() { - let _: () = weird_bound(); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr deleted file mode 100644 index 73388a725..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: the trait bound `for<'a> <_ as Trait<'a>>::Out: Copy` is not satisfied - --> $DIR/norm-before-method-resolution.rs:22:17 - | -LL | let _: () = weird_bound(); - | ^^^^^^^^^^^ the trait `for<'a> Copy` is not implemented for `<_ as Trait<'a>>::Out` - | -note: required by a bound in `weird_bound` - --> $DIR/norm-before-method-resolution.rs:18:40 - | -LL | fn weird_bound() -> X - | ----------- required by a bound in this function -... -LL | for<'a> >::Out: Copy - | ^^^^ required by this bound in `weird_bound` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/higher-lifetime-bounds.rs b/tests/ui/higher-ranked/higher-lifetime-bounds.rs new file mode 100644 index 000000000..f3393347d --- /dev/null +++ b/tests/ui/higher-ranked/higher-lifetime-bounds.rs @@ -0,0 +1,69 @@ +#![allow(dead_code, non_camel_case_types)] + +// Test that bounds on higher-kinded lifetime binders are rejected. + +fn bar1<'a, 'b>( + x: &'a i32, + y: &'b i32, + f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) + //~^ ERROR lifetime bounds cannot be used in this context +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( + //~^ ERROR lifetime bounds cannot be used in this context + x: &'a i32, + y: &'b i32, + f: F) +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +fn bar3<'a, 'b, F>( + x: &'a i32, + y: &'b i32, + f: F) + where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 + //~^ ERROR lifetime bounds cannot be used in this context +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +fn bar4<'a, 'b, F>( + x: &'a i32, + y: &'b i32, + f: F) + where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 + //~^ ERROR lifetime bounds cannot be used in this context +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); +//~^ ERROR lifetime bounds cannot be used in this context +struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; +//~^ ERROR lifetime bounds cannot be used in this context +struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; +//~^ ERROR lifetime bounds cannot be used in this context + +struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); +//~^ ERROR lifetime bounds cannot be used in this context + +type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; +//~^ ERROR lifetime bounds cannot be used in this context + +fn main() { + let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; + //~^ ERROR lifetime bounds cannot be used in this context + let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + //~^ ERROR lifetime bounds cannot be used in this context +} diff --git a/tests/ui/higher-ranked/higher-lifetime-bounds.stderr b/tests/ui/higher-ranked/higher-lifetime-bounds.stderr new file mode 100644 index 000000000..bc6d2288c --- /dev/null +++ b/tests/ui/higher-ranked/higher-lifetime-bounds.stderr @@ -0,0 +1,68 @@ +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:8:22 + | +LL | f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) + | ^^^ ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:16:34 + | +LL | fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:31:28 + | +LL | where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:43:25 + | +LL | where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:51:28 + | +LL | struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:53:40 + | +LL | struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:55:37 + | +LL | struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:58:29 + | +LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:61:33 + | +LL | type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:65:34 + | +LL | let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:67:42 + | +LL | let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + | ^^^ + +error: aborting due to 11 previous errors + diff --git a/tests/ui/higher-ranked/leak-check-in-selection.rs b/tests/ui/higher-ranked/leak-check-in-selection.rs new file mode 100644 index 000000000..e8d6cff85 --- /dev/null +++ b/tests/ui/higher-ranked/leak-check-in-selection.rs @@ -0,0 +1,24 @@ +// run-pass +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next +#![allow(coherence_leak_check)] + +trait Trait: Sized { + fn is_higher_ranked(self) -> bool; +} + +impl Trait for for<'a> fn(&'a ()) { + fn is_higher_ranked(self) -> bool { + true + } +} +impl<'a> Trait for fn(&'a ()) { + fn is_higher_ranked(self) -> bool { + false + } +} + +fn main() { + let x: for<'a> fn(&'a ()) = |&()| (); + assert!(x.is_higher_ranked()); +} diff --git a/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr new file mode 100644 index 000000000..b7264c7e9 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:54:13 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other +... +LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, +LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) } + | |_____________________________________________- in this macro invocation + | + = note: expected enum `Option fn(&'a u32, &'b u32) -> &'a u32>` + found enum `Option fn(&'a u32, &'a u32) -> &'a u32>` + = note: this error originates in the macro `check` (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/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr new file mode 100644 index 000000000..2355979b0 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/hr-subtype.bound_a_vs_free_x.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:54:13 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other +... +LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), +LL | | fn(&'x u32)) } + | |______________- in this macro invocation + | + = note: expected enum `Option fn(&'a u32)>` + found enum `Option` + = note: this error originates in the macro `check` (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/higher-ranked/subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr new file mode 100644 index 000000000..a73c03feb --- /dev/null +++ b/tests/ui/higher-ranked/subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:54:13 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other +... +LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), +LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } + | |__________________________________- in this macro invocation + | + = note: expected enum `Option fn(Inv<'a>, Inv<'b>)>` + found enum `Option fn(Inv<'a>, Inv<'a>)>` + = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:54:13 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other +... +LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), +LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } + | |__________________________________- in this macro invocation + | + = note: expected enum `Option fn(Inv<'a>, Inv<'b>)>` + found enum `Option fn(Inv<'a>, Inv<'a>)>` + = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-ranked/subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr new file mode 100644 index 000000000..31d36d716 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr @@ -0,0 +1,42 @@ +error: lifetime may not live long enough + --> $DIR/hr-subtype.rs:48:13 + | +LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | gimme::<$t2>(None::<$t1>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |______________- in this macro invocation + | + = help: consider adding the following bound: `'x: 'y` + = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Inv<'a>` is invariant over the parameter `'a` + = help: see for more information about variance + = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: lifetime may not live long enough + --> $DIR/hr-subtype.rs:54:13 + | +LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |______________- in this macro invocation + | + = help: consider adding the following bound: `'x: 'y` + = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant + = note: the struct `Inv<'a>` is invariant over the parameter `'a` + = help: see for more information about variance + = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/higher-ranked/subtype/hr-subtype.free_x_vs_free_y.stderr b/tests/ui/higher-ranked/subtype/hr-subtype.free_x_vs_free_y.stderr new file mode 100644 index 000000000..269cde54c --- /dev/null +++ b/tests/ui/higher-ranked/subtype/hr-subtype.free_x_vs_free_y.stderr @@ -0,0 +1,19 @@ +error: lifetime may not live long enough + --> $DIR/hr-subtype.rs:54:13 + | +LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` +... +LL | / check! { free_x_vs_free_y: (fn(&'x u32), +LL | | fn(&'y u32)) } + | |______________- in this macro invocation + | + = help: consider adding the following bound: `'x: 'y` + = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/higher-ranked/subtype/hr-subtype.rs b/tests/ui/higher-ranked/subtype/hr-subtype.rs new file mode 100644 index 000000000..c770e0de8 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/hr-subtype.rs @@ -0,0 +1,111 @@ +// Targeted tests for the higher-ranked subtyping code. + +#![allow(dead_code)] + +// revisions: bound_a_vs_bound_a +// revisions: bound_a_vs_bound_b +// revisions: bound_inv_a_vs_bound_inv_b +// revisions: bound_co_a_vs_bound_co_b +// revisions: bound_a_vs_free_x +// revisions: free_x_vs_free_x +// revisions: free_x_vs_free_y +// revisions: free_inv_x_vs_free_inv_y +// revisions: bound_a_b_vs_bound_a +// revisions: bound_co_a_b_vs_bound_co_a +// revisions: bound_contra_a_contra_b_ret_co_a +// revisions: bound_co_a_co_b_ret_contra_a +// revisions: bound_inv_a_b_vs_bound_inv_a +// revisions: bound_a_b_ret_a_vs_bound_a_ret_a + +//[bound_a_vs_bound_a] check-pass +//[bound_a_vs_bound_b] check-pass +//[bound_inv_a_vs_bound_inv_b] check-pass +//[bound_co_a_vs_bound_co_b] check-pass +//[free_x_vs_free_x] check-pass +//[bound_co_a_b_vs_bound_co_a] check-pass +//[bound_co_a_co_b_ret_contra_a] check-pass +//[bound_a_b_vs_bound_a] check-pass +//[bound_contra_a_contra_b_ret_co_a] check-pass + +fn gimme(_: Option) {} + +struct Inv<'a> { + x: *mut &'a u32, +} + +struct Co<'a> { + x: fn(&'a u32), +} + +struct Contra<'a> { + x: &'a u32, +} + +macro_rules! check { + ($rev:ident: ($t1:ty, $t2:ty)) => { + #[cfg($rev)] + fn subtype<'x, 'y: 'x, 'z: 'y>() { + gimme::<$t2>(None::<$t1>); + //[free_inv_x_vs_free_inv_y]~^ ERROR + } + + #[cfg($rev)] + fn supertype<'x, 'y: 'x, 'z: 'y>() { + gimme::<$t1>(None::<$t2>); + //[bound_a_vs_free_x]~^ ERROR + //[free_x_vs_free_y]~^^ ERROR + //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR + //[bound_inv_a_b_vs_bound_inv_a]~| ERROR + //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^^ ERROR + //[free_inv_x_vs_free_inv_y]~^^^^^^ ERROR + } + }; +} + +// If both have bound regions, they are equivalent, regardless of +// variant. +check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32), +for<'a> fn(&'a u32)) } +check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32), +for<'b> fn(&'b u32)) } +check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>), +for<'b> fn(Inv<'b>)) } +check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>), +for<'b> fn(Co<'b>)) } + +// Bound is a subtype of free. +check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), +fn(&'x u32)) } + +// Two free regions are relatable if subtyping holds. +check! { free_x_vs_free_x: (fn(&'x u32), +fn(&'x u32)) } +check! { free_x_vs_free_y: (fn(&'x u32), +fn(&'y u32)) } +check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +fn(Inv<'y>)) } + +// Somewhat surprisingly, a fn taking two distinct bound lifetimes and +// a fn taking one bound lifetime can be interchangeable, but only if +// we are co- or contra-variant with respect to both lifetimes. +// +// The reason is: +// - if we are covariant, then 'a and 'b can be set to the call-site +// intersection; +// - if we are contravariant, then 'a can be inferred to 'static. +check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), +for<'a> fn(&'a u32, &'a u32)) } +check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), +for<'a> fn(Co<'a>, Co<'a>)) } +check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, +for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } +check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, +for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } + +// If we make those lifetimes invariant, then the two types are not interchangeable. +check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), +for<'a> fn(Inv<'a>, Inv<'a>)) } +check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, +for<'a> fn(&'a u32, &'a u32) -> &'a u32) } + +fn main() {} diff --git a/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.rs b/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.rs new file mode 100644 index 000000000..bd4533e04 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.rs @@ -0,0 +1,25 @@ +// Check that incorrect higher ranked subtyping +// causes an error. +struct Inv<'a>(fn(&'a ()) -> &'a ()); +fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) { + // ok + let _: for<'a> fn(Inv<'a>, Inv<'a>) = f; + let sub: for<'a> fn(Inv<'a>, Inv<'a>) = f; + // no + let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; + //~^ ERROR mismatched types +} + +fn simple1<'c>(x: (&'c i32,)) { + let _x: (&'static i32,) = x; +} + +fn simple2<'c>(x: (&'c i32,)) { + let _: (&'static i32,) = x; +} + +fn main() { + hr_subtype(|_, _| {}); + simple1((&3,)); + simple2((&3,)); +} diff --git a/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr b/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr new file mode 100644 index 000000000..73b0a3173 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/placeholder-pattern-fail.stderr @@ -0,0 +1,12 @@ +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 + | + = note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)` + found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-ranked/subtype/placeholder-pattern.rs b/tests/ui/higher-ranked/subtype/placeholder-pattern.rs new file mode 100644 index 000000000..061e66e54 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/placeholder-pattern.rs @@ -0,0 +1,18 @@ +// check-pass +// Check that higher ranked subtyping correctly works when using +// placeholder patterns. +fn hr_subtype<'c>(f: for<'a, 'b> fn(&'a (), &'b ())) { + let _: for<'a> fn(&'a (), &'a ()) = f; + let _: for<'a, 'b> fn(&'a (), &'b ()) = f; + let _: for<'a> fn(&'a (), &'c ()) = f; + let _: fn(&'c (), &'c ()) = f; +} + +fn simple<'c>(x: (&'static i32,)) { + let _: (&'c i32,) = x; +} + +fn main() { + hr_subtype(|_, _| {}); + simple((&3,)); +} diff --git a/tests/ui/higher-ranked/subtype/return-static.rs b/tests/ui/higher-ranked/subtype/return-static.rs new file mode 100644 index 000000000..6455854f3 --- /dev/null +++ b/tests/ui/higher-ranked/subtype/return-static.rs @@ -0,0 +1,13 @@ +// check-pass + +fn make() -> T { + panic!() +} + +fn take(x: T) {} + +fn main() { + let x: for<'a> fn(&'a u32) -> _ = make(); + let y: &'static u32 = x(&22); + take:: fn(&'b u32) -> &'b u32>(x); +} diff --git a/tests/ui/higher-ranked/trait-bounds/complex.rs b/tests/ui/higher-ranked/trait-bounds/complex.rs new file mode 100644 index 000000000..8cdfe247e --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/complex.rs @@ -0,0 +1,28 @@ +// check-pass + +trait A<'a> {} +trait B<'b> {} +fn foo() where for<'a> T: A<'a> + 'a {} +trait C<'c>: for<'a> A<'a> + for<'b> B<'b> { + type As; +} +struct D where T: for<'c> C<'c, As=&'c ()> { + t: std::marker::PhantomData, +} +trait E<'e, 'g> { + type As; +} +trait F<'f>: for<'a> A<'a> + for<'e> E<'e, 'f> {} +struct G where T: for<'f> F<'f, As=&'f ()> { + t: std::marker::PhantomData, +} +trait H<'a, 'b> { + type As; +} +trait I<'a>: for<'b> H<'a, 'b> {} + +struct J where T: for<'i> I<'i, As=&'i ()> { + t: std::marker::PhantomData, +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.rs b/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.rs new file mode 100644 index 000000000..1afd15613 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.rs @@ -0,0 +1,13 @@ +fn main() { + test::(&mut 42); //~ ERROR implementation of `Foo` is not general enough +} + +trait Foo<'a> {} + +struct FooS<'a> { + data: &'a mut u32, +} + +impl<'a, 'b: 'a> Foo<'b> for FooS<'a> {} + +fn test<'a, F>(data: &'a mut u32) where F: for<'b> Foo<'b> {} diff --git a/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr b/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr new file mode 100644 index 000000000..520938a63 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr @@ -0,0 +1,11 @@ +error: implementation of `Foo` is not general enough + --> $DIR/due-to-where-clause.rs:2:5 + | +LL | test::(&mut 42); + | ^^^^^^^^^^^^ implementation of `Foo` is not general enough + | + = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`... + = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1` + +error: aborting due to previous error + diff --git a/tests/ui/higher-ranked/trait-bounds/fn-ptr.classic.stderr b/tests/ui/higher-ranked/trait-bounds/fn-ptr.classic.stderr new file mode 100644 index 000000000..9af6bc45c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/fn-ptr.classic.stderr @@ -0,0 +1,19 @@ +error[E0277]: expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` + --> $DIR/fn-ptr.rs:12:5 + | +LL | ice(); + | ^^^ expected an `Fn<(&'w (),)>` closure, found `fn(&'w ())` + | + = help: the trait `for<'w> Fn<(&'w (),)>` is not implemented for `fn(&'w ())` +note: required by a bound in `ice` + --> $DIR/fn-ptr.rs:7:25 + | +LL | fn ice() + | --- required by a bound in this function +LL | where +LL | for<'w> fn(&'w ()): Fn(&'w ()), + | ^^^^^^^^^^ required by this bound in `ice` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs b/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs new file mode 100644 index 000000000..853160f96 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/fn-ptr.rs @@ -0,0 +1,14 @@ +// revisions: classic next +//[next] compile-flags: -Ztrait-solver=next +//[next] check-pass + +fn ice() +where + for<'w> fn(&'w ()): Fn(&'w ()), +{ +} + +fn main() { + ice(); + //[classic]~^ ERROR expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` +} diff --git a/tests/ui/higher-ranked/trait-bounds/future.classic.stderr b/tests/ui/higher-ranked/trait-bounds/future.classic.stderr new file mode 100644 index 000000000..33c0f7173 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/future.classic.stderr @@ -0,0 +1,6 @@ +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [evaluate_obligation] evaluating trait selection obligation `for<'a> [async fn body@$DIR/future.rs:32:35: 34:2]: core::future::future::Future` +#1 [codegen_select_candidate] computing candidate for `` +end of query stack diff --git a/tests/ui/higher-ranked/trait-bounds/future.rs b/tests/ui/higher-ranked/trait-bounds/future.rs new file mode 100644 index 000000000..da7ee0343 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/future.rs @@ -0,0 +1,38 @@ +// ignore-tidy-linelength +// edition:2021 +// revisions: classic next +//[next] compile-flags: -Ztrait-solver=next +//[next] check-pass +//[classic] known-bug: #112347 +//[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 "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//[classic] rustc-env:RUST_BACKTRACE=0 + +#![feature(unboxed_closures)] + +use std::future::Future; + +trait Trait { + fn func(&self, _: &str); +} + +impl Trait for T +where + for<'a> T: Fn<(&'a str,)> + Send + Sync, + for<'a> >::Output: Future + Send, +{ + fn func(&self, _: &str) { + println!("hello!"); + } +} + +async fn strlen(x: &str) -> usize { + x.len() +} + +fn main() { + strlen.func("hi"); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs b/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs new file mode 100644 index 000000000..d34b7a296 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.rs @@ -0,0 +1,16 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" + +fn id( + f: &dyn Fn(u32), +) -> &dyn Fn( + &dyn Fn( + &dyn Fn( + &dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(u32))))))))), + ), + ), +) { + f + //~^ ERROR mismatched types +} + +fn main() {} 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 new file mode 100644 index 000000000..a9d649b82 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hang-on-deeply-nested-dyn.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/hang-on-deeply-nested-dyn.rs:12:5 + | +LL | ) -> &dyn Fn( + | ______- +LL | | &dyn Fn( +LL | | &dyn Fn( +LL | | &dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(u32))))))))), +LL | | ), +LL | | ), +LL | | ) { + | |_- expected `&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))` because of return type +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' + found reference `&dyn Fn(u32)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-binder-levels-in-object-types.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-binder-levels-in-object-types.rs new file mode 100644 index 000000000..cc766c060 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-binder-levels-in-object-types.rs @@ -0,0 +1,29 @@ +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that we handle binder levels in object types correctly. +// Initially, the reference to `'tcx` in the object type +// `&Typer<'tcx>` was getting an incorrect binder level, yielding +// weird compilation ICEs and so forth. + +// pretty-expanded FIXME #23616 + +trait Typer<'tcx> { + fn method(&self, data: &'tcx isize) -> &'tcx isize { data } +} + +struct Tcx<'tcx> { + fields: &'tcx isize +} + +impl<'tcx> Typer<'tcx> for Tcx<'tcx> { +} + +fn g<'tcx>(typer: &dyn Typer<'tcx>) { +} + +fn check_static_type<'x>(tcx: &Tcx<'x>) { + g(tcx) +} + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.rs new file mode 100644 index 000000000..a20d03c77 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.rs @@ -0,0 +1,24 @@ +// Regression test for #54302. +// +// We were incorrectly using the "evaluation cache" (which ignored +// region results) to conclude that `&'static str: Deserialize`, even +// though it would require that `for<'de> 'de: 'static`, which is +// clearly false. + +trait Deserialize<'de> {} + +trait DeserializeOwned: for<'de> Deserialize<'de> {} +impl DeserializeOwned for T where T: for<'de> Deserialize<'de> {} + +// Based on this impl, `&'static str` only implements Deserialize<'static>. +// It does not implement for<'de> Deserialize<'de>. +impl<'de: 'a, 'a> Deserialize<'de> for &'a str {} + +fn main() { + fn assert_deserialize_owned() {} + assert_deserialize_owned::<&'static str>(); //~ ERROR + + // It correctly does not implement for<'de> Deserialize<'de>. + // fn assert_hrtb Deserialize<'de>>() {} + // assert_hrtb::<&'static str>(); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.stderr new file mode 100644 index 000000000..f014eab86 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-cache-issue-54302.stderr @@ -0,0 +1,11 @@ +error: implementation of `Deserialize` is not general enough + --> $DIR/hrtb-cache-issue-54302.rs:19:5 + | +LL | assert_deserialize_owned::<&'static str>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Deserialize` is not general enough + | + = note: `&'static str` must implement `Deserialize<'0>`, for any lifetime `'0`... + = note: ...but `&str` actually implements `Deserialize<'1>`, for some specific lifetime `'1` + +error: aborting due to previous error + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.rs new file mode 100644 index 000000000..e83686404 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.rs @@ -0,0 +1,31 @@ +// Test that an impl with only one bound region `'a` cannot be used to +// satisfy a constraint where there are two bound regions. + +trait Foo { + fn foo(&self, x: X) { } +} + +fn want_foo2() + where T : for<'a,'b> Foo<(&'a isize, &'b isize)> +{ +} + +fn want_foo1() + where T : for<'z> Foo<(&'z isize, &'z isize)> +{ +} + +// Expressed as a where clause + +struct SomeStruct; + +impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct +{ +} + +fn a() { want_foo1::(); } // OK -- foo wants just one region +fn b() { want_foo2::(); } +//~^ ERROR implementation of +//~| ERROR implementation of + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.stderr new file mode 100644 index 000000000..46f5308dd --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-conflate-regions.stderr @@ -0,0 +1,20 @@ +error: implementation of `Foo` is not general enough + --> $DIR/hrtb-conflate-regions.rs:27:10 + | +LL | fn b() { want_foo2::(); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | + = note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` + +error: implementation of `Foo` is not general enough + --> $DIR/hrtb-conflate-regions.rs:27:10 + | +LL | fn b() { want_foo2::(); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | + = note: `SomeStruct` must implement `Foo<(&'0 isize, &'1 isize)>`, for any two lifetimes `'0` and `'1`... + = note: ...but it actually implements `Foo<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.rs new file mode 100644 index 000000000..05d3e1a43 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.rs @@ -0,0 +1,18 @@ +// Test the case where the `Self` type has a bound lifetime that must +// be adjusted in the fn signature. Issue #19537. + +use std::collections::HashMap; + +struct Foo<'a> { + map: HashMap +} + +impl<'a> Foo<'a> { + fn new() -> Foo<'a> { panic!() } + fn insert(&'a mut self) { } +} +fn main() { + let mut foo = Foo::new(); + foo.insert(); + foo.insert(); //~ ERROR cannot borrow +} 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 new file mode 100644 index 000000000..fa391ecba --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-in-receiver.stderr @@ -0,0 +1,14 @@ +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 +LL | foo.insert(); + | ^^^^^^^^^^^^ + | | + | second mutable borrow occurs here + | first borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-object-types-in-closures.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-object-types-in-closures.rs new file mode 100644 index 000000000..8431226a3 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-debruijn-object-types-in-closures.rs @@ -0,0 +1,16 @@ +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Typer<'tcx> { + fn method(&self, data: &'tcx isize) -> &'tcx isize { data } + fn dummy(&self) { } +} + +fn g(_: F) where F: FnOnce(&dyn Typer) {} + +fn h() { + g(|typer| typer.dummy()) +} + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.rs new file mode 100644 index 000000000..567802376 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.rs @@ -0,0 +1,18 @@ +// Test an `exists<'a> { forall<'b> { 'a = 'b } }` pattern -- which should not compile! +// +// In particular, we test this pattern in trait solving, where it is not connected +// to any part of the source code. + +fn foo<'a>() -> fn(&'a u32) { + panic!() +} + +fn main() { + // Here, proving that `fn(&'a u32) <: for<'b> fn(&'b u32)`: + // + // - instantiates `'b` with a placeholder `!b`, + // - requires that `&!b u32 <: &'a u32` and hence that `!b: 'a`, + // - but we can never know this. + + let _: for<'b> fn(&'b u32) = foo(); //~ ERROR mismatched types +} 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 new file mode 100644 index 000000000..9914783d9 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-fn.stderr @@ -0,0 +1,12 @@ +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 + | + = note: expected fn pointer `for<'b> fn(&'b u32)` + found fn pointer `fn(&u32)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.rs new file mode 100644 index 000000000..921061916 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.rs @@ -0,0 +1,36 @@ +// Test a case where variance and higher-ranked types interact in surprising ways. +// +// In particular, we test this pattern in trait solving, where it is not connected +// to any part of the source code. + +trait Trait {} + +fn foo() +where + T: Trait fn(&'b u32)>, +{ +} + +impl<'a> Trait for () {} + +fn main() { + // Here, proving that `(): Trait fn(&'b u32)>` uses the impl: + // + // - The impl provides the clause `forall<'a> { (): Trait }` + // - We instantiate `'a` existentially to get `(): Trait` + // - We unify `fn(&?a u32)` with `for<'b> fn(&'b u32)` -- this does a + // "bidirectional" subtyping check, so we wind up with: + // - `fn(&?a u32) <: for<'b> fn(&'b u32)` :- + // - `&'!b u32 <: &?a u32` + // - `!'b: ?a` -- solveable if `?a` is inferred to `'empty` + // - `for<'b> fn(&'b u32) <: fn(&?a u32)` :- + // - `&?a u32 u32 <: &?b u32` + // - `?a: ?b` -- solveable if `?b` is also inferred to `'empty` + // - So the subtyping check succeeds, somewhat surprisingly. + // This is because we can use `'empty`. + // + // NB. *However*, the reinstated leak-check gives an error here. + + foo::<()>(); + //~^ ERROR implementation of `Trait` is not general enough +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.stderr new file mode 100644 index 000000000..364b613fc --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-contravariant.stderr @@ -0,0 +1,11 @@ +error: implementation of `Trait` is not general enough + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 + | +LL | foo::<()>(); + | ^^^^^^^^^^^ implementation of `Trait` is not general enough + | + = note: `()` must implement `Trait fn(&'b u32)>` + = note: ...but it actually implements `Trait`, for some specific lifetime `'0` + +error: aborting due to previous error + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-covariant.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-covariant.rs new file mode 100644 index 000000000..f95496a6c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-covariant.rs @@ -0,0 +1,37 @@ +// Test a case where variance and higher-ranked types interact in surprising ways. +// +// In particular, we test this pattern in trait solving, where it is not connected +// to any part of the source code. +// +// check-pass + +trait Trait {} + +fn foo() +where + T: Trait fn(fn(&'b u32))>, +{ +} + +impl<'a> Trait for () {} + +fn main() { + // Here, proving that `(): Trait fn(&'b u32)>` uses the impl: + // + // - The impl provides the clause `forall<'a> { (): Trait }` + // - We instantiate `'a` existentially to get `(): Trait` + // - We unify `fn(fn(&?a u32))` with `for<'b> fn(fn(&'b u32))` -- this does a + // "bidirectional" subtyping check, so we wind up with: + // - `fn(fn(&?a u32)) <: for<'b> fn(fn(&'b u32))` :- + // - `fn(&!b u32) <: fn(&?a u32)` + // - `&?a u32 <: &!b u32` + // - `?a: !'b` -- solveable if `?a` is inferred to `'static` + // - `for<'b> fn(fn(&'b u32)) <: fn(fn(&?a u32))` :- + // - `fn(&?a u32) <: fn(&?b u32)` + // - `&?b u32 <: &?a u32` + // - `?b: ?a` -- solveable if `?b` is inferred to `'static` + // - So the subtyping check succeeds, somewhat surprisingly. + // This is because we can use `'static`. + + foo::<()>(); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.rs new file mode 100644 index 000000000..9b9e4496a --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.rs @@ -0,0 +1,29 @@ +// Test an `exists<'a> { forall<'b> { 'a = 'b } }` pattern -- which should not compile! +// +// In particular, we test this pattern in trait solving, where it is not connected +// to any part of the source code. + +use std::cell::Cell; + +trait Trait {} + +fn foo() +where + T: Trait fn(Cell<&'b u32>)>, +{ +} + +impl<'a> Trait)> for () {} + +fn main() { + // Here, proving that `(): Trait fn(&'b u32)>` uses the impl: + // + // - The impl provides the clause `forall<'a> { (): Trait }` + // - We instantiate `'a` existentially to get `(): Trait` + // - We unify `fn(&?a u32)` with `for<'b> fn(&'b u32)` + // - This requires (among other things) instantiating `'b` universally, + // yielding `fn(&!b u32)`, in a fresh universe U1 + // - So we get `?a = !b` but the universe U0 assigned to `?a` cannot name `!b`. + + foo::<()>(); //~ ERROR implementation of `Trait` is not general enough +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.stderr new file mode 100644 index 000000000..cb2ce8a41 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-exists-forall-trait-invariant.stderr @@ -0,0 +1,11 @@ +error: implementation of `Trait` is not general enough + --> $DIR/hrtb-exists-forall-trait-invariant.rs:28:5 + | +LL | foo::<()>(); + | ^^^^^^^^^^^ implementation of `Trait` is not general enough + | + = note: `()` must implement `Trait fn(Cell<&'b u32>)>` + = note: ...but it actually implements `Trait)>`, for some specific lifetime `'0` + +error: aborting due to previous error + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait-object.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait-object.rs new file mode 100644 index 000000000..ff84ad9d2 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait-object.rs @@ -0,0 +1,27 @@ +// run-pass +// A basic test of using a higher-ranked trait bound. + + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b; + +struct Identity; + +impl<'a, T> FnLike<&'a T, &'a T> for Identity { + fn call(&self, arg: &'a T) -> &'a T { + arg + } +} + +fn call_repeatedly(f: &FnObject) { + let x = 3; + let y = f.call(&x); + assert_eq!(3, *y); +} + +fn main() { + call_repeatedly(&Identity); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait.rs new file mode 100644 index 000000000..afab9986c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-fn-like-trait.rs @@ -0,0 +1,27 @@ +// run-pass +// A basic test of using a higher-ranked trait bound. + + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +struct Identity; + +impl<'a, T> FnLike<&'a T, &'a T> for Identity { + fn call(&self, arg: &'a T) -> &'a T { + arg + } +} + +fn call_repeatedly(f: F) + where F : for<'a> FnLike<&'a isize, &'a isize> +{ + let x = 3; + let y = f.call(&x); + assert_eq!(3, *y); +} + +fn main() { + call_repeatedly(Identity); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs new file mode 100644 index 000000000..f9ae1429e --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.rs @@ -0,0 +1,50 @@ +// Test HRTB supertraits with several levels of expansion required. + +trait Foo<'tcx> +{ + fn foo(&'tcx self) -> &'tcx isize; +} + +trait Bar<'ccx> + : for<'tcx> Foo<'tcx> +{ + fn bar(&'ccx self) -> &'ccx isize; +} + +trait Baz + : for<'ccx> Bar<'ccx> +{ + fn dummy(&self); +} + +trait Qux + : Bar<'static> +{ + fn dummy(&self); +} + +fn want_foo_for_any_tcx(f: &F) + where F : for<'tcx> Foo<'tcx> +{ +} + +fn want_bar_for_any_ccx(b: &B) + where B : for<'ccx> Bar<'ccx> +{ +} + +fn want_baz(b: &B) + where B : Baz +{ + want_foo_for_any_tcx(b); + want_bar_for_any_ccx(b); +} + +fn want_qux(b: &B) + where B : Qux +{ + want_foo_for_any_tcx(b); + want_bar_for_any_ccx(b); //~ ERROR +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr new file mode 100644 index 000000000..b1b8ffa8c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26 + | +LL | want_bar_for_any_ccx(b); + | -------------------- ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` + | | + | required by a bound introduced by this call + | +note: required by a bound in `want_bar_for_any_ccx` + --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:32:15 + | +LL | fn want_bar_for_any_ccx(b: &B) + | -------------------- required by a bound in this function +LL | where B : for<'ccx> Bar<'ccx> + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx` +help: consider further restricting this bound + | +LL | where B : Qux + for<'ccx> Bar<'ccx> + | +++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.rs new file mode 100644 index 000000000..48ebe5017 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.rs @@ -0,0 +1,48 @@ +// Test a trait (`Bar`) with a higher-ranked supertrait. + +trait Foo<'tcx> +{ + fn foo(&'tcx self) -> &'tcx isize; +} + +trait Bar<'ccx> + : for<'tcx> Foo<'tcx> +{ + fn bar(&'ccx self) -> &'ccx isize; +} + +fn want_foo_for_some_tcx<'x,F>(f: &'x F) + where F : Foo<'x> +{ + want_foo_for_some_tcx(f); + want_foo_for_any_tcx(f); //~ ERROR not satisfied +} + +fn want_foo_for_any_tcx(f: &F) + where F : for<'tcx> Foo<'tcx> +{ + want_foo_for_some_tcx(f); + want_foo_for_any_tcx(f); +} + +fn want_bar_for_some_ccx<'x,B>(b: &B) + where B : Bar<'x> +{ + want_foo_for_some_tcx(b); + want_foo_for_any_tcx(b); + + want_bar_for_some_ccx(b); + want_bar_for_any_ccx(b); //~ ERROR not satisfied +} + +fn want_bar_for_any_ccx(b: &B) + where B : for<'ccx> Bar<'ccx> +{ + want_foo_for_some_tcx(b); + want_foo_for_any_tcx(b); + + want_bar_for_some_ccx(b); + want_bar_for_any_ccx(b); +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.stderr new file mode 100644 index 000000000..7f96909b6 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits.stderr @@ -0,0 +1,43 @@ +error[E0277]: the trait bound `for<'tcx> F: Foo<'tcx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits.rs:18:26 + | +LL | want_foo_for_any_tcx(f); + | -------------------- ^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` + | | + | required by a bound introduced by this call + | +note: required by a bound in `want_foo_for_any_tcx` + --> $DIR/hrtb-higher-ranker-supertraits.rs:22:15 + | +LL | fn want_foo_for_any_tcx(f: &F) + | -------------------- required by a bound in this function +LL | where F : for<'tcx> Foo<'tcx> + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_foo_for_any_tcx` +help: consider further restricting this bound + | +LL | where F : Foo<'x> + for<'tcx> Foo<'tcx> + | +++++++++++++++++++++ + +error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits.rs:35:26 + | +LL | want_bar_for_any_ccx(b); + | -------------------- ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` + | | + | required by a bound introduced by this call + | +note: required by a bound in `want_bar_for_any_ccx` + --> $DIR/hrtb-higher-ranker-supertraits.rs:39:15 + | +LL | fn want_bar_for_any_ccx(b: &B) + | -------------------- required by a bound in this function +LL | where B : for<'ccx> Bar<'ccx> + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx` +help: consider further restricting this bound + | +LL | where B : Bar<'x> + for<'ccx> Bar<'ccx> + | +++++++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.rs new file mode 100644 index 000000000..89fc4705a --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.rs @@ -0,0 +1,26 @@ +// Test that the `'a` in the where clause correctly links the region +// of the output to the region of the input. + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +fn call_repeatedly(f: F) + where F : for<'a> FnLike<&'a isize, &'a isize> +{ + // Result is stored: cannot re-assign `x` + let mut x = 3; + let y = f.call(&x); + x = 5; //~ ERROR cannot assign to `x` because it is borrowed + + // Result is not stored: can re-assign `x` + let mut x = 3; + f.call(&x); + f.call(&x); + f.call(&x); + x = 5; + drop(y); +} + +fn main() { +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.stderr new file mode 100644 index 000000000..25af011e3 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-identity-fn-borrows.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/hrtb-identity-fn-borrows.rs:14:5 + | +LL | let y = f.call(&x); + | -- `x` is borrowed here +LL | x = 5; + | ^^^^^ `x` is assigned to here but it was already borrowed +... +LL | drop(y); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.rs new file mode 100644 index 000000000..8fb4218f8 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.rs @@ -0,0 +1,35 @@ +// Test a case where you have an impl of `Foo` for all `X` that +// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. + +trait Foo { + fn foo(&self, x: X) { } +} + +fn want_hrtb() + where T : for<'a> Foo<&'a isize> +{ +} + +// AnyInt implements Foo<&'a isize> for any 'a, so it is a match. +struct AnyInt; +impl<'a> Foo<&'a isize> for AnyInt { } +fn give_any() { + want_hrtb::() +} + +// StaticInt only implements Foo<&'static isize>, so it is an error. +struct StaticInt; +impl Foo<&'static isize> for StaticInt { } +fn give_static() { + want_hrtb::() //~ ERROR +} + +// &'a u32 only implements Foo<&'a isize> for specific 'a, so it is an error. +impl<'a> Foo<&'a isize> for &'a u32 { } +fn give_some<'a>() { + want_hrtb::<&'a u32>() + //~^ ERROR lifetime may not live long enough + //~| ERROR implementation of `Foo` is not general enough +} + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr new file mode 100644 index 000000000..31e11e128 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-just-for-static.stderr @@ -0,0 +1,34 @@ +error: implementation of `Foo` is not general enough + --> $DIR/hrtb-just-for-static.rs:24:5 + | +LL | want_hrtb::() + | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | + = note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`... + = note: ...but it actually implements `Foo<&'static isize>` + +error: lifetime may not live long enough + --> $DIR/hrtb-just-for-static.rs:30:5 + | +LL | fn give_some<'a>() { + | -- lifetime `'a` defined here +LL | want_hrtb::<&'a u32>() + | ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-just-for-static.rs:9:15 + | +LL | where T : for<'a> Foo<&'a isize> + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of `Foo` is not general enough + --> $DIR/hrtb-just-for-static.rs:30:5 + | +LL | want_hrtb::<&'a u32>() + | ^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | + = note: `Foo<&'0 isize>` would have to be implemented for the type `&u32`, for any lifetime `'0`... + = note: ...but `Foo<&'1 isize>` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.rs new file mode 100644 index 000000000..4b096be59 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.rs @@ -0,0 +1,20 @@ +// Test that Fn-family traits with lifetime parameters shouldn't compile and +// we suggest the usage of higher-rank trait bounds instead. + +fn fa(_: impl Fn<'a>(&'a str) -> bool) {} +//~^ ERROR `Fn` traits cannot take lifetime parameters + +fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {} +//~^ ERROR `Fn` traits cannot take lifetime parameters + +fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {} +//~^ ERROR `Fn` traits cannot take lifetime parameters + +use std::ops::Fn as AliasedFn; +fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {} +//~^ ERROR `Fn` traits cannot take lifetime parameters + +fn fe(_: F) where F: Fn<'a>(&'a str) -> bool {} +//~^ ERROR `Fn` traits cannot take lifetime parameters + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.stderr new file mode 100644 index 000000000..e8f6d63b5 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-malformed-lifetime-generics.stderr @@ -0,0 +1,62 @@ +error: `Fn` traits cannot take lifetime parameters + --> $DIR/hrtb-malformed-lifetime-generics.rs:4:17 + | +LL | fn fa(_: impl Fn<'a>(&'a str) -> bool) {} + | ^^^^ + | +help: consider using a higher-ranked trait bound instead + | +LL - fn fa(_: impl Fn<'a>(&'a str) -> bool) {} +LL + fn fa(_: impl for<'a> Fn(&'a str) -> bool) {} + | + +error: `Fn` traits cannot take lifetime parameters + --> $DIR/hrtb-malformed-lifetime-generics.rs:7:20 + | +LL | fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {} + | ^^^^^^^^ + | +help: consider using a higher-ranked trait bound instead + | +LL - fn fb(_: impl FnMut<'a, 'b>(&'a str, &'b str) -> bool) {} +LL + fn fb(_: impl for<'a, 'b> FnMut(&'a str, &'b str) -> bool) {} + | + +error: `Fn` traits cannot take lifetime parameters + --> $DIR/hrtb-malformed-lifetime-generics.rs:10:41 + | +LL | fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {} + | ^^^^ + | +help: consider using a higher-ranked trait bound instead + | +LL - fn fc(_: impl std::fmt::Display + FnOnce<'a>(&'a str) -> bool + std::fmt::Debug) {} +LL + fn fc(_: impl std::fmt::Display + for<'a> FnOnce(&'a str) -> bool + std::fmt::Debug) {} + | + +error: `Fn` traits cannot take lifetime parameters + --> $DIR/hrtb-malformed-lifetime-generics.rs:14:24 + | +LL | fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {} + | ^^^^ + | +help: consider using a higher-ranked trait bound instead + | +LL - fn fd(_: impl AliasedFn<'a>(&'a str) -> bool) {} +LL + fn fd(_: impl for<'a> AliasedFn(&'a str) -> bool) {} + | + +error: `Fn` traits cannot take lifetime parameters + --> $DIR/hrtb-malformed-lifetime-generics.rs:17:27 + | +LL | fn fe(_: F) where F: Fn<'a>(&'a str) -> bool {} + | ^^^^ + | +help: consider using a higher-ranked trait bound instead + | +LL - fn fe(_: F) where F: Fn<'a>(&'a str) -> bool {} +LL + fn fe(_: F) where F: for<'a> Fn(&'a str) -> bool {} + | + +error: aborting due to 5 previous errors + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-opt-in-copy.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-opt-in-copy.rs new file mode 100644 index 000000000..04519f116 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-opt-in-copy.rs @@ -0,0 +1,28 @@ +// run-pass +// Test that we handle binder levels correctly when checking whether a +// type can implement `Copy`. In particular, we had a bug where we failed to +// liberate the late-bound regions from the impl, and thus wound up +// searching for an impl of `for<'tcx> Foo<&'tcx T>`. The impl that +// exists however is `impl Copy for Foo` and the current rules +// did not consider that a match (something I would like to revise in +// a later PR). + +#![allow(dead_code)] + +use std::marker::PhantomData; + +#[derive(Copy, Clone)] +struct Foo { x: T } + +type Ty<'tcx> = &'tcx TyS<'tcx>; + +enum TyS<'tcx> { + Boop(PhantomData<*mut &'tcx ()>) +} + +#[derive(Copy, Clone)] +enum Bar<'tcx> { + Baz(Foo>) +} + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-parse.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-parse.rs new file mode 100644 index 000000000..1fab9758c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-parse.rs @@ -0,0 +1,36 @@ +// run-pass +// Test that we can parse all the various places that a `for` keyword +// can appear representing universal quantification. + +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] +#![allow(dead_code)] + +trait Get { + fn get(&self, arg: A) -> R; +} + +// Parse HRTB with explicit `for` in a where-clause: + +fn foo00(t: T) + where T : for<'a> Get<&'a i32, &'a i32> +{ +} + +fn foo01 Get<&'a i32, &'a i32>>(t: T) +{ +} + +// Parse HRTB with explicit `for` in various sorts of types: + +fn foo10(t: Box Get>) { } +fn foo11(t: Box Fn(i32) -> i32>) { } + +fn foo20(t: for<'a> fn(i32) -> i32) { } +fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } +fn foo22(t: for<'a> extern "C" fn(i32) -> i32) { } +fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { } + +fn main() { +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.polonius.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.polonius.stderr new file mode 100644 index 000000000..a94c80eb3 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.polonius.stderr @@ -0,0 +1,71 @@ +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:16:1 + | +LL | / fn no_hrtb<'b, T>(mut t: T) +LL | | where +LL | | T: Bar<&'b isize>, +LL | | { +... | +LL | | no_hrtb(&mut t); + | | --------------- recursive call site +LL | | } + | |_^ cannot return without recursing + | + = note: `#[warn(unconditional_recursion)]` on by default + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:25:1 + | +LL | / fn bar_hrtb(mut t: T) +LL | | where +LL | | T: for<'b> Bar<&'b isize>, +LL | | { +... | +LL | | bar_hrtb(&mut t); + | | ---------------- recursive call site +LL | | } + | |_^ cannot return without recursing + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:35:1 + | +LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T) +LL | | where +LL | | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, +LL | | { +... | +LL | | foo_hrtb_bar_not(&mut t); + | | ------------------------ recursive call site +LL | | +LL | | +LL | | } + | |_^ cannot return without recursing + | + = help: a `loop` may express intention better if this is on purpose + +error: higher-ranked subtype error + --> $DIR/hrtb-perfect-forwarding.rs:43:5 + | +LL | foo_hrtb_bar_not(&mut t); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:48:1 + | +LL | / fn foo_hrtb_bar_hrtb(mut t: T) +LL | | where +LL | | T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, +LL | | { +LL | | // OK -- now we have `T : for<'b> Bar<&'b isize>`. +LL | | foo_hrtb_bar_hrtb(&mut t); + | | ------------------------- recursive call site +LL | | } + | |_^ cannot return without recursing + | + = help: a `loop` may express intention better if this is on purpose + +error: aborting due to previous error; 4 warnings emitted + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.rs new file mode 100644 index 000000000..d45fa183c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.rs @@ -0,0 +1,56 @@ +// Test a case where you have an impl of `Foo` for all `X` that +// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. + +trait Foo { + fn foo(&mut self, x: X) {} +} + +trait Bar { + fn bar(&mut self, x: X) {} +} + +impl<'a, X, F> Foo for &'a mut F where F: Foo + Bar {} + +impl<'a, X, F> Bar for &'a mut F where F: Bar {} + +fn no_hrtb<'b, T>(mut t: T) //~ WARN function cannot return +where + T: Bar<&'b isize>, +{ + // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that + // `&mut T : Bar<&'b isize>`. + no_hrtb(&mut t); +} + +fn bar_hrtb(mut t: T) //~ WARN function cannot return +where + T: for<'b> Bar<&'b isize>, +{ + // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above + // ensures that `&mut T : for<'b> Bar<&'b isize>`. This is an + // example of a "perfect forwarding" impl. + bar_hrtb(&mut t); +} + +fn foo_hrtb_bar_not<'b, T>(mut t: T) //~ WARN function cannot return +where + T: for<'a> Foo<&'a isize> + Bar<&'b isize>, +{ + // Not OK -- The forwarding impl for `Foo` requires that `Bar` also + // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a + // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where + // clause only specifies `T : Bar<&'b isize>`. + foo_hrtb_bar_not(&mut t); + //~^ ERROR implementation of `Bar` is not general enough + //~^^ ERROR lifetime may not live long enough +} + +fn foo_hrtb_bar_hrtb(mut t: T) //~ WARN function cannot return +where + T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, +{ + // OK -- now we have `T : for<'b> Bar<&'b isize>`. + foo_hrtb_bar_hrtb(&mut t); +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr new file mode 100644 index 000000000..727b9e6be --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-perfect-forwarding.stderr @@ -0,0 +1,79 @@ +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:16:1 + | +LL | / fn no_hrtb<'b, T>(mut t: T) +LL | | where +LL | | T: Bar<&'b isize>, + | |______________________^ cannot return without recursing +... +LL | no_hrtb(&mut t); + | --------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:25:1 + | +LL | / fn bar_hrtb(mut t: T) +LL | | where +LL | | T: for<'b> Bar<&'b isize>, + | |______________________________^ cannot return without recursing +... +LL | bar_hrtb(&mut t); + | ---------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:35:1 + | +LL | / fn foo_hrtb_bar_not<'b, T>(mut t: T) +LL | | where +LL | | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, + | |_______________________________________________^ cannot return without recursing +... +LL | foo_hrtb_bar_not(&mut t); + | ------------------------ recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +error: lifetime may not live long enough + --> $DIR/hrtb-perfect-forwarding.rs:43:5 + | +LL | fn foo_hrtb_bar_not<'b, T>(mut t: T) + | -- lifetime `'b` defined here +... +LL | foo_hrtb_bar_not(&mut t); + | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + | +note: due to current limitations in the borrow checker, this implies a `'static` lifetime + --> $DIR/hrtb-perfect-forwarding.rs:37:8 + | +LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>, + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of `Bar` is not general enough + --> $DIR/hrtb-perfect-forwarding.rs:43:5 + | +LL | foo_hrtb_bar_not(&mut t); + | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Bar` is not general enough + | + = note: `T` must implement `Bar<&'0 isize>`, for any lifetime `'0`... + = note: ...but it actually implements `Bar<&'1 isize>`, for some specific lifetime `'1` + +warning: function cannot return without recursing + --> $DIR/hrtb-perfect-forwarding.rs:48:1 + | +LL | / fn foo_hrtb_bar_hrtb(mut t: T) +LL | | where +LL | | T: for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>, + | |_______________________________________________________^ cannot return without recursing +... +LL | foo_hrtb_bar_hrtb(&mut t); + | ------------------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + +error: aborting due to 2 previous errors; 4 warnings emitted + diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus-where-clause.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus-where-clause.rs new file mode 100644 index 000000000..42247798f --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus-where-clause.rs @@ -0,0 +1,25 @@ +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +// Test that `F : Fn(isize) -> isize + Send` is interpreted as two +// distinct bounds on `F`. + +fn foo1(f: F) + where F : FnOnce(isize) -> isize + Send +{ + bar(f); +} + +fn foo2(f: F) + where F : FnOnce(isize) -> isize + Send +{ + baz(f); +} + +fn bar(f: F) { } + +fn baz isize>(f: F) { } + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus.rs new file mode 100644 index 000000000..6834c392d --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-precedence-of-plus.rs @@ -0,0 +1,13 @@ +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +// Test that `Fn(isize) -> isize + 'static` parses as `(Fn(isize) -> isize) + +// 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would +// cause a compilation error. Issue #18772. + +fn adder(y: isize) -> Box isize + 'static> { + Box::new(move |x| y + x) +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-resolve-lifetime.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-resolve-lifetime.rs new file mode 100644 index 000000000..b97fdf4df --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-resolve-lifetime.rs @@ -0,0 +1,14 @@ +// run-pass +#![allow(dead_code)] +// A basic test of using a higher-ranked trait bound. + +// pretty-expanded FIXME #23616 + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b; + +fn main() { +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-paren-notation.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-paren-notation.rs new file mode 100644 index 000000000..d8c726cdd --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-paren-notation.rs @@ -0,0 +1,26 @@ +// run-pass +// A basic test of using a higher-ranked trait bound. + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +type FnObject<'b> = dyn for<'a> FnLike<(&'a i32,), &'a i32> + 'b; + +struct Identity; + +impl<'a, T> FnLike<(&'a T,), &'a T> for Identity { + fn call(&self, (arg,): (&'a T,)) -> &'a T { + arg + } +} + +fn call_repeatedly(f: &FnObject) { + let x = 3; + let y = f.call((&x,)); + assert_eq!(3, *y); +} + +fn main() { + call_repeatedly(&Identity); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-passed-to-closure.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-passed-to-closure.rs new file mode 100644 index 000000000..41ebb3f5a --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-trait-object-passed-to-closure.rs @@ -0,0 +1,25 @@ +// run-pass +#![allow(dead_code)] +// Test that `&PrinterSupport`, which is really short for `&'a +// PrinterSupport<'b>`, gets properly expanded when it appears in a +// closure type. This used to result in messed up De Bruijn indices. + +// pretty-expanded FIXME #23616 + +trait PrinterSupport<'ast> { + fn ast_map(&self) -> Option<&'ast usize> { None } +} + +struct NoAnn<'ast> { + f: Option<&'ast usize> +} + +impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> { +} + +fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&dyn PrinterSupport) { + let annotation = NoAnn { f: f }; + g(&annotation) +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-type-outlives.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-type-outlives.rs new file mode 100644 index 000000000..88d396101 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-type-outlives.rs @@ -0,0 +1,46 @@ +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test what happens when a HR obligation is applied to an impl with +// "outlives" bounds. Currently we're pretty conservative here; this +// will probably improve in time. + +trait Foo { + fn foo(&self, x: X) { } +} + +fn want_foo() + where T : for<'a> Foo<&'a isize> +{ +} + +// Expressed as a where clause + +struct SomeStruct { + x: X +} + +impl<'a,X> Foo<&'a isize> for SomeStruct + where X : 'a +{ +} + +fn one() { + want_foo::>(); +} + +// Expressed as shorthand + +struct AnotherStruct { + x: X +} + +impl<'a,X:'a> Foo<&'a isize> for AnotherStruct +{ +} + +fn two() { + want_foo::>(); +} + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-unboxed-closure-trait.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-unboxed-closure-trait.rs new file mode 100644 index 000000000..a4a8a5ac6 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-unboxed-closure-trait.rs @@ -0,0 +1,11 @@ +// run-pass +// Test HRTB used with the `Fn` trait. + +fn foo(f: F) { + let x = 22; + f(&x); +} + +fn main() { + foo(|x: &isize| println!("{}", *x)); +} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.rs new file mode 100644 index 000000000..1a9bb2523 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.rs @@ -0,0 +1,7 @@ +fn a() where for T: Copy {} +//~^ ERROR only lifetime parameters can be used in this context + +fn b() where for [(); C]: Copy {} +//~^ ERROR only lifetime parameters can be used in this context + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.stderr new file mode 100644 index 000000000..765ea9f78 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-wrong-kind.stderr @@ -0,0 +1,21 @@ +error[E0658]: only lifetime parameters can be used in this context + --> $DIR/hrtb-wrong-kind.rs:1:18 + | +LL | fn a() where for T: Copy {} + | ^ + | + = note: see issue #108185 for more information + = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable + +error[E0658]: only lifetime parameters can be used in this context + --> $DIR/hrtb-wrong-kind.rs:4:24 + | +LL | fn b() where for [(); C]: Copy {} + | ^ + | + = note: see issue #108185 for more information + = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/higher-ranked/trait-bounds/issue-100689.rs b/tests/ui/higher-ranked/trait-bounds/issue-100689.rs new file mode 100644 index 000000000..2db7f8a35 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-100689.rs @@ -0,0 +1,29 @@ +// check-pass + +struct Foo<'a> { + foo: &'a mut usize, +} + +trait Bar<'a> { + type FooRef<'b> + where + 'a: 'b; + fn uwu(foo: Foo<'a>, f: impl for<'b> FnMut(Self::FooRef<'b>)); +} +impl<'a> Bar<'a> for () { + type FooRef<'b> + = + &'b Foo<'a> + where + 'a : 'b, + ; + + fn uwu( + foo: Foo<'a>, + mut f: impl for<'b> FnMut(&'b Foo<'a>), //relevant part + ) { + f(&foo); + } +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-102899.rs b/tests/ui/higher-ranked/trait-bounds/issue-102899.rs new file mode 100644 index 000000000..952b81584 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-102899.rs @@ -0,0 +1,32 @@ +// check-pass + +pub trait BufferTrait<'buffer> { + type Subset<'channel> + where + 'buffer: 'channel; + + fn for_each_subset(&self, f: F) + where + F: for<'channel> Fn(Self::Subset<'channel>); +} + +pub struct SomeBuffer<'buffer> { + samples: &'buffer [()], +} + +impl<'buffer> BufferTrait<'buffer> for SomeBuffer<'buffer> { + type Subset<'subset> = Subset<'subset> where 'buffer: 'subset; + + fn for_each_subset(&self, _f: F) + where + F: for<'subset> Fn(Subset<'subset>), + { + todo!() + } +} + +pub struct Subset<'subset> { + buffer: &'subset [()], +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-30786.rs b/tests/ui/higher-ranked/trait-bounds/issue-30786.rs new file mode 100644 index 000000000..4a6399c8f --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-30786.rs @@ -0,0 +1,136 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" + +// rust-lang/rust#30786: the use of `for<'b> &'b mut A: Stream Option; +} + +// Example stream +pub struct Repeat(u64); + +impl<'a> Stream for &'a mut Repeat { + type Item = &'a u64; + fn next(self) -> Option { + Some(&self.0) + } +} + +pub struct Map { + stream: S, + func: F, +} + +impl<'a, A, F, T> Stream for &'a mut Map +where + &'a mut A: Stream, + F: FnMut(<&'a mut A as Stream>::Item) -> T, +{ + type Item = T; + fn next(self) -> Option { + match self.stream.next() { + Some(item) => Some((self.func)(item)), + None => None, + } + } +} + +pub struct Filter { + stream: S, + func: F, +} + +impl<'a, A, F, T> Stream for &'a mut Filter +where + for<'b> &'b mut A: Stream, // <---- BAD + F: FnMut(&T) -> bool, +{ + type Item = <&'a mut A as Stream>::Item; + fn next(self) -> Option { + while let Some(item) = self.stream.next() { + if (self.func)(&item) { + return Some(item); + } + } + None + } +} + +pub trait StreamExt +where + for<'b> &'b mut Self: Stream, +{ + fn mapx(self, func: F) -> Map + where + Self: Sized, + for<'a> &'a mut Map: Stream, + { + Map { func: func, stream: self } + } + + fn filterx(self, func: F) -> Filter + where + Self: Sized, + for<'a> &'a mut Filter: Stream, + { + Filter { func: func, stream: self } + } + + fn countx(mut self) -> usize + where + Self: Sized, + { + let mut count = 0; + while let Some(_) = self.next() { + count += 1; + } + count + } +} + +impl StreamExt for T where for<'a> &'a mut T: Stream {} + +fn identity(x: &T) -> &T { + x +} + +fn variant1() { + let source = Repeat(10); + + // Here, the call to `mapx` returns a type `T` to which `StreamExt` + // is not applicable, because `for<'b> &'b mut T: Stream`) doesn't hold. + // + // More concretely, the type `T` is `Map`, and + // the where clause doesn't hold because the signature of the + // closure gets inferred to a signature like `|&'_ Stream| -> &'_` + // for some specific `'_`, rather than a more generic + // signature. + // + // Why *exactly* we opt for this signature is a bit unclear to me, + // we deduce it somehow from a reuqirement that `Map: Stream` I + // guess. + let map = source.mapx(|x: &_| x); + let filter = map.filterx(|x: &_| true); + //~^ ERROR the method +} + +fn variant2() { + let source = Repeat(10); + + // Here, we use a function, which is not subject to the vagaries + // of closure signature inference. In this case, we get the error + // on `countx` as, I think, the test originally expected. + let map = source.mapx(identity); + let filter = map.filterx(|x: &_| true); + let count = filter.countx(); + //~^ ERROR the method +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr b/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr new file mode 100644 index 000000000..f32ba5720 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-30786.stderr @@ -0,0 +1,46 @@ +error[E0599]: the method `filterx` exists for struct `Map`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:120:22 + | +LL | pub struct Map { + | -------------------- + | | + | method `filterx` not found for this struct + | doesn't satisfy `_: StreamExt` +... +LL | let filter = map.filterx(|x: &_| true); + | ^^^^^^^ method cannot be called on `Map` due to unsatisfied trait bounds + | +note: the following trait bounds were not satisfied: + `&'a mut &Map: Stream` + `&'a mut &mut Map: Stream` + `&'a mut Map: Stream` + --> $DIR/issue-30786.rs:98:50 + | +LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} + | --------- - ^^^^^^ unsatisfied trait bound introduced here + +error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, [closure@issue-30786.rs:131:30]>`, but its trait bounds were not satisfied + --> $DIR/issue-30786.rs:132:24 + | +LL | pub struct Filter { + | ----------------------- + | | + | method `countx` not found for this struct + | doesn't satisfy `_: StreamExt` +... +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` + `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, [closure@$DIR/issue-30786.rs:131:30: 131:37]>: Stream` + --> $DIR/issue-30786.rs:98:50 + | +LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} + | --------- - ^^^^^^ unsatisfied trait bound introduced here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/higher-ranked/trait-bounds/issue-36139-normalize-closure-sig.rs b/tests/ui/higher-ranked/trait-bounds/issue-36139-normalize-closure-sig.rs new file mode 100644 index 000000000..2d49151ff --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-36139-normalize-closure-sig.rs @@ -0,0 +1,19 @@ +// run-pass +// Previously the closure's argument would be inferred to +// >::Item, causing an error in MIR type +// checking + +trait ITrait<'a> {type Item;} + +struct S {} + +impl<'a> ITrait<'a> for S { type Item = &'a mut usize; } + +fn m(_: F) + where I: for<'a> ITrait<'a>, + F: for<'a> FnMut(>::Item) { } + + +fn main() { + m::(|x| { *x += 1; }); +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-39292.rs b/tests/ui/higher-ranked/trait-bounds/issue-39292.rs new file mode 100644 index 000000000..968cf0891 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-39292.rs @@ -0,0 +1,17 @@ +// run-pass +// Regression test for issue #39292. The object vtable was being +// incorrectly left with a null pointer. + +trait Foo { + fn print<'a>(&'a self) where T: 'a { println!("foo"); } +} + +impl<'a> Foo<&'a ()> for () { } + +trait Bar: for<'a> Foo<&'a ()> { } + +impl Bar for () {} + +fn main() { + (&() as &dyn Bar).print(); // Segfault +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-42114.rs b/tests/ui/higher-ranked/trait-bounds/issue-42114.rs new file mode 100644 index 000000000..01515fdc9 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-42114.rs @@ -0,0 +1,20 @@ +// check-pass + +fn lifetime<'a>() +where + &'a (): 'a, +{ + /* do nothing */ +} + +fn doesnt_work() +where + for<'a> &'a (): 'a, +{ + /* do nothing */ +} + +fn main() { + lifetime(); + doesnt_work(); +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-43623.rs b/tests/ui/higher-ranked/trait-bounds/issue-43623.rs new file mode 100644 index 000000000..cedcf7c36 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-43623.rs @@ -0,0 +1,21 @@ +// check-pass + +pub trait Trait<'a> { + type Assoc; +} + +pub struct Type; + +impl<'a> Trait<'a> for Type { + type Assoc = (); +} + +pub fn break_me(f: F) +where + T: for<'b> Trait<'b>, + F: for<'b> FnMut(>::Assoc), +{ + break_me::; +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-46989.rs b/tests/ui/higher-ranked/trait-bounds/issue-46989.rs new file mode 100644 index 000000000..4a09f4be1 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-46989.rs @@ -0,0 +1,40 @@ +// Regression test for #46989: +// +// In the move to universes, this test started passing. +// It is not necessarily WRONG to do so, but it was a bit +// surprising. The reason that it passed is that when we were +// asked to prove that +// +// for<'a> fn(&'a i32): Foo +// +// we were able to use the impl below to prove +// +// fn(&'empty i32): Foo +// +// and then we were able to prove that +// +// fn(&'empty i32) = for<'a> fn(&'a i32) +// +// This last fact is somewhat surprising, but essentially "falls out" +// from handling variance correctly. In particular, consider the subtyping +// relations. First: +// +// fn(&'empty i32) <: for<'a> fn(&'a i32) +// +// This holds because -- intuitively -- a fn that takes a reference but doesn't use +// it can be given a reference with any lifetime. Similarly, the opposite direction: +// +// for<'a> fn(&'a i32) <: fn(&'empty i32) +// +// holds because 'a can be instantiated to 'empty. + +trait Foo {} + +impl Foo for fn(A) {} + +fn assert_foo() {} + +fn main() { + assert_foo::(); + //~^ ERROR implementation of `Foo` is not general enough +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-46989.stderr b/tests/ui/higher-ranked/trait-bounds/issue-46989.stderr new file mode 100644 index 000000000..3f874220a --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-46989.stderr @@ -0,0 +1,11 @@ +error: implementation of `Foo` is not general enough + --> $DIR/issue-46989.rs:38:5 + | +LL | assert_foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough + | + = note: `Foo` would have to be implemented for the type `for<'a> fn(&'a i32)` + = note: ...but `Foo` is actually implemented for the type `fn(&'0 i32)`, for some specific lifetime `'0` + +error: aborting due to previous error + diff --git a/tests/ui/higher-ranked/trait-bounds/issue-57639.rs b/tests/ui/higher-ranked/trait-bounds/issue-57639.rs new file mode 100644 index 000000000..392e7233b --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-57639.rs @@ -0,0 +1,29 @@ +// Regression test for #57639: +// +// In the move to universes, this test stopped working. The problem +// was that when the trait solver was asked to prove `for<'a> T::Item: +// Foo<'a>` as part of WF checking, it wound up "eagerly committing" +// to the where clause, which says that `T::Item: Foo<'a>`, but it +// should instead have been using the bound found in the trait +// declaration. Pre-universe, this used to work out ok because we got +// "eager errors" due to the leak check. +// +// See [this comment on GitHub][c] for more details. +// +// check-pass +// +// [c]: https://github.com/rust-lang/rust/issues/57639#issuecomment-455685861 + +trait Foo<'a> {} + +trait Bar { + type Item: for<'a> Foo<'a>; +} + +fn foo<'a, T>(_: T) +where + T: Bar, + T::Item: Foo<'a>, +{} + +fn main() { } diff --git a/tests/ui/higher-ranked/trait-bounds/issue-58451.rs b/tests/ui/higher-ranked/trait-bounds/issue-58451.rs new file mode 100644 index 000000000..6006a108c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-58451.rs @@ -0,0 +1,13 @@ +// Regression test for #58451: +// +// Error reporting here encountered an ICE in the shift to universes. + +fn f(i: I) +where + I: IntoIterator, + I::Item: for<'a> Into<&'a ()>, +{} + +fn main() { + f(&[f()]); //~ ERROR function takes 1 argument +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr b/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr new file mode 100644 index 000000000..0f051be21 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr @@ -0,0 +1,19 @@ +error[E0061]: this function takes 1 argument but 0 arguments were supplied + --> $DIR/issue-58451.rs:12:9 + | +LL | f(&[f()]); + | ^-- an argument is missing + | +note: function defined here + --> $DIR/issue-58451.rs:5:4 + | +LL | fn f(i: I) + | ^ ---- +help: provide the argument + | +LL | f(&[f(/* i */)]); + | ~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/higher-ranked/trait-bounds/issue-59311.rs b/tests/ui/higher-ranked/trait-bounds/issue-59311.rs new file mode 100644 index 000000000..3ad548450 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-59311.rs @@ -0,0 +1,22 @@ +// Regression test for #59311. The test is taken from +// rust-lang/rust/issues/71546#issuecomment-620638437 +// as they seem to have the same cause. + +// FIXME: It's not clear that this code ought to report +// an error, but the regression test is here to ensure +// that it does not ICE. See discussion on #74889 for details. + +pub trait T { + fn t(&self, _: F) {} +} + +pub fn crash(v: &V) +where + for<'a> &'a V: T + 'static, +{ + v.t(|| {}); + //~^ ERROR: higher-ranked lifetime error + //~| ERROR: higher-ranked lifetime error +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr b/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr new file mode 100644 index 000000000..c01ab8e34 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr @@ -0,0 +1,18 @@ +error: higher-ranked lifetime error + --> $DIR/issue-59311.rs:17:5 + | +LL | v.t(|| {}); + | ^^^^^^^^^^ + | + = note: could not prove `[closure@$DIR/issue-59311.rs:17:9: 17:11] well-formed` + +error: higher-ranked lifetime error + --> $DIR/issue-59311.rs:17:9 + | +LL | v.t(|| {}); + | ^^^^^ + | + = note: could not prove `for<'a> &'a V: 'static` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/higher-ranked/trait-bounds/issue-60283.rs b/tests/ui/higher-ranked/trait-bounds/issue-60283.rs new file mode 100644 index 000000000..05315b3f9 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-60283.rs @@ -0,0 +1,20 @@ +// check-pass + +pub trait Trait<'a> { + type Item; +} + +impl<'a> Trait<'a> for () { + type Item = (); +} + +pub fn foo(_: T, _: F) +where + T: for<'a> Trait<'a>, + F: for<'a> FnMut(>::Item), +{ +} + +fn main() { + foo((), drop) +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.rs b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.rs new file mode 100644 index 000000000..e70f6fc34 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.rs @@ -0,0 +1,54 @@ +trait T0<'a, A> { + type O; +} + +struct L { + f: T, +} + +// explicitly named variants of what one would normally denote by the +// unit type `()`. Why do this? So that we can differentiate them in +// the diagnostic output. +struct Unit1; +struct Unit2; +struct Unit3; +struct Unit4; + +impl<'a, A, T> T0<'a, A> for L +where + T: FnMut(A) -> Unit3, +{ + type O = T::Output; +} + +trait T1: for<'r> Ty<'r> { + fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 + where + F: for<'r> T0<'r, (>::V,), O = >::V>, + { + unimplemented!(); + } +} + +trait Ty<'a> { + type V; +} + +fn main() { + let v = Unit2.m( + L { + //~^ ERROR to be a closure that returns `Unit3`, but it returns `Unit4` + //~| ERROR type mismatch + f: |x| { + drop(x); + Unit4 + }, + }, + ); +} + +impl<'a> Ty<'a> for Unit2 { + type V = &'a u8; +} + +impl T1 for Unit2 {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr new file mode 100644 index 000000000..4d470ae70 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr @@ -0,0 +1,66 @@ +error[E0271]: type mismatch resolving ` as T0<'r, (&u8,)>>::O == <_ as Ty<'r>>::V` + --> $DIR/issue-62203-hrtb-ice.rs:39:9 + | +LL | let v = Unit2.m( + | - required by a bound introduced by this call +LL | / L { +LL | | +LL | | +LL | | f: |x| { +... | +LL | | }, +LL | | }, + | |_________^ type mismatch resolving ` as T0<'r, (&u8,)>>::O == <_ as Ty<'r>>::V` + | +note: expected this to be `<_ as Ty<'_>>::V` + --> $DIR/issue-62203-hrtb-ice.rs:21:14 + | +LL | type O = T::Output; + | ^^^^^^^^^ + = note: expected associated type `<_ as Ty<'_>>::V` + found struct `Unit4` + = help: consider constraining the associated type `<_ as Ty<'_>>::V` to `Unit4` or calling a method that returns `<_ as Ty<'_>>::V` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: required by a bound in `T1::m` + --> $DIR/issue-62203-hrtb-ice.rs:27:51 + | +LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 + | - required by a bound in this associated function +LL | where +LL | F: for<'r> T0<'r, (>::V,), O = >::V>, + | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` + +error[E0271]: expected `[closure@issue-62203-hrtb-ice.rs:42:16]` to be a closure that returns `Unit3`, but it returns `Unit4` + --> $DIR/issue-62203-hrtb-ice.rs:39:9 + | +LL | let v = Unit2.m( + | - required by a bound introduced by this call +LL | / L { +LL | | +LL | | +LL | | f: |x| { +... | +LL | | }, +LL | | }, + | |_________^ expected `Unit3`, found `Unit4` + | +note: required for `L<[closure@$DIR/issue-62203-hrtb-ice.rs:42:16: 42:19]>` to implement `for<'r> T0<'r, (&'r u8,)>` + --> $DIR/issue-62203-hrtb-ice.rs:17:16 + | +LL | impl<'a, A, T> T0<'a, A> for L + | ^^^^^^^^^ ^^^^ +LL | where +LL | T: FnMut(A) -> Unit3, + | ----- unsatisfied trait bound introduced here +note: required by a bound in `T1::m` + --> $DIR/issue-62203-hrtb-ice.rs:27:12 + | +LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 + | - required by a bound in this associated function +LL | where +LL | F: for<'r> T0<'r, (>::V,), O = >::V>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/higher-ranked/trait-bounds/issue-88446.rs b/tests/ui/higher-ranked/trait-bounds/issue-88446.rs new file mode 100644 index 000000000..571b85317 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-88446.rs @@ -0,0 +1,35 @@ +// check-pass + +trait Yokeable<'a> { + type Output: 'a; +} +impl<'a> Yokeable<'a> for () { + type Output = (); +} + +trait DataMarker<'data> { + type Yokeable: for<'a> Yokeable<'a>; +} +impl<'data> DataMarker<'data> for () { + type Yokeable = (); +} + +struct DataPayload<'data, M>(&'data M); + +impl DataPayload<'static, ()> { + pub fn map_project_with_capture( + _: for<'a> fn( + capture: T, + std::marker::PhantomData<&'a ()>, + ) -> >::Output, + ) -> DataPayload<'static, M2> + where + M2: DataMarker<'static>, + { + todo!() + } +} + +fn main() { + let _: DataPayload<()> = DataPayload::<()>::map_project_with_capture::<_, &()>(|_, _| todo!()); +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs b/tests/ui/higher-ranked/trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs new file mode 100644 index 000000000..92b7c5deb --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-88586-hr-self-outlives-in-trait-def.rs @@ -0,0 +1,13 @@ +// Regression test for #88586: a higher-ranked outlives bound on Self in a trait +// definition caused an ICE when debug_assertions were enabled. +// +// Made to pass as part of fixing #98095. +// +// check-pass + +trait A where + for<'a> Self: 'a, +{ +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-90177.rs b/tests/ui/higher-ranked/trait-bounds/issue-90177.rs new file mode 100644 index 000000000..b151a9d3a --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-90177.rs @@ -0,0 +1,32 @@ +// check-pass + +trait Base<'f> { + type Assoc; + + fn do_something(&self); +} + +trait ForAnyLifetime: for<'f> Base<'f> {} + +impl ForAnyLifetime for T where T: for<'f> Base<'f> {} + +trait CanBeDynamic: ForAnyLifetime + for<'f> Base<'f, Assoc = ()> {} + +fn foo(a: &dyn CanBeDynamic) { + a.do_something(); +} + +struct S; + +impl<'a> Base<'a> for S { + type Assoc = (); + + fn do_something(&self) {} +} + +impl CanBeDynamic for S {} + +fn main() { + let s = S; + foo(&s); +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-95034.rs b/tests/ui/higher-ranked/trait-bounds/issue-95034.rs new file mode 100644 index 000000000..af4946a18 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-95034.rs @@ -0,0 +1,80 @@ +// check-pass +// compile-flags: --edition=2021 --crate-type=lib + +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, + task::{Context, Poll}, +}; + +mod object { + use super::*; + + pub trait Object<'a> { + type Error; + type Future: Future; + fn create() -> Self::Future; + } + + impl<'a> Object<'a> for u8 { + type Error = (); + type Future = Pin>>; + fn create() -> Self::Future { + unimplemented!() + } + } + + impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) { + type Error = (); + type Future = CustomFut<'a, E, A>; + fn create() -> Self::Future { + unimplemented!() + } + } + + pub struct CustomFut<'f, E, A: Object<'f, Error = E>> { + ph: PhantomData<(A::Future,)>, + } + + impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> { + type Output = (A,); + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { + unimplemented!() + } + } +} + +mod async_fn { + use super::*; + + pub trait AsyncFn { + type Future: Future; + fn call(&self) -> Self::Future; + } + + impl AsyncFn for F + where + F: Fn() -> Fut, + Fut: Future, + { + type Future = Fut; + fn call(&self) -> Self::Future { + (self)() + } + } +} + +pub async fn test() { + use self::{async_fn::AsyncFn, object::Object}; + + async fn create>() { + T::create().await; + } + + async fn call_async_fn(inner: impl AsyncFn) { + inner.call().await; + } + + call_async_fn(create::<(u8,)>).await; +} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-95230.next.stderr b/tests/ui/higher-ranked/trait-bounds/issue-95230.next.stderr new file mode 100644 index 000000000..d4bc5b672 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-95230.next.stderr @@ -0,0 +1,19 @@ +error[E0275]: overflow evaluating the requirement `for<'a> &'a mut Bar well-formed` + --> $DIR/issue-95230.rs:9:13 + | +LL | for<'a> &'a mut Self:; + | ^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_95230`) +note: required by a bound in `Bar` + --> $DIR/issue-95230.rs:9:13 + | +LL | pub struct Bar + | --- required by a bound in this struct +LL | where +LL | for<'a> &'a mut Self:; + | ^^^^^^^^^^^^ required by this bound in `Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/higher-ranked/trait-bounds/issue-95230.rs b/tests/ui/higher-ranked/trait-bounds/issue-95230.rs new file mode 100644 index 000000000..49a1584d5 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/issue-95230.rs @@ -0,0 +1,11 @@ +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next +//[old] check-pass +//[next] known-bug: #109764 + + +pub struct Bar +where + for<'a> &'a mut Self:; + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-44005.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-44005.rs new file mode 100644 index 000000000..f255eac0c --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-44005.rs @@ -0,0 +1,31 @@ +// check-pass + +pub trait Foo<'a> { + type Bar; + fn foo(&'a self) -> Self::Bar; +} + +impl<'a, 'b, T: 'a> Foo<'a> for &'b T { + type Bar = &'a T; + fn foo(&'a self) -> &'a T { + self + } +} + +pub fn uncallable(x: T, f: F) +where + T: for<'a> Foo<'a>, + F: for<'a> Fn(>::Bar), +{ + f(x.foo()); +} + +pub fn catalyst(x: &i32) { + broken(x, |_| {}) +} + +pub fn broken(x: &i32, f: F) { + uncallable(x, |y| f(y)); +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-56556.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-56556.rs new file mode 100644 index 000000000..4d38cb19e --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-56556.rs @@ -0,0 +1,30 @@ +// check-pass + +fn foo(t: T) -> usize +where + for<'a> &'a T: IntoIterator, + for<'a> <&'a T as IntoIterator>::IntoIter: ExactSizeIterator, +{ + t.into_iter().len() +} + +fn main() { + foo::>(vec![]); +} + +mod another { + use std::ops::Deref; + + fn test() + where + T: Deref, + TDeref: ?Sized, + for<'a> &'a TDeref: IntoIterator, + for<'a> <&'a TDeref as IntoIterator>::IntoIter: Clone, + { + } + + fn main() { + test::, _>(); + } +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs new file mode 100644 index 000000000..c6f29fa59 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-1.rs @@ -0,0 +1,88 @@ +// check-pass + +// FamilyType (GAT workaround) +pub trait FamilyLt<'a> { + type Out; +} + +struct RefMutFamily(std::marker::PhantomData, ()); +impl<'a, T: 'a> FamilyLt<'a> for RefMutFamily { + type Out = &'a mut T; +} + +pub trait Execute { + type E: Inject; + fn execute(self, value: <::I as FamilyLt>::Out); +} + +pub trait Inject +where + Self: Sized, +{ + type I: for<'a> FamilyLt<'a>; + fn inject(_: &()) -> ::Out; +} + +impl Inject for RefMutFamily { + type I = Self; + fn inject(_: &()) -> ::Out { + unimplemented!() + } +} + +// This struct is only used to give a hint to the compiler about the type `Q` +struct Annotate(std::marker::PhantomData); +impl Annotate { + fn new() -> Self { + Self(std::marker::PhantomData) + } +} + +// This function annotate a closure so it can have Higher-Rank Lifetime Bounds +// +// See 'annotate' workaround: https://github.com/rust-lang/rust/issues/58052 +fn annotate(_q: Annotate, func: F) -> impl Execute + 'static +where + F: for<'r> FnOnce(<::I as FamilyLt<'r>>::Out) + 'static, + Q: Inject + 'static, +{ + let wrapper: Wrapper = Wrapper(std::marker::PhantomData, func); + wrapper +} + +struct Wrapper(std::marker::PhantomData, F); +impl Execute for Wrapper + where + Q: Inject, + F: for<'r> FnOnce(<::I as FamilyLt<'r>>::Out), +{ + type E = Q; + + fn execute(self, value: <::I as FamilyLt>::Out) { + (self.1)(value) + } +} + +struct Task { + _processor: Box, +} + +// This function consume the closure +fn task

(processor: P) -> Task +where P: Execute + 'static { + Task { + _processor: Box::new(move || { + let q = P::E::inject(&()); + processor.execute(q); + }) + } +} + +fn main() { + task(annotate( + Annotate::>::new(), + |value: &mut usize| { + *value = 2; + } + )); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-2.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-2.rs new file mode 100644 index 000000000..002054732 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-2.rs @@ -0,0 +1,33 @@ +// check-pass + +use std::marker::PhantomData; + +trait Lt<'a> { + type T; +} +struct Id(PhantomData); +impl<'a,T> Lt<'a> for Id { + type T = T; +} + +struct Ref(PhantomData) where T: ?Sized; +impl<'a,T> Lt<'a> for Ref +where T: 'a + Lt<'a> + ?Sized +{ + type T = &'a T; +} +struct Mut(PhantomData) where T: ?Sized; +impl<'a,T> Lt<'a> for Mut +where T: 'a + Lt<'a> + ?Sized +{ + type T = &'a mut T; +} + +struct C(for<'a> fn(>::T) -> O) where I: for<'a> Lt<'a>; + + +fn main() { + let c = C::,_>(|()| 3); + c.0(()); + +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.rs new file mode 100644 index 000000000..d84e30f49 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.rs @@ -0,0 +1,32 @@ +trait ATC<'a> { + type Type: Sized; +} + +trait WithDefault: for<'a> ATC<'a> { + fn with_default Fn(>::Type)>(f: F); +} + +fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(>::Type)>( + f: F, + x: >::Type, +) { + f(x); +} + +impl<'a> ATC<'a> for () { + type Type = Self; +} + +impl WithDefault for () { + fn with_default Fn(>::Type)>(f: F) { + // Errors with a bogus type mismatch. + //f(()); + // Going through another generic function works fine. + call(f, ()); + //~^ expected a + } +} + +fn main() { + // <()>::with_default(|_| {}); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.stderr new file mode 100644 index 000000000..b30dd36d2 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-3.stderr @@ -0,0 +1,19 @@ +error[E0277]: expected a `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` + --> $DIR/issue-62529-3.rs:25:14 + | +LL | call(f, ()); + | ---- ^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` + | | + | required by a bound introduced by this call + | + = note: expected a closure with arguments `((),)` + found a closure with arguments `(<_ as ATC<'a>>::Type,)` +note: required by a bound in `call` + --> $DIR/issue-62529-3.rs:9:36 + | +LL | fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(>::Type)>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-4.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-4.rs new file mode 100644 index 000000000..8c2a59868 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-4.rs @@ -0,0 +1,39 @@ +// check-pass + +use std::marker::PhantomData; +use std::mem; + +trait Container<'a> { + type Root: 'a; +} + +type RootOf<'a, T> = >::Root; + +struct Test<'a, T> where T: Container<'a> { + pub root: T::Root, + marker: PhantomData<&'a mut &'a mut ()>, +} + +impl<'a, 'b> Container<'b> for &'a str { + type Root = &'b str; +} + +impl<'a, T> Test<'a, T> where T: for<'b> Container<'b> { + fn new(root: RootOf<'a, T>) -> Test<'a, T> { + Test { + root: root, + marker: PhantomData + } + } + + fn with_mut(&mut self, f: F) -> R where + F: for<'b> FnOnce(&'b mut RootOf<'b, T>) -> R { + f(unsafe { mem::transmute(&mut self.root) }) + } +} + +fn main() { + let val = "root"; + let mut test: Test<&str> = Test::new(val); + test.with_mut(|_| { }); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-5.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-5.rs new file mode 100644 index 000000000..03f257a02 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-5.rs @@ -0,0 +1,27 @@ +// check-pass + +pub struct Struct {} + +pub trait Trait<'a> { + type Assoc; + + fn method() -> Self::Assoc; +} + +impl<'a> Trait<'a> for Struct { + type Assoc = (); + + fn method() -> Self::Assoc {} +} + +pub fn function(f: F) +where + F: for<'a> FnOnce(>::Assoc), + T: for<'b> Trait<'b>, +{ + f(T::method()); +} + +fn main() { + function::<_, Struct>(|_| {}); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs new file mode 100644 index 000000000..0ea736dee --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-62529-6.rs @@ -0,0 +1,77 @@ +// check-pass + +use std::cell::RefMut; + +fn main() { + StateMachine2::Init.resume(); +} + +enum StateMachine2<'a> { + Init, + #[allow(dead_code)] // match required for ICE + AfterTwoYields { + p: Backed<'a, *mut String>, + }, +} + +impl<'a> StateMachine2<'a> { + fn take(&self) -> Self { + StateMachine2::Init + } +} + +impl<'a> StateMachine2<'a> { + fn resume(&mut self) -> () { + use StateMachine2::*; + match self.take() { + AfterTwoYields { p } => { + p.with(|_| {}); + } + _ => panic!("Resume after completed."), + } + } +} + +unsafe trait Unpack<'a> { + type Unpacked: 'a; + + fn unpack(&self) -> Self::Unpacked { + unsafe { std::mem::transmute_copy(&self) } + } +} + +unsafe trait Pack { + type Packed; + + fn pack(&self) -> Self::Packed { + unsafe { std::mem::transmute_copy(&self) } + } +} + +unsafe impl<'a> Unpack<'a> for String { + type Unpacked = String; +} + +unsafe impl Pack for String { + type Packed = String; +} + +unsafe impl<'a> Unpack<'a> for *mut String { + type Unpacked = &'a mut String; +} + +unsafe impl<'a> Pack for &'a mut String { + type Packed = *mut String; +} + +struct Backed<'a, U>(RefMut<'a, Option>, U); + +impl<'a, 'b, U: Unpack<'b>> Backed<'a, U> { + fn with(self, f: F) -> Backed<'a, ()> + where + F: for<'f> FnOnce(>::Unpacked) -> (), + { + let result: () = f(self.1.unpack()); + Backed(self.0, result) + } +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-70120.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-70120.rs new file mode 100644 index 000000000..3ced40230 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-70120.rs @@ -0,0 +1,31 @@ +// check-pass + +pub trait MyTrait<'a> { + type Output: 'a; + fn gimme_value(&self) -> Self::Output; +} + +pub struct MyStruct; + +impl<'a> MyTrait<'a> for MyStruct { + type Output = &'a usize; + fn gimme_value(&self) -> Self::Output { + unimplemented!() + } +} + +fn meow(t: T, f: F) +where + T: for<'any> MyTrait<'any>, + F: for<'any2> Fn(>::Output), +{ + let v = t.gimme_value(); + f(v); +} + +fn main() { + let struc = MyStruct; + meow(struc, |foo| { + println!("{:?}", foo); + }) +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.migrate.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.migrate.stderr new file mode 100644 index 000000000..0f38f8e32 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.migrate.stderr @@ -0,0 +1,79 @@ +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:54:5 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>` + found type `for<'r> FnOnce<(&'r &str,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:54:24 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:34:9 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:54:5 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `FnOnce<(&&str,)>` + found type `for<'r> FnOnce<(&'r &str,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:54:24 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:34:44 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:58:5 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>` + found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:58:24 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:34:9 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:58:5 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `FnOnce<(&Wrapper<'_>,)>` + found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:58:24 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^^^^^^^^^^^^^^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:34:44 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.rs new file mode 100644 index 000000000..1d90226a3 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.rs @@ -0,0 +1,51 @@ +// check-fail +#![feature(rustc_attrs)] + +trait Parser<'s> { + type Output; + + fn call(&self, input: &'s str) -> (&'s str, Self::Output); +} + +impl<'s, F, T> Parser<'s> for F +where F: Fn(&'s str) -> (&'s str, T) { + type Output = T; + fn call(&self, input: &'s str) -> (&'s str, T) { + self(input) + } +} + +fn foo( + f1: F1, + base: &'static str, + f2: F2 +) +where + F1: for<'a> Parser<'a>, + F2: FnOnce(&::Output) -> bool +{ + let s: String = base.to_owned(); + let str_ref = s.as_ref(); + let (remaining, produced) = f1.call(str_ref); + assert!(f2(&produced)); + assert_eq!(remaining.len(), 0); +} + +struct Wrapper<'a>(&'a str); + +fn main() { + fn bar<'a>(s: &'a str) -> (&'a str, &'a str) { + (&s[..1], &s[..]) + } + + fn baz<'a>(s: &'a str) -> (&'a str, Wrapper<'a>) { + (&s[..1], Wrapper(&s[..])) + } + + foo(bar, "string", |s| s.len() == 5); + //~^ ERROR mismatched types + //~| ERROR mismatched types + foo(baz, "string", |s| s.0.len() == 5); + //~^ ERROR mismatched types + //~| ERROR mismatched types +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr new file mode 100644 index 000000000..4ef96cd95 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-71955.stderr @@ -0,0 +1,79 @@ +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:45:5 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a &'b str,)>` + found trait `for<'a> FnOnce<(&'a &str,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:45:24 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:25:9 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:45:5 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a &'b str,)>` + found trait `for<'a> FnOnce<(&'a &str,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:45:24 + | +LL | foo(bar, "string", |s| s.len() == 5); + | ^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:25:44 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:48:5 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a Wrapper<'b>,)>` + found trait `for<'a> FnOnce<(&'a Wrapper<'_>,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:48:24 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:25:9 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/issue-71955.rs:48:5 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> FnOnce<(&'a Wrapper<'b>,)>` + found trait `for<'a> FnOnce<(&'a Wrapper<'_>,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-71955.rs:48:24 + | +LL | foo(baz, "string", |s| s.0.len() == 5); + | ^^^ +note: the lifetime requirement is introduced here + --> $DIR/issue-71955.rs:25:44 + | +LL | F2: FnOnce(&::Output) -> bool + | ^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-74261.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-74261.rs new file mode 100644 index 000000000..93ccb4268 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-74261.rs @@ -0,0 +1,30 @@ +// check-pass + +use std::marker::PhantomData; + +trait A<'a> { + type B; + fn b(self) -> Self::B; +} + +struct T; +struct S<'a>(PhantomData<&'a ()>); + +impl<'a> A<'a> for T { + type B = S<'a>; + fn b(self) -> Self::B { + S(PhantomData) + } +} + +fn s(t: TT, f: F) +where + TT: for<'a> A<'a>, + F: for<'a> FnOnce(>::B) +{ + f(t.b()); +} + +fn main() { + s(T, |_| {}); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-76956.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-76956.rs new file mode 100644 index 000000000..583470080 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-76956.rs @@ -0,0 +1,15 @@ +// check-pass + +use std::ops::Deref; + +struct Data { + boxed: Box<&'static i32> +} + +impl Data { + fn use_data(&self, user: impl for <'a> FnOnce( as Deref>::Target)) { + user(*self.boxed) + } +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80706.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80706.rs new file mode 100644 index 000000000..00a866f22 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80706.rs @@ -0,0 +1,71 @@ +// build-pass +// edition:2018 + +type BoxFuture = std::pin::Pin>>; + +fn main() { + f(); +} + +async fn f() { + run("dependency").await; +} + +struct InMemoryStorage; + +struct User<'dep> { + dep: &'dep str, +} + +impl<'a> StorageRequest for SaveUser<'a> { + fn execute(&self) -> BoxFuture> { + todo!() + } +} + +trait Storage { + type Error; +} + +impl Storage for InMemoryStorage { + type Error = String; +} + +trait StorageRequestReturnType { + type Output; +} + +trait StorageRequest: StorageRequestReturnType { + fn execute( + &self, + ) -> BoxFuture::Output, ::Error>>; +} + +struct SaveUser<'a> { + name: &'a str, +} + +impl<'a> StorageRequestReturnType for SaveUser<'a> { + type Output = (); +} + +impl<'dep> User<'dep> { + async fn save(self) + where + S: Storage, + for<'a> SaveUser<'a>: StorageRequest, + { + SaveUser { name: "Joe" } + .execute() + .await; + } +} + +async fn run(dep: &str) +where + S: Storage, + for<'a> SaveUser<'a>: StorageRequest, + for<'a> SaveUser<'a>: StorageRequestReturnType, +{ + User { dep }.save().await; +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80956.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80956.rs new file mode 100644 index 000000000..6316ceea1 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-80956.rs @@ -0,0 +1,21 @@ +// check-pass + +trait Bar { + type Type; +} +struct Foo<'a>(&'a ()); +impl<'a> Bar for Foo<'a> { + type Type = (); +} + +fn func<'a>(_: as Bar>::Type) {} +fn assert_is_func(_: fn(A)) {} + +fn test() +where + for<'a> as Bar>::Type: Sized, +{ + assert_is_func(func); +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-81809.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-81809.rs new file mode 100644 index 000000000..f6ab9c203 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-81809.rs @@ -0,0 +1,21 @@ +// check-pass + +pub trait Indexable { + type Idx; +} +impl Indexable for u8 { + type Idx = u8; +} +impl Indexable for u16 { + type Idx = u16; +} + +pub trait Indexer: std::ops::Index {} + +trait StoreIndex: Indexer + Indexer {} + +fn foo(st: &impl StoreIndex) -> &dyn StoreIndex { + st as &dyn StoreIndex +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.rs new file mode 100644 index 000000000..8aa29926d --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.rs @@ -0,0 +1,19 @@ +#![feature(unboxed_closures)] + +trait SomeTrait<'a> { + type Associated; +} + +fn give_me_ice() { + callee:: >::Associated>(); + //~^ ERROR the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied [E0277] + //~| ERROR the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied [E0277] +} + +fn callee>() { + println!("{}", std::any::type_name::<>::Output>()); +} + +fn main() { + give_me_ice::<()>(); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.stderr new file mode 100644 index 000000000..3240518fb --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-85455.stderr @@ -0,0 +1,25 @@ +error[E0277]: the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied + --> $DIR/issue-85455.rs:8:14 + | +LL | callee:: >::Associated>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> SomeTrait<'a>` is not implemented for `T` + | +help: consider restricting type parameter `T` + | +LL | fn give_me_ice SomeTrait<'a>>() { + | +++++++++++++++++++++++ + +error[E0277]: the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied + --> $DIR/issue-85455.rs:8:5 + | +LL | callee:: >::Associated>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> SomeTrait<'a>` is not implemented for `T` + | +help: consider restricting type parameter `T` + | +LL | fn give_me_ice SomeTrait<'a>>() { + | +++++++++++++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.rs new file mode 100644 index 000000000..fffb54f86 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.rs @@ -0,0 +1,32 @@ +trait BufferMut {} +struct Ctx(D); + +trait BufferUdpStateContext {} +impl BufferUdpStateContext for C {} + +trait StackContext +where + Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, +{ + type Dispatcher; +} + +trait TimerContext { + type Handler; +} +impl TimerContext for C +where + C: StackContext, + //~^ ERROR: is not satisfied [E0277] +{ + type Handler = Ctx; + //~^ ERROR: is not satisfied [E0277] +} + +struct EthernetWorker(C) +where + Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; +impl EthernetWorker {} +//~^ ERROR: is not satisfied [E0277] + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr new file mode 100644 index 000000000..edef6ccd3 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr @@ -0,0 +1,69 @@ +error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied + --> $DIR/issue-89118.rs:19:8 + | +LL | C: StackContext, + | ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` + | +note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` + --> $DIR/issue-89118.rs:5:23 + | +LL | impl BufferUdpStateContext for C {} + | --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `StackContext` + --> $DIR/issue-89118.rs:9:14 + | +LL | trait StackContext + | ------------ required by a bound in this trait +LL | where +LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` + +error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied + --> $DIR/issue-89118.rs:29:9 + | +LL | impl EthernetWorker {} + | ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` + | +note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` + --> $DIR/issue-89118.rs:5:23 + | +LL | impl BufferUdpStateContext for C {} + | --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `EthernetWorker` + --> $DIR/issue-89118.rs:28:14 + | +LL | struct EthernetWorker(C) + | -------------- required by a bound in this struct +LL | where +LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` + +error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied + --> $DIR/issue-89118.rs:22:20 + | +LL | type Handler = Ctx; + | ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` + | +note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` + --> $DIR/issue-89118.rs:5:23 + | +LL | impl BufferUdpStateContext for C {} + | --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `StackContext` + --> $DIR/issue-89118.rs:9:14 + | +LL | trait StackContext + | ------------ required by a bound in this trait +LL | where +LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs new file mode 100644 index 000000000..f7e467b37 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89436.rs @@ -0,0 +1,44 @@ +// check-pass + +#![allow(unused)] + +trait MiniYokeable<'a> { + type Output; +} + +struct MiniYoke MiniYokeable<'a>> { + pub yokeable: Y, +} + +fn map_project_broken( + source: MiniYoke, + f: impl for<'a> FnOnce( + >::Output, + core::marker::PhantomData<&'a ()>, + ) ->

>::Output, +) -> MiniYoke

+where + Y: for<'a> MiniYokeable<'a>, + P: for<'a> MiniYokeable<'a> +{ + unimplemented!() +} + +struct Bar<'a> { + string_1: &'a str, + string_2: &'a str, +} + +impl<'a> MiniYokeable<'a> for Bar<'static> { + type Output = Bar<'a>; +} + +impl<'a> MiniYokeable<'a> for &'static str { + type Output = &'a str; +} + +fn demo_broken(bar: MiniYoke>) -> MiniYoke<&'static str> { + map_project_broken(bar, |bar, _| bar.string_1) +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90612.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90612.rs new file mode 100644 index 000000000..effc32945 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90612.rs @@ -0,0 +1,41 @@ +// check-pass + +use std::marker::PhantomData; + +trait Family: Sized { + type Item<'a>; + + fn apply_all(&self, f: F) + where + F: FamilyItemFn { } +} + +struct Array(PhantomData); + +impl Family for Array { + type Item<'a> = &'a T; +} + +trait FamilyItemFn { + fn apply(&self, item: T::Item<'_>); +} + +impl FamilyItemFn for F +where + T: Family, + for<'a> F: Fn(T::Item<'a>) +{ + fn apply(&self, item: T::Item<'_>) { + (*self)(item); + } +} + +fn process(array: Array) { + // Works + array.apply_all(|x: &T| { }); + + // ICE: NoSolution + array.apply_all(|x: as Family>::Item<'_>| { }); +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs new file mode 100644 index 000000000..628b5cba1 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90638.rs @@ -0,0 +1,35 @@ +//check-pass + +trait Yokeable<'a>: 'static { + type Output: 'a; +} + +trait IsCovariant<'a> {} + +struct Yoke Yokeable<'a>> { + data: Y, +} + +impl Yokeable<'a>> Yoke { + fn project Yokeable<'a>>(&self, _f: for<'a> fn(>::Output, &'a ()) + -> >::Output) -> Yoke { + + unimplemented!() + } +} + +fn _upcast(x: Yoke) -> Yoke + 'static>> where + Y: for<'a> Yokeable<'a>, + for<'a> >::Output: IsCovariant<'a> + { + x.project(|data, _| { + Box::new(data) + }) +} + + +impl<'a> Yokeable<'a> for Box + 'static> { + type Output = Box + 'a>; +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90875.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90875.rs new file mode 100644 index 000000000..ffd6857d8 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90875.rs @@ -0,0 +1,31 @@ +// check-pass + +trait Variable<'a> { + type Type; +} + +impl Variable<'_> for () { + type Type = (); +} + +fn check(_: F) +where + F: Fn(T), // <- if removed, all fn_* then require type annotations + F: for<'a> Fn(>::Type), + T: for<'a> Variable<'a>, +{ +} + +fn test(arg: impl Fn(())) { + fn fn_1(_: ()) {} + let fn_2 = |_: ()| (); + let fn_3 = |a| fn_1(a); + let fn_4 = arg; + + check(fn_1); // Error + check(fn_2); // Ok + check(fn_3); // Ok + check(fn_4); // Error +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.rs new file mode 100644 index 000000000..ab9d9a7ce --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.rs @@ -0,0 +1,53 @@ +// check-fail +// known-bug: #90950 + +trait Yokeable<'a>: 'static { + type Output: 'a; +} + + +trait IsCovariant<'a> {} + +struct Yoke Yokeable<'a>> { + data: Y, +} + + +// impl Yokeable<'a>> Yoke { +// fn project Yokeable<'a>>( +// &self, +// f: for<'a> fn(>::Output, &'a (), +// ) -> >::Output) -> Yoke { +// unimplemented!() +// } +// } + +fn upcast(x: Yoke) -> Yoke + 'static>> where + Y: for<'a> Yokeable<'a>, + for<'a> >::Output: IsCovariant<'a> + { + // x.project(|data, _| { + // Box::new(data) + // }) + unimplemented!() +} + + +impl<'a> Yokeable<'a> for Box + 'static> { + type Output = Box + 'a>; +} + +// this impl is mostly an example and unnecessary for the pure repro +use std::borrow::*; +impl<'a, T: ToOwned + ?Sized> Yokeable<'a> for Cow<'static, T> { + type Output = Cow<'a, T>; +} +impl<'a, T: ToOwned + ?Sized> IsCovariant<'a> for Cow<'a, T> {} + + + +fn upcast_yoke(y: Yoke>) -> Yoke + 'static>> { + upcast(y) +} + +fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.stderr new file mode 100644 index 000000000..5be33bccd --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-90950.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `for<'a> <_ as Yokeable<'a>>::Output: IsCovariant<'a>` is not satisfied + --> $DIR/issue-90950.rs:50:12 + | +LL | upcast(y) + | ------ ^ the trait `for<'a> IsCovariant<'a>` is not implemented for `<_ as Yokeable<'a>>::Output` + | | + | required by a bound introduced by this call + | + = help: the trait `IsCovariant<'a>` is implemented for `std::borrow::Cow<'a, T>` +note: required by a bound in `upcast` + --> $DIR/issue-90950.rs:27:42 + | +LL | fn upcast(x: Yoke) -> Yoke + 'static>> where + | ------ required by a bound in this function +LL | Y: for<'a> Yokeable<'a>, +LL | for<'a> >::Output: IsCovariant<'a> + | ^^^^^^^^^^^^^^^ required by this bound in `upcast` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.rs b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.rs new file mode 100644 index 000000000..7693b1182 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.rs @@ -0,0 +1,23 @@ +// check-fail +// known-bug: #89196 + +// Should pass, but we normalize and check bounds before we resolve the generics +// of the function (which we know because of the return type). + +trait Trait<'a> { + type Out; +} + +impl<'a, T> Trait<'a> for T { + type Out = T; +} + +fn weird_bound() -> X + where + for<'a> X: Trait<'a>, + for<'a> >::Out: Copy +{ todo!() } + +fn main() { + let _: () = weird_bound(); +} diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr new file mode 100644 index 000000000..73388a725 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `for<'a> <_ as Trait<'a>>::Out: Copy` is not satisfied + --> $DIR/norm-before-method-resolution.rs:22:17 + | +LL | let _: () = weird_bound(); + | ^^^^^^^^^^^ the trait `for<'a> Copy` is not implemented for `<_ as Trait<'a>>::Out` + | +note: required by a bound in `weird_bound` + --> $DIR/norm-before-method-resolution.rs:18:40 + | +LL | fn weird_bound() -> X + | ----------- required by a bound in this function +... +LL | for<'a> >::Out: Copy + | ^^^^ required by this bound in `weird_bound` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/tests/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr deleted file mode 100644 index b7264c7e9..000000000 --- a/tests/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:54:13 - | -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other -... -LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, -LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) } - | |_____________________________________________- in this macro invocation - | - = note: expected enum `Option fn(&'a u32, &'b u32) -> &'a u32>` - found enum `Option fn(&'a u32, &'a u32) -> &'a u32>` - = note: this error originates in the macro `check` (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/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr b/tests/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr deleted file mode 100644 index 2355979b0..000000000 --- a/tests/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:54:13 - | -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other -... -LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), -LL | | fn(&'x u32)) } - | |______________- in this macro invocation - | - = note: expected enum `Option fn(&'a u32)>` - found enum `Option` - = note: this error originates in the macro `check` (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/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr b/tests/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr deleted file mode 100644 index a73c03feb..000000000 --- a/tests/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:54:13 - | -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other -... -LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), -LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } - | |__________________________________- in this macro invocation - | - = note: expected enum `Option fn(Inv<'a>, Inv<'b>)>` - found enum `Option fn(Inv<'a>, Inv<'a>)>` - = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0308]: mismatched types - --> $DIR/hr-subtype.rs:54:13 - | -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other -... -LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), -LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } - | |__________________________________- in this macro invocation - | - = note: expected enum `Option fn(Inv<'a>, Inv<'b>)>` - found enum `Option fn(Inv<'a>, Inv<'a>)>` - = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr b/tests/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr deleted file mode 100644 index 31d36d716..000000000 --- a/tests/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:48:13 - | -LL | fn subtype<'x, 'y: 'x, 'z: 'y>() { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | gimme::<$t2>(None::<$t1>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` -... -LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), -LL | | fn(Inv<'y>)) } - | |______________- in this macro invocation - | - = help: consider adding the following bound: `'x: 'y` - = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant - = note: the struct `Inv<'a>` is invariant over the parameter `'a` - = help: see for more information about variance - = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:54:13 - | -LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` -... -LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), -LL | | fn(Inv<'y>)) } - | |______________- in this macro invocation - | - = help: consider adding the following bound: `'x: 'y` - = note: requirement occurs because of the type `Inv<'_>`, which makes the generic argument `'_` invariant - = note: the struct `Inv<'a>` is invariant over the parameter `'a` - = help: see for more information about variance - = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 2 previous errors - diff --git a/tests/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr b/tests/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr deleted file mode 100644 index 269cde54c..000000000 --- a/tests/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/hr-subtype.rs:54:13 - | -LL | fn supertype<'x, 'y: 'x, 'z: 'y>() { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` -... -LL | / check! { free_x_vs_free_y: (fn(&'x u32), -LL | | fn(&'y u32)) } - | |______________- in this macro invocation - | - = help: consider adding the following bound: `'x: 'y` - = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - diff --git a/tests/ui/hr-subtype/hr-subtype.rs b/tests/ui/hr-subtype/hr-subtype.rs deleted file mode 100644 index c770e0de8..000000000 --- a/tests/ui/hr-subtype/hr-subtype.rs +++ /dev/null @@ -1,111 +0,0 @@ -// Targeted tests for the higher-ranked subtyping code. - -#![allow(dead_code)] - -// revisions: bound_a_vs_bound_a -// revisions: bound_a_vs_bound_b -// revisions: bound_inv_a_vs_bound_inv_b -// revisions: bound_co_a_vs_bound_co_b -// revisions: bound_a_vs_free_x -// revisions: free_x_vs_free_x -// revisions: free_x_vs_free_y -// revisions: free_inv_x_vs_free_inv_y -// revisions: bound_a_b_vs_bound_a -// revisions: bound_co_a_b_vs_bound_co_a -// revisions: bound_contra_a_contra_b_ret_co_a -// revisions: bound_co_a_co_b_ret_contra_a -// revisions: bound_inv_a_b_vs_bound_inv_a -// revisions: bound_a_b_ret_a_vs_bound_a_ret_a - -//[bound_a_vs_bound_a] check-pass -//[bound_a_vs_bound_b] check-pass -//[bound_inv_a_vs_bound_inv_b] check-pass -//[bound_co_a_vs_bound_co_b] check-pass -//[free_x_vs_free_x] check-pass -//[bound_co_a_b_vs_bound_co_a] check-pass -//[bound_co_a_co_b_ret_contra_a] check-pass -//[bound_a_b_vs_bound_a] check-pass -//[bound_contra_a_contra_b_ret_co_a] check-pass - -fn gimme(_: Option) {} - -struct Inv<'a> { - x: *mut &'a u32, -} - -struct Co<'a> { - x: fn(&'a u32), -} - -struct Contra<'a> { - x: &'a u32, -} - -macro_rules! check { - ($rev:ident: ($t1:ty, $t2:ty)) => { - #[cfg($rev)] - fn subtype<'x, 'y: 'x, 'z: 'y>() { - gimme::<$t2>(None::<$t1>); - //[free_inv_x_vs_free_inv_y]~^ ERROR - } - - #[cfg($rev)] - fn supertype<'x, 'y: 'x, 'z: 'y>() { - gimme::<$t1>(None::<$t2>); - //[bound_a_vs_free_x]~^ ERROR - //[free_x_vs_free_y]~^^ ERROR - //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR - //[bound_inv_a_b_vs_bound_inv_a]~| ERROR - //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^^ ERROR - //[free_inv_x_vs_free_inv_y]~^^^^^^ ERROR - } - }; -} - -// If both have bound regions, they are equivalent, regardless of -// variant. -check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32), -for<'a> fn(&'a u32)) } -check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32), -for<'b> fn(&'b u32)) } -check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>), -for<'b> fn(Inv<'b>)) } -check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>), -for<'b> fn(Co<'b>)) } - -// Bound is a subtype of free. -check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), -fn(&'x u32)) } - -// Two free regions are relatable if subtyping holds. -check! { free_x_vs_free_x: (fn(&'x u32), -fn(&'x u32)) } -check! { free_x_vs_free_y: (fn(&'x u32), -fn(&'y u32)) } -check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), -fn(Inv<'y>)) } - -// Somewhat surprisingly, a fn taking two distinct bound lifetimes and -// a fn taking one bound lifetime can be interchangeable, but only if -// we are co- or contra-variant with respect to both lifetimes. -// -// The reason is: -// - if we are covariant, then 'a and 'b can be set to the call-site -// intersection; -// - if we are contravariant, then 'a can be inferred to 'static. -check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), -for<'a> fn(&'a u32, &'a u32)) } -check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), -for<'a> fn(Co<'a>, Co<'a>)) } -check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, -for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } -check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, -for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } - -// If we make those lifetimes invariant, then the two types are not interchangeable. -check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), -for<'a> fn(Inv<'a>, Inv<'a>)) } -check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, -for<'a> fn(&'a u32, &'a u32) -> &'a u32) } - -fn main() {} diff --git a/tests/ui/hr-subtype/placeholder-pattern-fail.rs b/tests/ui/hr-subtype/placeholder-pattern-fail.rs deleted file mode 100644 index bd4533e04..000000000 --- a/tests/ui/hr-subtype/placeholder-pattern-fail.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Check that incorrect higher ranked subtyping -// causes an error. -struct Inv<'a>(fn(&'a ()) -> &'a ()); -fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) { - // ok - let _: for<'a> fn(Inv<'a>, Inv<'a>) = f; - let sub: for<'a> fn(Inv<'a>, Inv<'a>) = f; - // no - let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; - //~^ ERROR mismatched types -} - -fn simple1<'c>(x: (&'c i32,)) { - let _x: (&'static i32,) = x; -} - -fn simple2<'c>(x: (&'c i32,)) { - let _: (&'static i32,) = x; -} - -fn main() { - hr_subtype(|_, _| {}); - simple1((&3,)); - simple2((&3,)); -} diff --git a/tests/ui/hr-subtype/placeholder-pattern-fail.stderr b/tests/ui/hr-subtype/placeholder-pattern-fail.stderr deleted file mode 100644 index 73b0a3173..000000000 --- a/tests/ui/hr-subtype/placeholder-pattern-fail.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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 - | - = note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)` - found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/hr-subtype/placeholder-pattern.rs b/tests/ui/hr-subtype/placeholder-pattern.rs deleted file mode 100644 index 061e66e54..000000000 --- a/tests/ui/hr-subtype/placeholder-pattern.rs +++ /dev/null @@ -1,18 +0,0 @@ -// check-pass -// Check that higher ranked subtyping correctly works when using -// placeholder patterns. -fn hr_subtype<'c>(f: for<'a, 'b> fn(&'a (), &'b ())) { - let _: for<'a> fn(&'a (), &'a ()) = f; - let _: for<'a, 'b> fn(&'a (), &'b ()) = f; - let _: for<'a> fn(&'a (), &'c ()) = f; - let _: fn(&'c (), &'c ()) = f; -} - -fn simple<'c>(x: (&'static i32,)) { - let _: (&'c i32,) = x; -} - -fn main() { - hr_subtype(|_, _| {}); - simple((&3,)); -} diff --git a/tests/ui/hr-subtype/return-static.rs b/tests/ui/hr-subtype/return-static.rs deleted file mode 100644 index 6455854f3..000000000 --- a/tests/ui/hr-subtype/return-static.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass - -fn make() -> T { - panic!() -} - -fn take(x: T) {} - -fn main() { - let x: for<'a> fn(&'a u32) -> _ = make(); - let y: &'static u32 = x(&22); - take:: fn(&'b u32) -> &'b u32>(x); -} diff --git a/tests/ui/hygiene/no_implicit_prelude-2018.stderr b/tests/ui/hygiene/no_implicit_prelude-2018.stderr index 3f31b041b..b22f3e75b 100644 --- a/tests/ui/hygiene/no_implicit_prelude-2018.stderr +++ b/tests/ui/hygiene/no_implicit_prelude-2018.stderr @@ -4,8 +4,10 @@ error: cannot find macro `print` in this scope LL | print!(); | ^^^^^ | - = help: consider importing this macro: - std::print +help: consider importing this macro + | +LL + use std::print; + | error: aborting due to previous error diff --git a/tests/ui/impl-trait/auto-trait-leak.rs b/tests/ui/impl-trait/auto-trait-leak.rs index c2fbbf94f..d71c09879 100644 --- a/tests/ui/impl-trait/auto-trait-leak.rs +++ b/tests/ui/impl-trait/auto-trait-leak.rs @@ -3,21 +3,23 @@ use std::rc::Rc; fn send(_: T) {} -fn main() { -} +fn main() {} // Cycles should work as the deferred obligations are // independently resolved and only require the concrete // return type, which can't depend on the obligation. fn cycle1() -> impl Clone { //~^ ERROR cycle detected + //~| ERROR cycle detected send(cycle2().clone()); + //~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits Rc::new(Cell::new(5)) } fn cycle2() -> impl Clone { send(cycle1().clone()); + //~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits Rc::new(String::from("foo")) } diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr index aa4ee75bb..92a9763bc 100644 --- a/tests/ui/impl-trait/auto-trait-leak.stderr +++ b/tests/ui/impl-trait/auto-trait-leak.stderr @@ -1,44 +1,9 @@ error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}` - --> $DIR/auto-trait-leak.rs:12:16 + --> $DIR/auto-trait-leak.rs:11:16 | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^ | -note: ...which requires borrow-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires preparing `cycle1` for borrow checking... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires unsafety-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires match-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building THIR for `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires type-checking `cycle1`... --> $DIR/auto-trait-leak.rs:14:5 | @@ -46,51 +11,51 @@ LL | send(cycle2().clone()); | ^^^^ = note: ...which requires evaluating trait selection obligation `cycle2::{opaque#0}: core::marker::Send`... note: ...which requires computing type of `cycle2::{opaque#0}`... - --> $DIR/auto-trait-leak.rs:19:16 + --> $DIR/auto-trait-leak.rs:20:16 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^ -note: ...which requires borrow-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:19:1 +note: ...which requires type-checking `cycle2`... + --> $DIR/auto-trait-leak.rs:21:5 | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires promoting constants in MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:19:1 +LL | send(cycle1().clone()); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `cycle1::{opaque#0}: core::marker::Send`... + = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/auto-trait-leak.rs:1:1 | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires preparing `cycle2` for borrow checking... - --> $DIR/auto-trait-leak.rs:19:1 +LL | / use std::cell::Cell; +LL | | use std::rc::Rc; +LL | | +LL | | fn send(_: T) {} +... | +LL | | Rc::new(String::from("foo")) +LL | | } + | |_^ + +error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}` + --> $DIR/auto-trait-leak.rs:11:16 | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires unsafety-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:19:1 +LL | fn cycle1() -> impl Clone { + | ^^^^^^^^^^ | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:19:1 +note: ...which requires type-checking `cycle1`... + --> $DIR/auto-trait-leak.rs:14:5 | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires match-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:19:1 +LL | send(cycle2().clone()); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `cycle2::{opaque#0}: core::marker::Send`... +note: ...which requires computing type of `cycle2::{opaque#0}`... + --> $DIR/auto-trait-leak.rs:20:16 | LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building THIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:19:1 + | ^^^^^^^^^^ +note: ...which requires type-checking `cycle2`... + --> $DIR/auto-trait-leak.rs:20:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires type-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:5 - | -LL | send(cycle1().clone()); - | ^^^^ - = note: ...which requires evaluating trait selection obligation `cycle1::{opaque#0}: core::marker::Send`... = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle note: cycle used when checking item types in top-level module --> $DIR/auto-trait-leak.rs:1:1 @@ -104,6 +69,54 @@ LL | | Rc::new(String::from("foo")) LL | | } | |_^ -error: aborting due to previous error +error: cannot check whether the hidden type of opaque type satisfies auto traits + --> $DIR/auto-trait-leak.rs:21:10 + | +LL | send(cycle1().clone()); + | ---- ^^^^^^^^^^^^^^^^ + | | + | required by a bound introduced by this call + | +note: opaque type is declared here + --> $DIR/auto-trait-leak.rs:11:16 + | +LL | fn cycle1() -> impl Clone { + | ^^^^^^^^^^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/auto-trait-leak.rs:20:4 + | +LL | fn cycle2() -> impl Clone { + | ^^^^^^ +note: required by a bound in `send` + --> $DIR/auto-trait-leak.rs:4:12 + | +LL | fn send(_: T) {} + | ^^^^ required by this bound in `send` + +error: cannot check whether the hidden type of opaque type satisfies auto traits + --> $DIR/auto-trait-leak.rs:14:10 + | +LL | send(cycle2().clone()); + | ---- ^^^^^^^^^^^^^^^^ + | | + | required by a bound introduced by this call + | +note: opaque type is declared here + --> $DIR/auto-trait-leak.rs:20:16 + | +LL | fn cycle2() -> impl Clone { + | ^^^^^^^^^^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/auto-trait-leak.rs:11:4 + | +LL | fn cycle1() -> impl Clone { + | ^^^^^^ +note: required by a bound in `send` + --> $DIR/auto-trait-leak.rs:4:12 + | +LL | fn send(_: T) {} + | ^^^^ required by this bound in `send` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/impl-trait/autoderef.rs b/tests/ui/impl-trait/autoderef.rs index 5e4f49954..0d07a5496 100644 --- a/tests/ui/impl-trait/autoderef.rs +++ b/tests/ui/impl-trait/autoderef.rs @@ -1,3 +1,5 @@ +// revisions: current next +//[next] compile-flag: -Ztrait-solver=next // check-pass use std::path::Path; diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr b/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr new file mode 100644 index 000000000..61fed1629 --- /dev/null +++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Into` for type `Foo` + --> $DIR/coherence-treats-tait-ambig.rs:10:1 + | +LL | impl Into for Foo { + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl Into for T + where U: From; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr b/tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr new file mode 100644 index 000000000..61fed1629 --- /dev/null +++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.next.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Into` for type `Foo` + --> $DIR/coherence-treats-tait-ambig.rs:10:1 + | +LL | impl Into for Foo { + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl Into for T + where U: From; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.rs b/tests/ui/impl-trait/coherence-treats-tait-ambig.rs new file mode 100644 index 000000000..156a7eb0e --- /dev/null +++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.rs @@ -0,0 +1,19 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +#![feature(type_alias_impl_trait)] + +type T = impl Sized; + +struct Foo; + +impl Into for Foo { +//~^ ERROR conflicting implementations of trait `Into` for type `Foo` + fn into(self) -> T { + Foo + } +} + +fn main() { + let _: T = Foo.into(); +} diff --git a/tests/ui/impl-trait/deduce-signature-from-supertrait.rs b/tests/ui/impl-trait/deduce-signature-from-supertrait.rs index d2c347920..7a51aac44 100644 --- a/tests/ui/impl-trait/deduce-signature-from-supertrait.rs +++ b/tests/ui/impl-trait/deduce-signature-from-supertrait.rs @@ -8,8 +8,10 @@ impl SuperExpectation for T {} type Foo = impl SuperExpectation; -fn main() { +fn bop(_: Foo) { let _: Foo = |x| { let _ = x.to_string(); }; } + +fn main() {} diff --git a/tests/ui/impl-trait/defined-by-trait-resolution.rs b/tests/ui/impl-trait/defined-by-trait-resolution.rs new file mode 100644 index 000000000..1744046dd --- /dev/null +++ b/tests/ui/impl-trait/defined-by-trait-resolution.rs @@ -0,0 +1,12 @@ +//! The trait query `foo: Fn() -> u8` is a valid defining use of RPIT. + +// build-pass + +fn returns_u8(_: impl Fn() -> u8) {} + +pub fn foo() -> impl Sized { + returns_u8(foo); + 0u8 +} + +fn main() {} diff --git a/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs new file mode 100644 index 000000000..befd768b1 --- /dev/null +++ b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs @@ -0,0 +1,9 @@ +fn test() -> impl std::fmt::Debug { + if true { + "boo2" + } else { + //~^ ERROR `if` and `else` have incompatible types + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr new file mode 100644 index 000000000..9b63911da --- /dev/null +++ b/tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr @@ -0,0 +1,16 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/dont-suggest-box-on-empty-else-arm.rs:4:12 + | +LL | if true { + | ------- `if` and `else` have incompatible types +LL | "boo2" + | ------ expected because of this +LL | } else { + | ____________^ +LL | | +LL | | } + | |_____^ expected `&str`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/equality.stderr b/tests/ui/impl-trait/equality.stderr index 69f4cbbbf..9b8bff215 100644 --- a/tests/ui/impl-trait/equality.stderr +++ b/tests/ui/impl-trait/equality.stderr @@ -30,10 +30,10 @@ LL | n + sum_to(n - 1) | = help: the trait `Add` is not implemented for `u32` = help: the following other types implement trait `Add`: + + > <&'a u32 as Add> <&u32 as Add<&u32>> - > - error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr index 1097cd0f4..8e61a65ab 100644 --- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -40,10 +40,10 @@ LL | fn method() -> Self::Ty; = note: expected signature `fn() -> <() as compare_method::Trait>::Ty` found signature `fn()` note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/in-assoc-type-unconstrained.rs:22:9 + --> $DIR/in-assoc-type-unconstrained.rs:22:12 | LL | fn method() -> () {} - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^ error: unconstrained opaque type --> $DIR/in-assoc-type-unconstrained.rs:20:19 diff --git a/tests/ui/impl-trait/in-assoc-type.rs b/tests/ui/impl-trait/in-assoc-type.rs index 36c54bdd6..38ad2fa6f 100644 --- a/tests/ui/impl-trait/in-assoc-type.rs +++ b/tests/ui/impl-trait/in-assoc-type.rs @@ -1,3 +1,6 @@ +//! This test checks that we don't allow registering hidden types for +//! opaque types from other impls. + #![feature(impl_trait_in_assoc_type)] trait Foo { diff --git a/tests/ui/impl-trait/in-assoc-type.stderr b/tests/ui/impl-trait/in-assoc-type.stderr index f0a272dc2..af60da07c 100644 --- a/tests/ui/impl-trait/in-assoc-type.stderr +++ b/tests/ui/impl-trait/in-assoc-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/in-assoc-type.rs:17:22 + --> $DIR/in-assoc-type.rs:20:22 | LL | type Bar = impl std::fmt::Debug; | -------------------- the expected opaque type @@ -12,10 +12,10 @@ LL | fn foo(&self) -> >::Bar {} = note: expected opaque type `<() as Foo<()>>::Bar` found unit type `()` note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/in-assoc-type.rs:17:5 + --> $DIR/in-assoc-type.rs:20:8 | LL | fn foo(&self) -> >::Bar {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to previous error diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs index 98417b343..b0fbe3a3d 100644 --- a/tests/ui/impl-trait/in-trait/foreign.rs +++ b/tests/ui/impl-trait/in-trait/foreign.rs @@ -14,6 +14,10 @@ impl Foo for Local { fn bar(self) -> Arc { Arc::new(String::new()) } } +fn generic(f: impl Foo) { + let x = &*f.bar(); +} + fn main() { // Witness an RPITIT from another crate. let &() = Foreign.bar(); diff --git a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr index 7aa7880e2..94893c9e7 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr @@ -6,11 +6,7 @@ LL | MyTrait::foo(&self) | | | required by a bound introduced by this call | -help: consider removing the leading `&`-reference - | -LL - MyTrait::foo(&self) -LL + MyTrait::foo(self) - | + = 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 diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr new file mode 100644 index 000000000..239c4b35c --- /dev/null +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr @@ -0,0 +1,21 @@ +error[E0053]: method `early` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:58:27 + | +LL | fn early<'late, T>(_: &'late ()) {} + | - ^^^^^^^^^ + | | | + | | expected type parameter `T`, found `()` + | | help: change the parameter type to match the trait: `&T` + | this type parameter + | +note: type in trait + --> $DIR/method-signature-matches.rs:53:28 + | +LL | fn early<'early, T>(x: &'early T) -> impl Sized; + | ^^^^^^^^^ + = note: expected signature `fn(&T)` + found signature `fn(&'late ())` + +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/method-signature-matches.mismatch.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr new file mode 100644 index 000000000..d3183b92e --- /dev/null +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr @@ -0,0 +1,20 @@ +error[E0053]: method `owo` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:14:15 + | +LL | fn owo(_: u8) {} + | ^^ + | | + | expected `()`, found `u8` + | help: change the parameter type to match the trait: `()` + | +note: type in trait + --> $DIR/method-signature-matches.rs:9:15 + | +LL | fn owo(x: ()) -> impl Sized; + | ^^ + = note: expected signature `fn(())` + found signature `fn(u8)` + +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/method-signature-matches.mismatch_async.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr new file mode 100644 index 000000000..80fda1c9f --- /dev/null +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr @@ -0,0 +1,20 @@ +error[E0053]: method `owo` has an incompatible type for trait + --> $DIR/method-signature-matches.rs:25:21 + | +LL | async fn owo(_: u8) {} + | ^^ + | | + | expected `()`, found `u8` + | help: change the parameter type to match the trait: `()` + | +note: type in trait + --> $DIR/method-signature-matches.rs:20:21 + | +LL | async fn owo(x: ()) {} + | ^^ + = note: expected signature `fn(()) -> _` + found signature `fn(u8) -> _` + +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/method-signature-matches.rs b/tests/ui/impl-trait/in-trait/method-signature-matches.rs index c848ee3f6..294f93b30 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.rs +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.rs @@ -1,51 +1,62 @@ // edition: 2021 +// revisions: mismatch mismatch_async too_many too_few lt #![feature(return_position_impl_trait_in_trait, async_fn_in_trait)] #![allow(incomplete_features)] +#[cfg(mismatch)] trait Uwu { fn owo(x: ()) -> impl Sized; } +#[cfg(mismatch)] impl Uwu for () { fn owo(_: u8) {} - //~^ ERROR method `owo` has an incompatible type for trait + //[mismatch]~^ ERROR method `owo` has an incompatible type for trait } +#[cfg(mismatch_async)] trait AsyncUwu { async fn owo(x: ()) {} } +#[cfg(mismatch_async)] impl AsyncUwu for () { async fn owo(_: u8) {} - //~^ ERROR method `owo` has an incompatible type for trait + //[mismatch_async]~^ ERROR method `owo` has an incompatible type for trait } +#[cfg(too_many)] trait TooMuch { fn calm_down_please() -> impl Sized; } +#[cfg(too_many)] impl TooMuch for () { fn calm_down_please(_: (), _: (), _: ()) {} - //~^ ERROR method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 + //[too_many]~^ ERROR method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 } +#[cfg(too_few)] trait TooLittle { fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; } +#[cfg(too_few)] impl TooLittle for () { fn come_on_a_little_more_effort() {} - //~^ ERROR method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3 + //[too_few]~^ ERROR method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3 } +#[cfg(lt)] trait Lifetimes { fn early<'early, T>(x: &'early T) -> impl Sized; } +#[cfg(lt)] impl Lifetimes for () { fn early<'late, T>(_: &'late ()) {} - //~^ ERROR method `early` has an incompatible type for trait + //[lt]~^ ERROR method `early` has an incompatible type for trait } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.stderr deleted file mode 100644 index 3ec62020e..000000000 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.stderr +++ /dev/null @@ -1,74 +0,0 @@ -error[E0053]: method `owo` has an incompatible type for trait - --> $DIR/method-signature-matches.rs:11:15 - | -LL | fn owo(_: u8) {} - | ^^ - | | - | expected `()`, found `u8` - | help: change the parameter type to match the trait: `()` - | -note: type in trait - --> $DIR/method-signature-matches.rs:7:15 - | -LL | fn owo(x: ()) -> impl Sized; - | ^^ - = note: expected signature `fn(())` - found signature `fn(u8)` - -error[E0053]: method `owo` has an incompatible type for trait - --> $DIR/method-signature-matches.rs:20:21 - | -LL | async fn owo(_: u8) {} - | ^^ - | | - | expected `()`, found `u8` - | help: change the parameter type to match the trait: `()` - | -note: type in trait - --> $DIR/method-signature-matches.rs:16:21 - | -LL | async fn owo(x: ()) {} - | ^^ - = note: expected signature `fn(()) -> _` - found signature `fn(u8) -> _` - -error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 - --> $DIR/method-signature-matches.rs:29:28 - | -LL | fn calm_down_please() -> impl Sized; - | ------------------------------------ trait requires 0 parameters -... -LL | fn calm_down_please(_: (), _: (), _: ()) {} - | ^^^^^^^^^^^^^^^^ expected 0 parameters, found 3 - -error[E0050]: method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3 - --> $DIR/method-signature-matches.rs:38:5 - | -LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; - | ---------------- trait requires 3 parameters -... -LL | fn come_on_a_little_more_effort() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 parameters, found 0 - -error[E0053]: method `early` has an incompatible type for trait - --> $DIR/method-signature-matches.rs:47:27 - | -LL | fn early<'late, T>(_: &'late ()) {} - | - ^^^^^^^^^ - | | | - | | expected type parameter `T`, found `()` - | | help: change the parameter type to match the trait: `&'early T` - | this type parameter - | -note: type in trait - --> $DIR/method-signature-matches.rs:43:28 - | -LL | fn early<'early, T>(x: &'early T) -> impl Sized; - | ^^^^^^^^^ - = note: expected signature `fn(&'early T)` - found signature `fn(&())` - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0050, E0053. -For more information about an error, try `rustc --explain E0050`. diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr new file mode 100644 index 000000000..24bcfeb74 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr @@ -0,0 +1,12 @@ +error[E0050]: method `come_on_a_little_more_effort` has 0 parameters but the declaration in trait `TooLittle::come_on_a_little_more_effort` has 3 + --> $DIR/method-signature-matches.rs:47:5 + | +LL | fn come_on_a_little_more_effort(_: (), _: (), _: ()) -> impl Sized; + | ---------------- trait requires 3 parameters +... +LL | fn come_on_a_little_more_effort() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 parameters, found 0 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0050`. diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr new file mode 100644 index 000000000..616cbd290 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr @@ -0,0 +1,12 @@ +error[E0050]: method `calm_down_please` has 3 parameters but the declaration in trait `TooMuch::calm_down_please` has 0 + --> $DIR/method-signature-matches.rs:36:28 + | +LL | fn calm_down_please() -> impl Sized; + | ------------------------------------ trait requires 0 parameters +... +LL | fn calm_down_please(_: (), _: (), _: ()) {} + | ^^^^^^^^^^^^^^^^ expected 0 parameters, found 3 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0050`. 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 new file mode 100644 index 000000000..ff30103b7 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.current.stderr @@ -0,0 +1,16 @@ +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 new file mode 100644 index 000000000..7c7f7feaa --- /dev/null +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.next.stderr @@ -0,0 +1,16 @@ +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 new file mode 100644 index 000000000..65528f212 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs @@ -0,0 +1,19 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] + +trait Foo { + fn foo(self) -> impl Foo; +} + +struct Bar; + +impl Foo for Bar { + fn foo>(self) -> impl Foo { + //~^ ERROR: the trait bound `impl Foo: Foo` is not satisfied [E0277] + self + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr index eba270af7..8c9dd4031 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr @@ -1,16 +1,61 @@ -error: `impl` item signature doesn't match `trait` item signature - --> $DIR/signature-mismatch.rs:17:5 +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>; - | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '3` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = 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 | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '2` +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... | - = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '3` - found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '2` - = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` - = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output +LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>( + | ++++ -error: aborting due to previous error +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 index eba270af7..8c9dd4031 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr @@ -1,16 +1,61 @@ -error: `impl` item signature doesn't match `trait` item signature - --> $DIR/signature-mismatch.rs:17:5 +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>; - | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '3` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = 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 | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '2` +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... | - = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '3` - found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future> + '2` - = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` - = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output +LL | fn async_fn_reduce_outlive<'a, 'b, T: 'a>( + | ++++ -error: aborting due to previous error +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 38c902a97..23dd71ace 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs @@ -7,17 +7,70 @@ use std::future::Future; +trait Captures<'a> {} +impl Captures<'_> for T {} + +trait Captures2<'a, 'b> {} +impl Captures2<'_, '_> for T {} + pub trait AsyncTrait { fn async_fn(&self, buff: &[u8]) -> impl Future>; + fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future>; + fn async_fn_multiple<'a>(&'a self, buff: &[u8]) + -> impl Future> + Captures<'a>; + fn async_fn_reduce_outlive<'a, T>( + &'a self, + buff: &[u8], + t: T, + ) -> impl Future> + 'a; + fn async_fn_reduce<'a, T>( + &'a self, + buff: &[u8], + t: T, + ) -> impl Future> + Captures<'a>; } pub struct Struct; impl AsyncTrait for Struct { fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { - //~^ ERROR `impl` item signature doesn't match `trait` item signature + //~^ ERROR return type captures more lifetimes than trait definition + async move { buff.to_vec() } + } + + fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future> + 'a { + //~^ ERROR return type captures more lifetimes than trait definition + async move { buff.to_vec() } + } + + fn async_fn_multiple<'a, 'b>( + &'a self, + buff: &'b [u8], + ) -> impl Future> + Captures2<'a, 'b> { + //~^ ERROR return type captures more lifetimes than trait definition async move { buff.to_vec() } } + + fn async_fn_reduce_outlive<'a, 'b, T>( + &'a self, + buff: &'b [u8], + t: T, + ) -> impl Future> { + //~^ ERROR the parameter type `T` may not live long enough + async move { + let _t = t; + vec![] + } + } + + // OK: We remove the `Captures<'a>`, providing a guarantee that we don't capture `'a`, + // but we still fulfill the `Captures<'a>` trait bound. + fn async_fn_reduce<'a, 'b, T>(&'a self, buff: &'b [u8], t: T) -> impl Future> { + async move { + let _t = t; + vec![] + } + } } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed new file mode 100644 index 000000000..d9f775a6c --- /dev/null +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed @@ -0,0 +1,25 @@ +// edition:2021 +// run-rustfix + +#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] + +trait Trait { + async fn foo(); + + async fn bar() -> i32; + + fn test(&self) -> impl Sized + '_; + + async fn baz(&self) -> &i32; +} + +struct S; + +impl Trait for S {async fn baz(&self) -> &i32 { todo!() } +fn test(&self) -> impl Sized + '_ { todo!() } +async fn bar() -> i32 { todo!() } +async fn foo() { todo!() } +} +//~^ ERROR not all trait items implemented + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs new file mode 100644 index 000000000..26979b514 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs @@ -0,0 +1,21 @@ +// edition:2021 +// run-rustfix + +#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] + +trait Trait { + async fn foo(); + + async fn bar() -> i32; + + fn test(&self) -> impl Sized + '_; + + async fn baz(&self) -> &i32; +} + +struct S; + +impl Trait for S {} +//~^ ERROR not all trait items implemented + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr new file mode 100644 index 000000000..44f98896e --- /dev/null +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr @@ -0,0 +1,21 @@ +error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz` + --> $DIR/suggest-missing-item.rs:18:1 + | +LL | async fn foo(); + | --------------- `foo` from trait +LL | +LL | async fn bar() -> i32; + | ---------------------- `bar` from trait +LL | +LL | fn test(&self) -> impl Sized + '_; + | ---------------------------------- `test` from trait +LL | +LL | async fn baz(&self) -> &i32; + | ---------------------------- `baz` from trait +... +LL | impl Trait for S {} + | ^^^^^^^^^^^^^^^^ missing `foo`, `bar`, `test`, `baz` 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/unconstrained-lt.current.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.current.stderr new file mode 100644 index 000000000..bf088ae8b --- /dev/null +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.current.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: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 new file mode 100644 index 000000000..bf088ae8b --- /dev/null +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.next.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: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 new file mode 100644 index 000000000..f966be43a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs @@ -0,0 +1,16 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] + +trait Foo { + fn test() -> impl Sized; +} + +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 main() {} diff --git a/tests/ui/impl-trait/in-trait/variances-of-gat.rs b/tests/ui/impl-trait/in-trait/variances-of-gat.rs new file mode 100644 index 000000000..4008ece94 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/variances-of-gat.rs @@ -0,0 +1,19 @@ +// check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] + +trait Foo {} + +impl Foo for () {} + +trait ThreeCellFragment { + fn ext_cells<'a>(&'a self) -> impl Foo + 'a { + self.ext_adjacent_cells() + } + + fn ext_adjacent_cells<'a>(&'a self) -> impl Foo + 'a; +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr index 1a7071612..74c84c012 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:13:22 + --> $DIR/wf-bounds.rs:17:22 | LL | fn nya() -> impl Wf>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,14 +9,14 @@ 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:16:23 + --> $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:8:10 + --> $DIR/wf-bounds.rs:10:10 | LL | trait Wf { | ^ required by this bound in `Wf` @@ -26,7 +26,7 @@ LL | trait Wf { | ++++++++ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:19:44 + --> $DIR/wf-bounds.rs:23:44 | LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -35,6 +35,23 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -error: aborting due to 3 previous errors +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 index 1a7071612..74c84c012 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:13:22 + --> $DIR/wf-bounds.rs:17:22 | LL | fn nya() -> impl Wf>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,14 +9,14 @@ 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:16:23 + --> $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:8:10 + --> $DIR/wf-bounds.rs:10:10 | LL | trait Wf { | ^ required by this bound in `Wf` @@ -26,7 +26,7 @@ LL | trait Wf { | ++++++++ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:19:44 + --> $DIR/wf-bounds.rs:23:44 | LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -35,6 +35,23 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf>>; note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -error: aborting due to 3 previous errors +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 1c9590bd8..f8c1e561d 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.rs +++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs @@ -5,10 +5,14 @@ #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] +use std::fmt::Display; + trait Wf { type Output; } +struct NeedsDisplay(T); + trait Uwu { fn nya() -> impl Wf>; //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time @@ -18,6 +22,9 @@ trait Uwu { fn nya3() -> impl Wf<(), Output = impl Wf>>; //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + + fn nya4() -> impl Wf>; + //~^ ERROR `T` doesn't implement `std::fmt::Display` } fn main() {} diff --git a/tests/ui/impl-trait/issue-103181-2.rs b/tests/ui/impl-trait/issue-103181-2.rs index b43ac4507..34deb98be 100644 --- a/tests/ui/impl-trait/issue-103181-2.rs +++ b/tests/ui/impl-trait/issue-103181-2.rs @@ -24,6 +24,8 @@ where B: Send, // <- a second bound { normalize(broken_fut(), ()); + //~^ ERROR: cannot check whether the hidden type of opaque type satisfies auto traits + //~| ERROR: cannot check whether the hidden type of opaque type satisfies auto traits } fn main() {} diff --git a/tests/ui/impl-trait/issue-103181-2.stderr b/tests/ui/impl-trait/issue-103181-2.stderr index 5eb2dd918..cb5253ea6 100644 --- a/tests/ui/impl-trait/issue-103181-2.stderr +++ b/tests/ui/impl-trait/issue-103181-2.stderr @@ -4,6 +4,61 @@ error[E0425]: cannot find value `ident_error` in this scope LL | ident_error; | ^^^^^^^^^^^ not found in this scope -error: aborting due to previous error +error: cannot check whether the hidden type of opaque type satisfies auto traits + --> $DIR/issue-103181-2.rs:26:15 + | +LL | normalize(broken_fut(), ()); + | --------- ^^^^^^^^^^^^ + | | + | required by a bound introduced by this call + | +note: opaque type is declared here + --> $DIR/issue-103181-2.rs:11:23 + | +LL | async fn broken_fut() { + | ^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/issue-103181-2.rs:20:10 + | +LL | async fn iceice() + | ^^^^^^ +note: required for `impl Future` to implement `SendFuture` + --> $DIR/issue-103181-2.rs:7:17 + | +LL | impl SendFuture for Fut { + | ---- ^^^^^^^^^^ ^^^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `normalize` + --> $DIR/issue-103181-2.rs:18:19 + | +LL | fn normalize(_: Fut, _: Fut::Output) {} + | ^^^^^^^^^^ required by this bound in `normalize` + +error: cannot check whether the hidden type of opaque type satisfies auto traits + --> $DIR/issue-103181-2.rs:26:5 + | +LL | normalize(broken_fut(), ()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: opaque type is declared here + --> $DIR/issue-103181-2.rs:11:23 + | +LL | async fn broken_fut() { + | ^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/issue-103181-2.rs:20:10 + | +LL | async fn iceice() + | ^^^^^^ +note: required for `impl Future` to implement `SendFuture` + --> $DIR/issue-103181-2.rs:7:17 + | +LL | impl SendFuture for Fut { + | ---- ^^^^^^^^^^ ^^^ + | | + | unsatisfied trait bound introduced here + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/impl-trait/issue-55872-3.rs b/tests/ui/impl-trait/issue-55872-3.rs index d031271ac..7490a1308 100644 --- a/tests/ui/impl-trait/issue-55872-3.rs +++ b/tests/ui/impl-trait/issue-55872-3.rs @@ -1,5 +1,4 @@ // edition:2018 -// ignore-compare-mode-chalk #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/impl-trait/issue-55872-3.stderr b/tests/ui/impl-trait/issue-55872-3.stderr index c6e10f0f3..827988974 100644 --- a/tests/ui/impl-trait/issue-55872-3.stderr +++ b/tests/ui/impl-trait/issue-55872-3.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `[async block@$DIR/issue-55872-3.rs:16:9: 16:17]: Copy` is not satisfied - --> $DIR/issue-55872-3.rs:14:20 +error[E0277]: the trait bound `[async block@$DIR/issue-55872-3.rs:15:9: 15:17]: Copy` is not satisfied + --> $DIR/issue-55872-3.rs:13:20 | LL | fn foo() -> Self::E { - | ^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/issue-55872-3.rs:16:9: 16:17]` + | ^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/issue-55872-3.rs:15:9: 15:17]` error: aborting due to previous error diff --git a/tests/ui/impl-trait/issues/issue-65581.rs b/tests/ui/impl-trait/issues/issue-65581.rs index b947fc1d2..af65b79d3 100644 --- a/tests/ui/impl-trait/issues/issue-65581.rs +++ b/tests/ui/impl-trait/issues/issue-65581.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-compare-mode-chalk #![allow(dead_code)] diff --git a/tests/ui/impl-trait/issues/issue-70877.rs b/tests/ui/impl-trait/issues/issue-70877.rs index 8169cfafa..df7722986 100644 --- a/tests/ui/impl-trait/issues/issue-70877.rs +++ b/tests/ui/impl-trait/issues/issue-70877.rs @@ -25,12 +25,12 @@ fn ham() -> Foo { Bar(1) } -fn oof() -> impl std::fmt::Debug { +fn oof(_: Foo) -> impl std::fmt::Debug { let mut bar = ham(); let func = bar.next().unwrap(); return func(&"oof"); //~ ERROR opaque type's hidden type cannot be another opaque type } fn main() { - let _ = oof(); + let _ = oof(ham()); } diff --git a/tests/ui/impl-trait/issues/issue-70877.stderr b/tests/ui/impl-trait/issues/issue-70877.stderr index 8813bff3c..ee140e6f6 100644 --- a/tests/ui/impl-trait/issues/issue-70877.stderr +++ b/tests/ui/impl-trait/issues/issue-70877.stderr @@ -5,10 +5,10 @@ LL | return func(&"oof"); | ^^^^^^^^^^^^ one of the two opaque types used here has to be outside its defining scope | note: opaque type whose hidden type is being assigned - --> $DIR/issue-70877.rs:28:13 + --> $DIR/issue-70877.rs:28:19 | -LL | fn oof() -> impl std::fmt::Debug { - | ^^^^^^^^^^^^^^^^^^^^ +LL | fn oof(_: Foo) -> impl std::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^^^ note: opaque type being used as hidden type --> $DIR/issue-70877.rs:4:15 | diff --git a/tests/ui/impl-trait/issues/issue-74282.rs b/tests/ui/impl-trait/issues/issue-74282.rs index 654de0cd0..51bd5f67e 100644 --- a/tests/ui/impl-trait/issues/issue-74282.rs +++ b/tests/ui/impl-trait/issues/issue-74282.rs @@ -3,9 +3,12 @@ type Closure = impl Fn() -> u64; struct Anonymous(Closure); -fn main() { +fn bop(_: Closure) { let y = || -> Closure { || 3 }; - Anonymous(|| { //~ ERROR mismatched types - 3 //~^ ERROR mismatched types + Anonymous(|| { + //~^ ERROR mismatched types + 3 //~^^ ERROR mismatched types }) } + +fn main() {} diff --git a/tests/ui/impl-trait/issues/issue-74282.stderr b/tests/ui/impl-trait/issues/issue-74282.stderr index 724f3c5d6..d43e9fee0 100644 --- a/tests/ui/impl-trait/issues/issue-74282.stderr +++ b/tests/ui/impl-trait/issues/issue-74282.stderr @@ -8,6 +8,7 @@ LL | Anonymous(|| { | _____---------_^ | | | | | arguments to this struct are incorrect +LL | | LL | | 3 LL | | }) | |_____^ expected opaque type, found closure @@ -25,15 +26,20 @@ LL | struct Anonymous(Closure); error[E0308]: mismatched types --> $DIR/issue-74282.rs:8:5 | -LL | fn main() { - | - expected `()` because of default return type -LL | let y = || -> Closure { || 3 }; LL | / Anonymous(|| { +LL | | LL | | 3 LL | | }) - | | ^- help: consider using a semicolon here: `;` - | |______| - | expected `()`, found `Anonymous` + | |______^ expected `()`, found `Anonymous` + | +help: consider using a semicolon here + | +LL | }); + | + +help: try adding a return type + | +LL | fn bop(_: Closure) -> Anonymous { + | ++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/issues/issue-78722-2.rs b/tests/ui/impl-trait/issues/issue-78722-2.rs new file mode 100644 index 000000000..cf5361e1e --- /dev/null +++ b/tests/ui/impl-trait/issues/issue-78722-2.rs @@ -0,0 +1,22 @@ +//! test that we cannot register hidden types for opaque types +//! declared outside an anonymous constant. +// edition:2018 + +#![feature(type_alias_impl_trait)] + +type F = impl core::future::Future; + +struct Bug { + V1: [(); { + fn concrete_use() -> F { + //~^ ERROR future that resolves to `u8`, but it resolves to `()` + async {} + } + let f: F = async { 1 }; + //~^ ERROR item constrains opaque type that is not in its signature + //~| ERROR `async` blocks are not allowed in constants + 1 + }], +} + +fn main() {} diff --git a/tests/ui/impl-trait/issues/issue-78722-2.stderr b/tests/ui/impl-trait/issues/issue-78722-2.stderr new file mode 100644 index 000000000..6db603e77 --- /dev/null +++ b/tests/ui/impl-trait/issues/issue-78722-2.stderr @@ -0,0 +1,32 @@ +error[E0658]: `async` blocks are not allowed in constants + --> $DIR/issue-78722-2.rs:15:20 + | +LL | let f: F = async { 1 }; + | ^^^^^^^^^^^ + | + = note: see issue #85368 for more information + = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable + +error[E0271]: expected `[async block@$DIR/issue-78722-2.rs:13:13: 13:21]` to be a future that resolves to `u8`, but it resolves to `()` + --> $DIR/issue-78722-2.rs:11:30 + | +LL | fn concrete_use() -> F { + | ^ expected `()`, found `u8` + +error: item constrains opaque type that is not in its signature + --> $DIR/issue-78722-2.rs:15:20 + | +LL | let f: F = async { 1 }; + | ^^^^^^^^^^^ + | + = note: this item must mention the opaque type in its signature in order to be able to register hidden types +note: this item must mention the opaque type in its signature in order to be able to register hidden types + --> $DIR/issue-78722-2.rs:15:20 + | +LL | let f: F = async { 1 }; + | ^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0271, E0658. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/issues/issue-78722.rs b/tests/ui/impl-trait/issues/issue-78722.rs index 7b5ab5f22..75ccc8d8e 100644 --- a/tests/ui/impl-trait/issues/issue-78722.rs +++ b/tests/ui/impl-trait/issues/issue-78722.rs @@ -2,10 +2,9 @@ #![feature(type_alias_impl_trait)] -type F = impl core::future::Future; - struct Bug { V1: [(); { + type F = impl core::future::Future; fn concrete_use() -> F { //~^ ERROR to be a future that resolves to `u8`, but it resolves to `()` async {} diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index 05a2c135c..36340a0ba 100644 --- a/tests/ui/impl-trait/issues/issue-78722.stderr +++ b/tests/ui/impl-trait/issues/issue-78722.stderr @@ -1,5 +1,5 @@ error[E0658]: `async` blocks are not allowed in constants - --> $DIR/issue-78722.rs:13:20 + --> $DIR/issue-78722.rs:12:20 | LL | let f: F = async { 1 }; | ^^^^^^^^^^^ @@ -7,8 +7,8 @@ LL | let f: F = async { 1 }; = note: see issue #85368 for more information = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable -error[E0271]: expected `[async block@$DIR/issue-78722.rs:11:13: 11:21]` to be a future that resolves to `u8`, but it resolves to `()` - --> $DIR/issue-78722.rs:9:30 +error[E0271]: expected `[async block@$DIR/issue-78722.rs:10:13: 10:21]` to be a future that resolves to `u8`, but it resolves to `()` + --> $DIR/issue-78722.rs:8:30 | LL | fn concrete_use() -> F { | ^ expected `()`, found `u8` diff --git a/tests/ui/impl-trait/multiple-defining-usages-in-body.rs b/tests/ui/impl-trait/multiple-defining-usages-in-body.rs index c3a6f09f8..86661153a 100644 --- a/tests/ui/impl-trait/multiple-defining-usages-in-body.rs +++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.rs @@ -4,9 +4,9 @@ impl Trait for () {} fn foo() -> impl Trait { //~^ WARN function cannot return without recursing [unconditional_recursion] let a: T = foo::(); - //~^ ERROR concrete type differs from previous defining opaque type use loop {} let _: T = foo::(); + //~^ ERROR concrete type differs from previous defining opaque type use } fn main() {} diff --git a/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr index 06991749b..f3c090408 100644 --- a/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr +++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr @@ -11,15 +11,15 @@ LL | let a: T = foo::(); = note: `#[warn(unconditional_recursion)]` on by default error: concrete type differs from previous defining opaque type use - --> $DIR/multiple-defining-usages-in-body.rs:6:16 + --> $DIR/multiple-defining-usages-in-body.rs:8:16 | -LL | let a: T = foo::(); - | ^^^^^^^^^^^^^ expected `U`, got `T` +LL | let _: T = foo::(); + | ^^^^^^^^^^^^^ expected `T`, got `U` | note: previous use here - --> $DIR/multiple-defining-usages-in-body.rs:9:16 + --> $DIR/multiple-defining-usages-in-body.rs:6:16 | -LL | let _: T = foo::(); +LL | let a: T = foo::(); | ^^^^^^^^^^^^^ error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/impl-trait/nested-return-type2-tait.stderr b/tests/ui/impl-trait/nested-return-type2-tait.stderr index a8eb69cfc..4383e8ab3 100644 --- a/tests/ui/impl-trait/nested-return-type2-tait.stderr +++ b/tests/ui/impl-trait/nested-return-type2-tait.stderr @@ -8,10 +8,6 @@ LL | fn foo() -> impl Trait { | ^^^^^^^^^^^^^^^^ | = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | type Sendable = impl Send + Duh; - | +++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/nested-return-type3-tait.stderr b/tests/ui/impl-trait/nested-return-type3-tait.stderr index 5f58c8dca..d32944a0d 100644 --- a/tests/ui/impl-trait/nested-return-type3-tait.stderr +++ b/tests/ui/impl-trait/nested-return-type3-tait.stderr @@ -8,10 +8,6 @@ LL | fn foo() -> impl Trait { | ^^^^^^^^^^^^^^^^ | = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | type Sendable = impl Send + Duh; - | +++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/nested-return-type3-tait2.stderr b/tests/ui/impl-trait/nested-return-type3-tait2.stderr index c07f6ead7..a2eddd116 100644 --- a/tests/ui/impl-trait/nested-return-type3-tait2.stderr +++ b/tests/ui/impl-trait/nested-return-type3-tait2.stderr @@ -8,10 +8,6 @@ LL | type Traitable = impl Trait; | ^^^^^^^^^^^^^^^^ | = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | type Sendable = impl Send + Duh; - | +++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs b/tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs new file mode 100644 index 000000000..1025c2c7e --- /dev/null +++ b/tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs @@ -0,0 +1,27 @@ +// build-pass +// edition:2021 +// compile-flags: -Cdebuginfo=2 + +// We were not normalizing opaques with escaping bound vars during codegen, +// leading to later linker errors because of differences in mangled symbol name. + +fn func() -> impl Sized {} + +trait Trait<'a> { + type Assoc; + + fn call() { + let _ = async { + let _value = func::(); + std::future::ready(()).await + }; + } +} + +impl Trait<'static> for () { + type Assoc = (); +} + +fn main() { + <()>::call(); +} diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs index af9dfe25b..01c933473 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs @@ -1,5 +1,7 @@ #![feature(type_alias_impl_trait)] +// check-pass + type Foo = impl PartialEq<(Foo, i32)>; struct Bar; @@ -11,7 +13,6 @@ impl PartialEq<(Foo, i32)> for Bar { } fn foo() -> Foo { - //~^ ERROR can't compare `Bar` with `(Bar, i32)` Bar } diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr deleted file mode 100644 index 7b63a3d0b..000000000 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: can't compare `Bar` with `(Bar, i32)` - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs:13:13 - | -LL | fn foo() -> Foo { - | ^^^ no implementation for `Bar == (Bar, i32)` -LL | -LL | Bar - | --- return type was inferred to be `Bar` here - | - = help: the trait `PartialEq<(Bar, i32)>` is not implemented for `Bar` - = help: the trait `PartialEq<(Foo, i32)>` is implemented for `Bar` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index fe62a8f32..fe765271b 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -44,10 +44,10 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool { = note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _` found signature `fn(&b::Bar, &(b::Bar, i32)) -> _` note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:9 + --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:24:12 | LL | fn eq(&self, _other: &(Bar, i32)) -> bool { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^ error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs index ad0a003e8..aab10be2d 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs @@ -1,5 +1,3 @@ -// check-pass - #![feature(type_alias_impl_trait)] type Foo = impl PartialEq<(Foo, i32)>; @@ -13,6 +11,7 @@ impl PartialEq<(Bar, i32)> for Bar { } fn foo() -> Foo { + //~^ ERROR can't compare `Bar` with `(Foo, i32)` Bar } diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr new file mode 100644 index 000000000..b98b859a9 --- /dev/null +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr @@ -0,0 +1,15 @@ +error[E0277]: can't compare `Bar` with `(Foo, i32)` + --> $DIR/recursive-type-alias-impl-trait-declaration.rs:13:13 + | +LL | fn foo() -> Foo { + | ^^^ no implementation for `Bar == (Foo, i32)` +LL | +LL | Bar + | --- return type was inferred to be `Bar` here + | + = help: the trait `PartialEq<(Foo, i32)>` is not implemented for `Bar` + = help: the trait `PartialEq<(Bar, i32)>` is implemented for `Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/reveal-during-codegen.rs b/tests/ui/impl-trait/reveal-during-codegen.rs new file mode 100644 index 000000000..11463772e --- /dev/null +++ b/tests/ui/impl-trait/reveal-during-codegen.rs @@ -0,0 +1,11 @@ +// build-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +fn test() -> Option { + Some("") +} + +fn main() { + test(); +} diff --git a/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs new file mode 100644 index 000000000..98dbaf036 --- /dev/null +++ b/tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs @@ -0,0 +1,12 @@ +// check-pass + +#![allow(incomplete_features)] +#![feature(adt_const_params, return_position_impl_trait_in_trait)] + +pub struct Element; + +pub trait Node { + fn elements(&self) -> impl Iterator; +} + +fn main() {} diff --git a/tests/ui/impl-trait/universal_wrong_hrtb.rs b/tests/ui/impl-trait/universal_wrong_hrtb.rs index b9551c2ce..485617101 100644 --- a/tests/ui/impl-trait/universal_wrong_hrtb.rs +++ b/tests/ui/impl-trait/universal_wrong_hrtb.rs @@ -3,6 +3,6 @@ trait Trait<'a> { } fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} -//~^ ERROR `impl Trait` can only mention lifetimes bound at the fn or impl level +//~^ ERROR `impl Trait` can only mention lifetimes from an fn or impl fn main() {} diff --git a/tests/ui/impl-trait/universal_wrong_hrtb.stderr b/tests/ui/impl-trait/universal_wrong_hrtb.stderr index 37eb8dfa1..b5a091b61 100644 --- a/tests/ui/impl-trait/universal_wrong_hrtb.stderr +++ b/tests/ui/impl-trait/universal_wrong_hrtb.stderr @@ -1,14 +1,8 @@ -error: `impl Trait` can only mention lifetimes bound at the fn or impl level +error: `impl Trait` can only mention lifetimes from an fn or impl --> $DIR/universal_wrong_hrtb.rs:5:73 | LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} - | ^^ - | -note: lifetime declared here - --> $DIR/universal_wrong_hrtb.rs:5:39 - | -LL | fn test_argument_position(x: impl for<'a> Trait<'a, Assoc = impl Copy + 'a>) {} - | ^^ + | -- lifetime declared here ^^ error: aborting due to previous error diff --git a/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs b/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs new file mode 100644 index 000000000..025e5176f --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-unconstrained-1.rs @@ -0,0 +1,28 @@ +// check-pass + +// Regression test for #112832. +pub trait QueryDb { + type Db; +} + +pub struct QueryTable { + db: DB, + storage: Q, +} + +// We normalize `::Db` to `>::SendDb` +// using the where-bound. 'd is an unconstrained region variable which previously +// triggered an assert. +impl QueryTable::Db> where Q: for<'d> AsyncQueryFunction<'d> {} + +pub trait AsyncQueryFunction<'d>: QueryDb>::SendDb> { + type SendDb: 'd; +} + +pub trait QueryStorageOpsAsync +where + Q: for<'d> AsyncQueryFunction<'d>, +{ +} + +fn main() {} diff --git a/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs b/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs new file mode 100644 index 000000000..976054fac --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-unconstrained-2.rs @@ -0,0 +1,20 @@ +// check-pass + +// Another minimized regression test for #112832. +trait Trait { + type Assoc; +} + +trait Sub<'a>: Trait>::SubAssoc> { + type SubAssoc; +} + +// By using the where-clause we normalize `::Assoc` to +// `>::SubAssoc` where `'a` is an unconstrained region +// variable. +fn foo(x: ::Assoc) +where + for<'a> T: Sub<'a>, +{} + +fn main() {} diff --git a/tests/ui/implied-bounds/references-err.rs b/tests/ui/implied-bounds/references-err.rs new file mode 100644 index 000000000..203d512e3 --- /dev/null +++ b/tests/ui/implied-bounds/references-err.rs @@ -0,0 +1,22 @@ +trait Identity { + type Identity; +} +impl Identity for T { + type Identity = T; +} + +trait Trait { + type Assoc: Identity; + fn tokenize(&self) -> ::Identity; +} + +impl Trait for () { + type Assoc = DoesNotExist; + //~^ ERROR cannot find type `DoesNotExist` in this scope + + fn tokenize(&self) -> ::Identity { + unimplemented!() + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/references-err.stderr b/tests/ui/implied-bounds/references-err.stderr new file mode 100644 index 000000000..6076eea3c --- /dev/null +++ b/tests/ui/implied-bounds/references-err.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `DoesNotExist` in this scope + --> $DIR/references-err.rs:14:18 + | +LL | type Assoc = DoesNotExist; + | ^^^^^^^^^^^^ 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/imports/auxiliary/issue-85992-extern-1.rs b/tests/ui/imports/auxiliary/issue-85992-extern-1.rs new file mode 100644 index 000000000..a2d0e2060 --- /dev/null +++ b/tests/ui/imports/auxiliary/issue-85992-extern-1.rs @@ -0,0 +1,6 @@ +#[macro_export] +macro_rules! m { + () => { + use issue_85992_extern_2::Outcome; + } +} diff --git a/tests/ui/imports/auxiliary/issue-85992-extern-2.rs b/tests/ui/imports/auxiliary/issue-85992-extern-2.rs new file mode 100644 index 000000000..e9b6a44cf --- /dev/null +++ b/tests/ui/imports/auxiliary/issue-85992-extern-2.rs @@ -0,0 +1 @@ +// nothing diff --git a/tests/ui/imports/issue-55884-2.rs b/tests/ui/imports/issue-55884-2.rs index 75bb4206f..6f8d0cf8a 100644 --- a/tests/ui/imports/issue-55884-2.rs +++ b/tests/ui/imports/issue-55884-2.rs @@ -6,6 +6,7 @@ mod parser { pub use options::*; // Private single import shadows public glob import, but arrives too late for initial // resolution of `use parser::ParseOptions` because it depends on that resolution itself. + #[allow(hidden_glob_reexports)] use ParseOptions; } diff --git a/tests/ui/imports/issue-55884-2.stderr b/tests/ui/imports/issue-55884-2.stderr index 5adbc4b66..67d411414 100644 --- a/tests/ui/imports/issue-55884-2.stderr +++ b/tests/ui/imports/issue-55884-2.stderr @@ -1,16 +1,16 @@ error[E0603]: struct import `ParseOptions` is private - --> $DIR/issue-55884-2.rs:12:17 + --> $DIR/issue-55884-2.rs:13:17 | LL | pub use parser::ParseOptions; | ^^^^^^^^^^^^ private struct import | note: the struct import `ParseOptions` is defined here... - --> $DIR/issue-55884-2.rs:9:9 + --> $DIR/issue-55884-2.rs:10:9 | LL | use ParseOptions; | ^^^^^^^^^^^^ note: ...and refers to the struct import `ParseOptions` which is defined here... - --> $DIR/issue-55884-2.rs:12:9 + --> $DIR/issue-55884-2.rs:13:9 | LL | pub use parser::ParseOptions; | ^^^^^^^^^^^^^^^^^^^^ consider importing it directly diff --git a/tests/ui/imports/issue-56125.stderr b/tests/ui/imports/issue-56125.stderr index 3448f3119..15477fb6f 100644 --- a/tests/ui/imports/issue-56125.stderr +++ b/tests/ui/imports/issue-56125.stderr @@ -22,7 +22,7 @@ error[E0659]: `issue_56125` is ambiguous LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here @@ -30,7 +30,8 @@ note: `issue_56125` could also refer to the module imported here | LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `self::issue_56125` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous --> $DIR/issue-56125.rs:11:9 @@ -38,7 +39,7 @@ error[E0659]: `issue_56125` is ambiguous LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here @@ -46,7 +47,8 @@ note: `issue_56125` could also refer to the module imported here | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `self::issue_56125` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous --> $DIR/issue-56125.rs:18:9 @@ -54,7 +56,7 @@ error[E0659]: `issue_56125` is ambiguous LL | use issue_56125::*; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here @@ -62,7 +64,8 @@ note: `issue_56125` could also refer to the module imported here | LL | use issue_56125::*; | ^^^^^^^^^^^^^^ - = help: use `self::issue_56125` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously error: aborting due to 4 previous errors diff --git a/tests/ui/imports/issue-57539.stderr b/tests/ui/imports/issue-57539.stderr index 1a3ca4eda..88cc42ccf 100644 --- a/tests/ui/imports/issue-57539.stderr +++ b/tests/ui/imports/issue-57539.stderr @@ -4,7 +4,7 @@ error[E0659]: `core` is ambiguous LL | use core; | ^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `core` could refer to a built-in crate = help: use `::core` to refer to this crate unambiguously note: `core` could also refer to the module imported here @@ -12,7 +12,8 @@ note: `core` could also refer to the module imported here | LL | use crate::*; | ^^^^^^^^ - = help: use `self::core` to refer to this module unambiguously + = help: consider adding an explicit import of `core` to disambiguate + = help: or use `self::core` to refer to this module unambiguously error: aborting due to previous error diff --git a/tests/ui/imports/issue-85992.rs b/tests/ui/imports/issue-85992.rs new file mode 100644 index 000000000..d55241091 --- /dev/null +++ b/tests/ui/imports/issue-85992.rs @@ -0,0 +1,11 @@ +// edition: 2021 +// compile-flags: --extern issue_85992_extern_1 --extern issue_85992_extern_2 +// aux-build: issue-85992-extern-1.rs +// aux-build: issue-85992-extern-2.rs + +issue_85992_extern_1::m!(); + +use crate::issue_85992_extern_2; +//~^ ERROR unresolved import `crate::issue_85992_extern_2` + +fn main() {} diff --git a/tests/ui/imports/issue-85992.stderr b/tests/ui/imports/issue-85992.stderr new file mode 100644 index 000000000..810d41009 --- /dev/null +++ b/tests/ui/imports/issue-85992.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `crate::issue_85992_extern_2` + --> $DIR/issue-85992.rs:8:5 + | +LL | use crate::issue_85992_extern_2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `issue_85992_extern_2` in the root + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/inference/deref-suggestion.stderr b/tests/ui/inference/deref-suggestion.stderr index c58aab422..096989db0 100644 --- a/tests/ui/inference/deref-suggestion.stderr +++ b/tests/ui/inference/deref-suggestion.stderr @@ -84,15 +84,16 @@ LL | fn foo3(_: u32) {} | ^^^^ ------ error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:37:5 + --> $DIR/deref-suggestion.rs:37:22 | LL | assert_eq!(3i32, &3i32); - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected `i32`, found `&i32` - | expected because this is `i32` + | ^^^^^ expected `i32`, found `&i32` + | +help: consider removing the borrow + | +LL - assert_eq!(3i32, &3i32); +LL + assert_eq!(3i32, 3i32); | - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:40:17 diff --git a/tests/ui/inline-const/elided-lifetime-being-infer-vars.rs b/tests/ui/inline-const/elided-lifetime-being-infer-vars.rs new file mode 100644 index 000000000..5661db4a2 --- /dev/null +++ b/tests/ui/inline-const/elided-lifetime-being-infer-vars.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(inline_const)] + +fn main() { + let _my_usize = const { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }; +} diff --git a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs index 1a0104b85..6db2ebb97 100644 --- a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -391,7 +391,7 @@ fn main() { let _val = mem::zeroed::(); let _val = mem::uninitialized::>(); let _val = mem::uninitialized::<[!; 0]>(); - let _val = mem::uninitialized::<()>(); + let _val: () = mem::uninitialized::<()>(); let _val = mem::uninitialized::(); } } diff --git a/tests/ui/issue-94866.rs b/tests/ui/issue-94866.rs deleted file mode 100644 index c42034879..000000000 --- a/tests/ui/issue-94866.rs +++ /dev/null @@ -1,14 +0,0 @@ -macro_rules! m { - () => { - {} - }; -} - -enum Enum { A, B } - -fn main() { - match Enum::A { - //~^ ERROR non-exhaustive patterns - Enum::A => m!() - } -} diff --git a/tests/ui/issue-94866.stderr b/tests/ui/issue-94866.stderr deleted file mode 100644 index b3c17ce89..000000000 --- a/tests/ui/issue-94866.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0004]: non-exhaustive patterns: `Enum::B` not covered - --> $DIR/issue-94866.rs:10:11 - | -LL | match Enum::A { - | ^^^^^^^ pattern `Enum::B` not covered - | -note: `Enum` defined here - --> $DIR/issue-94866.rs:7:16 - | -LL | enum Enum { A, B } - | ---- ^ not covered - = note: the matched value is of type `Enum` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown - | -LL ~ Enum::A => m!(), -LL + Enum::B => todo!() - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/issues/issue-100605.stderr b/tests/ui/issues/issue-100605.stderr index be30eef2a..6f11f4475 100644 --- a/tests/ui/issues/issue-100605.stderr +++ b/tests/ui/issues/issue-100605.stderr @@ -13,10 +13,6 @@ note: function defined here | LL | fn takes_option(_arg: Option<&String>) {} | ^^^^^^^^^^^^ --------------------- -help: you can convert from `&Option` to `Option<&T>` using `.as_ref()` - | -LL | takes_option(None.as_ref()); - | ~~~~~~~~~~~~~ help: consider removing the borrow | LL - takes_option(&None); @@ -27,10 +23,8 @@ error[E0308]: mismatched types --> $DIR/issue-100605.rs:8:18 | LL | takes_option(&res); - | ------------ ^^^^ - | | | - | | expected `Option<&String>`, found `&Option` - | | help: you can convert from `&Option` to `Option<&T>` using `.as_ref()`: `res.as_ref()` + | ------------ ^^^^ expected `Option<&String>`, found `&Option` + | | | arguments to this function are incorrect | = note: expected enum `Option<&String>` @@ -40,6 +34,11 @@ note: function defined here | 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 diff --git a/tests/ui/issues/issue-11047.rs b/tests/ui/issues/issue-11047.rs index 1fb2b5bb3..7a4acea45 100644 --- a/tests/ui/issues/issue-11047.rs +++ b/tests/ui/issues/issue-11047.rs @@ -18,8 +18,8 @@ pub mod foo { fn main() { type Ham = foo::bar::baz::Qux; - let foo = foo::bar::baz::Qux::new(); // invoke directly - let bar = Ham::new(); // invoke via type alias + let foo: () = foo::bar::baz::Qux::new(); // invoke directly + let bar: () = Ham::new(); // invoke via type alias type StringVec = Vec; let sv = StringVec::new(); diff --git a/tests/ui/issues/issue-11680.stderr b/tests/ui/issues/issue-11680.stderr index ea224af8e..5bcf93de8 100644 --- a/tests/ui/issues/issue-11680.stderr +++ b/tests/ui/issues/issue-11680.stderr @@ -2,7 +2,9 @@ error[E0603]: enum `Foo` is private --> $DIR/issue-11680.rs:6:21 | LL | let _b = other::Foo::Bar(1); - | ^^^ private enum + | ^^^ --- tuple variant `Bar` is not publicly re-exported + | | + | private enum | note: the enum `Foo` is defined here --> $DIR/auxiliary/issue-11680.rs:1:1 @@ -14,7 +16,9 @@ error[E0603]: enum `Foo` is private --> $DIR/issue-11680.rs:9:27 | LL | let _b = other::test::Foo::Bar(1); - | ^^^ private enum + | ^^^ --- tuple variant `Bar` is not publicly re-exported + | | + | private enum | note: the enum `Foo` is defined here --> $DIR/auxiliary/issue-11680.rs:6:5 diff --git a/tests/ui/issues/issue-11709.rs b/tests/ui/issues/issue-11709.rs index 58424f9e4..2d6956649 100644 --- a/tests/ui/issues/issue-11709.rs +++ b/tests/ui/issues/issue-11709.rs @@ -10,7 +10,7 @@ struct S {x:()} fn test(slot: &mut Option Box>>) -> () { let a = slot.take(); - let _a = match a { + let _a: () = match a { // `{let .. a(); }` would break Some(mut a) => { let _a = a(); }, None => (), @@ -28,7 +28,7 @@ fn not(b: bool) -> bool { pub fn main() { // {} would break - let _r = {}; + let _r: () = {}; let mut slot = None; // `{ test(...); }` would break let _s : S = S{ x: { test(&mut slot); } }; diff --git a/tests/ui/issues/issue-11740.rs b/tests/ui/issues/issue-11740.rs index 9faeb7770..fa80f509b 100644 --- a/tests/ui/issues/issue-11740.rs +++ b/tests/ui/issues/issue-11740.rs @@ -24,5 +24,5 @@ impl Element { fn main() { let element = Element { attrs: Vec::new() }; - let _ = unsafe { element.get_attr("foo") }; + unsafe { let () = element.get_attr("foo"); }; } diff --git a/tests/ui/issues/issue-11771.stderr b/tests/ui/issues/issue-11771.stderr index 161fce4b0..b37140f60 100644 --- a/tests/ui/issues/issue-11771.stderr +++ b/tests/ui/issues/issue-11771.stderr @@ -6,14 +6,14 @@ LL | 1 + | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error[E0277]: cannot add `()` to `{integer}` @@ -24,14 +24,14 @@ LL | 1 + | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-12133-3.rs b/tests/ui/issues/issue-12133-3.rs index e6b16e2da..988b61e3b 100644 --- a/tests/ui/issues/issue-12133-3.rs +++ b/tests/ui/issues/issue-12133-3.rs @@ -4,7 +4,7 @@ // aux-build:issue-12133-dylib2.rs // ignore-emscripten no dylib support // ignore-musl -// ignore-sgx no dylib support +// needs-dynamic-linking // pretty-expanded FIXME #23616 diff --git a/tests/ui/issues/issue-1251.rs b/tests/ui/issues/issue-1251.rs deleted file mode 100644 index c2c047c79..000000000 --- a/tests/ui/issues/issue-1251.rs +++ /dev/null @@ -1,16 +0,0 @@ -// build-pass -#![allow(unused_attributes)] -#![allow(dead_code)] -// pretty-expanded FIXME #23616 -// ignore-wasm32-bare no libc to test ffi with -#![feature(rustc_private)] - -mod rustrt { - extern crate libc; - - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub fn main() {} diff --git a/tests/ui/issues/issue-1257.rs b/tests/ui/issues/issue-1257.rs deleted file mode 100644 index de5a6d359..000000000 --- a/tests/ui/issues/issue-1257.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main () { - let mut line = "".to_string(); - let mut i = 0; - while line != "exit".to_string() { - line = if i == 9 { "exit".to_string() } else { "notexit".to_string() }; - i += 1; - } -} diff --git a/tests/ui/issues/issue-13167.rs b/tests/ui/issues/issue-13167.rs index 8584c98de..9a9f129ec 100644 --- a/tests/ui/issues/issue-13167.rs +++ b/tests/ui/issues/issue-13167.rs @@ -1,5 +1,7 @@ // check-pass // pretty-expanded FIXME #23616 +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next use std::slice; diff --git a/tests/ui/issues/issue-1460.stderr b/tests/ui/issues/issue-1460.stderr index eb7661fad..d4a8c8955 100644 --- a/tests/ui/issues/issue-1460.stderr +++ b/tests/ui/issues/issue-1460.stderr @@ -1,8 +1,8 @@ warning: unused closure that must be used - --> $DIR/issue-1460.rs:6:5 + --> $DIR/issue-1460.rs:6:6 | LL | {|i: u32| if 1 == i { }}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ | = note: closures are lazy and do nothing unless called = note: `#[warn(unused_must_use)]` on by default diff --git a/tests/ui/issues/issue-15734.rs b/tests/ui/issues/issue-15734.rs index be5820606..27410d4c3 100644 --- a/tests/ui/issues/issue-15734.rs +++ b/tests/ui/issues/issue-15734.rs @@ -1,6 +1,6 @@ // run-pass -// If `Index` used an associated type for its output, this test would -// work more smoothly. +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next use std::ops::Index; diff --git a/tests/ui/issues/issue-16538.mir.stderr b/tests/ui/issues/issue-16538.mir.stderr deleted file mode 100644 index e320df4b7..000000000 --- a/tests/ui/issues/issue-16538.mir.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0015]: cannot call non-const fn `Y::foo` in statics - --> $DIR/issue-16538.rs:14:23 - | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell - -error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-16538.rs:14:30 - | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ^^^^ use of extern static - | - = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior - -error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-16538.rs:14:21 - | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer - | - = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0015, E0133. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/issues/issue-16538.rs b/tests/ui/issues/issue-16538.rs deleted file mode 100644 index 270fa3014..000000000 --- a/tests/ui/issues/issue-16538.rs +++ /dev/null @@ -1,19 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -mod Y { - pub type X = usize; - extern "C" { - pub static x: *const usize; - } - pub fn foo(value: *const X) -> *const X { - value - } -} - -static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); -//~^ ERROR dereference of raw pointer -//~| ERROR E0015 -//~| ERROR use of extern static is unsafe and requires - -fn main() {} diff --git a/tests/ui/issues/issue-16538.thir.stderr b/tests/ui/issues/issue-16538.thir.stderr deleted file mode 100644 index 4a8628692..000000000 --- a/tests/ui/issues/issue-16538.thir.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-16538.rs:14:22 - | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer - | - = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior - -error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-16538.rs:14:30 - | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ^^^^ use of extern static - | - = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior - -error[E0015]: cannot call non-const fn `Y::foo` in statics - --> $DIR/issue-16538.rs:14:23 - | -LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0015, E0133. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/issues/issue-17954.stderr b/tests/ui/issues/issue-17954.stderr index e08375fee..3e3706bcb 100644 --- a/tests/ui/issues/issue-17954.stderr +++ b/tests/ui/issues/issue-17954.stderr @@ -5,7 +5,7 @@ LL | let a = &FOO; | ^^^^ thread-local variables cannot be borrowed beyond the end of the function ... LL | } - | - end of enclosing function is here + | - end of enclosing function is here error: aborting due to previous error diff --git a/tests/ui/issues/issue-18389.rs b/tests/ui/issues/issue-18389.rs index 654dfb63b..05a5decf4 100644 --- a/tests/ui/issues/issue-18389.rs +++ b/tests/ui/issues/issue-18389.rs @@ -1,3 +1,10 @@ +#![feature(type_privacy_lints)] +#![warn(private_bounds)] + +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. + use std::any::Any; use std::any::TypeId; @@ -6,6 +13,7 @@ trait Private { } pub trait Public: Private< //~^ ERROR private trait `Private<::P, ::R>` in public interface +//~| WARNING trait `Private<::P, ::R>` is more private than the item `Public` ::P, ::R > { diff --git a/tests/ui/issues/issue-18389.stderr b/tests/ui/issues/issue-18389.stderr index 6ce78c45d..18ffc4177 100644 --- a/tests/ui/issues/issue-18389.stderr +++ b/tests/ui/issues/issue-18389.stderr @@ -1,16 +1,39 @@ error[E0445]: private trait `Private<::P, ::R>` in public interface - --> $DIR/issue-18389.rs:7:1 + --> $DIR/issue-18389.rs:14:1 | LL | trait Private { | ------------------- `Private<::P, ::R>` declared as private ... LL | / pub trait Public: Private< LL | | +LL | | LL | | ::P, LL | | ::R LL | | > { | |_^ can't leak private trait -error: aborting due to previous error +warning: trait `Private<::P, ::R>` is more private than the item `Public` + --> $DIR/issue-18389.rs:14:1 + | +LL | / pub trait Public: Private< +LL | | +LL | | +LL | | ::P, +LL | | ::R +LL | | > { + | |_^ trait `Public` is reachable at visibility `pub` + | +note: but trait `Private<::P, ::R>` is only usable at visibility `pub(crate)` + --> $DIR/issue-18389.rs:11:1 + | +LL | trait Private { + | ^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/issue-18389.rs:2:9 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0445`. diff --git a/tests/ui/issues/issue-1871.rs b/tests/ui/issues/issue-1871.rs deleted file mode 100644 index f7a2bdd56..000000000 --- a/tests/ui/issues/issue-1871.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Tests that we don't generate a spurious error about f.honk's type -// being undeterminable -fn main() { - let f = 42; - - let _g = if f < 5 { - f.honk() //~ ERROR no method named `honk` found - } - else { - () - }; -} diff --git a/tests/ui/issues/issue-1871.stderr b/tests/ui/issues/issue-1871.stderr deleted file mode 100644 index b774ca22d..000000000 --- a/tests/ui/issues/issue-1871.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0599]: no method named `honk` found for type `{integer}` in the current scope - --> $DIR/issue-1871.rs:7:9 - | -LL | f.honk() - | ^^^^ method not found in `{integer}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/issues/issue-20605.rs b/tests/ui/issues/issue-20605.rs deleted file mode 100644 index 17b7d32eb..000000000 --- a/tests/ui/issues/issue-20605.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn changer<'a>(mut things: Box>) { - for item in *things { *item = 0 } -//~^ ERROR the size for values of type -} - -fn main() {} diff --git a/tests/ui/issues/issue-20605.stderr b/tests/ui/issues/issue-20605.stderr deleted file mode 100644 index e1858b639..000000000 --- a/tests/ui/issues/issue-20605.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: the size for values of type `dyn Iterator` cannot be known at compilation time - --> $DIR/issue-20605.rs:2:17 - | -LL | for item in *things { *item = 0 } - | ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator` - | - = note: the trait bound `dyn Iterator: IntoIterator` is not satisfied - = note: required for `dyn Iterator` to implement `IntoIterator` -help: consider mutably borrowing here - | -LL | for item in &mut *things { *item = 0 } - | ++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-2063-resource.rs b/tests/ui/issues/issue-2063-resource.rs deleted file mode 100644 index 1d0527447..000000000 --- a/tests/ui/issues/issue-2063-resource.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check-pass -#![allow(dead_code)] -// test that autoderef of a type like this does not -// cause compiler to loop. Note that no instances -// of such a type could ever be constructed. - -struct S { - x: X, - to_str: (), -} - -struct X(Box); - -fn main() {} diff --git a/tests/ui/issues/issue-2063.rs b/tests/ui/issues/issue-2063.rs deleted file mode 100644 index f08f9d4cf..000000000 --- a/tests/ui/issues/issue-2063.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -// test that autoderef of a type like this does not -// cause compiler to loop. Note that no instances -// of such a type could ever be constructed. - -struct T(#[allow(unused_tuple_struct_fields)] Box); - -trait ToStr2 { - fn my_to_string(&self) -> String; -} - -impl ToStr2 for T { - fn my_to_string(&self) -> String { "t".to_string() } -} - -#[allow(dead_code)] -fn new_t(x: T) { - x.my_to_string(); -} - -fn main() { -} diff --git a/tests/ui/issues/issue-20644.rs b/tests/ui/issues/issue-20644.rs index 1b90727fb..a3a9ea740 100644 --- a/tests/ui/issues/issue-20644.rs +++ b/tests/ui/issues/issue-20644.rs @@ -26,7 +26,7 @@ fn foo() { let cwd = env::current_dir().unwrap(); let src = cwd.clone(); let summary = File::open(&src.join("SUMMARY.md")).unwrap(); - let _ = parse_summary(summary, &src); + parse_summary(summary, &src); } fn main() {} diff --git a/tests/ui/issues/issue-23808.rs b/tests/ui/issues/issue-23808.rs index 0988b09fc..b10682521 100644 --- a/tests/ui/issues/issue-23808.rs +++ b/tests/ui/issues/issue-23808.rs @@ -45,14 +45,14 @@ impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum); impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum); fn main() { - let _ = ConstStruct::C; - let _ = ConstEnum::C; + let () = ConstStruct::C; + let () = ConstEnum::C; StaticFnStruct::sfn(); StaticFnEnum::sfn(); - let _ = AliasConstStruct::C; - let _ = AliasConstEnum::C; + let () = AliasConstStruct::C; + let () = AliasConstEnum::C; AliasStaticFnStruct::sfn(); AliasStaticFnEnum::sfn(); diff --git a/tests/ui/issues/issue-24352.stderr b/tests/ui/issues/issue-24352.stderr index 1f51b6e29..f1c3891b8 100644 --- a/tests/ui/issues/issue-24352.stderr +++ b/tests/ui/issues/issue-24352.stderr @@ -6,10 +6,10 @@ LL | 1.0f64 - 1 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | 1.0f64 - 1.0 diff --git a/tests/ui/issues/issue-28822.rs b/tests/ui/issues/issue-28822.rs deleted file mode 100644 index 10e5d1dd0..000000000 --- a/tests/ui/issues/issue-28822.rs +++ /dev/null @@ -1,7 +0,0 @@ -// check-pass -#![allow(dead_code)] - -fn main() {} - -const fn size_ofs(_: usize) {} -const fn size_ofs2(_foo: usize) {} diff --git a/tests/ui/issues/issue-29798.rs b/tests/ui/issues/issue-29798.rs deleted file mode 100644 index 5eff5d191..000000000 --- a/tests/ui/issues/issue-29798.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-fail -// error-pattern:index out of bounds: the len is 5 but the index is 5 -// ignore-emscripten no processes - -const fn test(x: usize) -> i32 { - [42;5][x] -} - -fn main () { - let _ = test(5); -} diff --git a/tests/ui/issues/issue-3008-1.rs b/tests/ui/issues/issue-3008-1.rs deleted file mode 100644 index 1124969e6..000000000 --- a/tests/ui/issues/issue-3008-1.rs +++ /dev/null @@ -1,12 +0,0 @@ -enum Foo { - Foo_(Bar) -} - -enum Bar { - //~^ ERROR recursive type `Bar` has infinite size - BarNone, - BarSome(Bar) -} - -fn main() { -} diff --git a/tests/ui/issues/issue-3008-1.stderr b/tests/ui/issues/issue-3008-1.stderr deleted file mode 100644 index be25b9091..000000000 --- a/tests/ui/issues/issue-3008-1.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0072]: recursive type `Bar` has infinite size - --> $DIR/issue-3008-1.rs:5:1 - | -LL | enum Bar { - | ^^^^^^^^ -... -LL | BarSome(Bar) - | --- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | BarSome(Box) - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/issues/issue-3008-2.rs b/tests/ui/issues/issue-3008-2.rs deleted file mode 100644 index 5846c69da..000000000 --- a/tests/ui/issues/issue-3008-2.rs +++ /dev/null @@ -1,6 +0,0 @@ -enum Foo { Foo_(Bar) } -struct Bar { x: Bar } -//~^ ERROR E0072 - -fn main() { -} diff --git a/tests/ui/issues/issue-3008-2.stderr b/tests/ui/issues/issue-3008-2.stderr deleted file mode 100644 index 858a8fd6a..000000000 --- a/tests/ui/issues/issue-3008-2.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0072]: recursive type `Bar` has infinite size - --> $DIR/issue-3008-2.rs:2:1 - | -LL | struct Bar { x: Bar } - | ^^^^^^^^^^ --- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | struct Bar { x: Box } - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/issues/issue-3008-3.rs b/tests/ui/issues/issue-3008-3.rs deleted file mode 100644 index 212eb2eb8..000000000 --- a/tests/ui/issues/issue-3008-3.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::marker; - -enum E1 { V1(E2), } -enum E2 { V2(E2, marker::PhantomData), } -//~^ ERROR recursive type `E2` has infinite size - -impl E1 { fn foo(&self) {} } - -fn main() { -} diff --git a/tests/ui/issues/issue-3008-3.stderr b/tests/ui/issues/issue-3008-3.stderr deleted file mode 100644 index a1a81e293..000000000 --- a/tests/ui/issues/issue-3008-3.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0072]: recursive type `E2` has infinite size - --> $DIR/issue-3008-3.rs:4:1 - | -LL | enum E2 { V2(E2, marker::PhantomData), } - | ^^^^^^^^^^ ------ recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL | enum E2 { V2(Box>, marker::PhantomData), } - | ++++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/issues/issue-32709.stderr b/tests/ui/issues/issue-32709.stderr index a4ba5da4d..94e8f9295 100644 --- a/tests/ui/issues/issue-32709.stderr +++ b/tests/ui/issues/issue-32709.stderr @@ -8,6 +8,7 @@ LL | Err(5)?; | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From`: + <(T,) as From<[T; 1]>> <(T, T) as From<[T; 2]>> <(T, T, T) as From<[T; 3]>> <(T, T, T, T) as From<[T; 4]>> @@ -15,7 +16,6 @@ LL | Err(5)?; <(T, T, T, T, T, T) as From<[T; 6]>> <(T, T, T, T, T, T, T) as From<[T; 7]>> <(T, T, T, T, T, T, T, T) as From<[T; 8]>> - <(T, T, T, T, T, T, T, T, T) as From<[T; 9]>> and 4 others = note: required for `Result` to implement `FromResidual>` diff --git a/tests/ui/issues/issue-35570.rs b/tests/ui/issues/issue-35570.rs index a2b0222d4..42bdb423f 100644 --- a/tests/ui/issues/issue-35570.rs +++ b/tests/ui/issues/issue-35570.rs @@ -7,7 +7,6 @@ trait Trait2<'a> { fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { //~^ ERROR the trait bound `for<'a> (): Trait2<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> (): Trait2<'a>` is not satisfied let _e: (usize, usize) = unsafe{mem::transmute(param)}; } diff --git a/tests/ui/issues/issue-35570.stderr b/tests/ui/issues/issue-35570.stderr index 3dc33729d..2697d46bd 100644 --- a/tests/ui/issues/issue-35570.stderr +++ b/tests/ui/issues/issue-35570.stderr @@ -4,16 +4,6 @@ error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied LL | fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()` -error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied - --> $DIR/issue-35570.rs:8:1 - | -LL | / fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { -LL | | -LL | | -LL | | let _e: (usize, usize) = unsafe{mem::transmute(param)}; -LL | | } - | |_^ the trait `for<'a> Trait2<'a>` is not implemented for `()` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs index 50d1f166c..c109be005 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs @@ -1,5 +1,6 @@ // build-fail // normalize-stderr-test: ".nll/" -> "/" +// ignore-compare-mode-next-solver (hangs) trait Mirror { type Image; diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr index 5b8299fe8..87832dd29 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr @@ -1,11 +1,11 @@ error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse` - --> $DIR/issue-37311.rs:17:9 + --> $DIR/issue-37311.rs:18:9 | LL | (self, self).recurse(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `::recurse` defined here - --> $DIR/issue-37311.rs:16:5 + --> $DIR/issue-37311.rs:17:5 | LL | fn recurse(&self) { | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-3794.rs b/tests/ui/issues/issue-3794.rs deleted file mode 100644 index b1f028fbc..000000000 --- a/tests/ui/issues/issue-3794.rs +++ /dev/null @@ -1,32 +0,0 @@ -// run-pass -#![allow(dead_code)] - -trait T { - fn print(&self); -} - -#[derive(Debug)] -struct S { - s: isize, -} - -impl T for S { - fn print(&self) { - println!("{:?}", self); - } -} - -fn print_t(t: &dyn T) { - t.print(); -} - -fn print_s(s: &S) { - s.print(); -} - -pub fn main() { - let s: Box = Box::new(S { s: 5 }); - print_s(&*s); - let t: Box = s as Box; - print_t(&*t); -} diff --git a/tests/ui/issues/issue-50582.stderr b/tests/ui/issues/issue-50582.stderr index 3d527eb6b..9eafd7ab4 100644 --- a/tests/ui/issues/issue-50582.stderr +++ b/tests/ui/issues/issue-50582.stderr @@ -15,14 +15,14 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); | = help: the trait `Add<()>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-50689.rs b/tests/ui/issues/issue-50689.rs deleted file mode 100644 index b49f29500..000000000 --- a/tests/ui/issues/issue-50689.rs +++ /dev/null @@ -1,9 +0,0 @@ -// run-pass -#![allow(unused_variables)] -enum Foo { - Bar = (|x: i32| { }, 42).1, -} - -fn main() { - assert_eq!(Foo::Bar as usize, 42); -} diff --git a/tests/ui/issues/issue-50811.rs b/tests/ui/issues/issue-50811.rs index 683c85604..2a20e50fa 100644 --- a/tests/ui/issues/issue-50811.rs +++ b/tests/ui/issues/issue-50811.rs @@ -1,5 +1,6 @@ // run-pass #![feature(test)] +#![allow(invalid_nan_comparisons)] extern crate test; diff --git a/tests/ui/issues/issue-50825-1.rs b/tests/ui/issues/issue-50825-1.rs deleted file mode 100644 index ee4316029..000000000 --- a/tests/ui/issues/issue-50825-1.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -// regression test for issue #50825 -// Make sure that the `impl` bound (): X is preferred over -// the (): X bound in the where clause. - -trait X { - type T; -} - -trait Y: X { - fn foo(x: &Self::T); -} - -impl X for () { - type T = (); -} - -impl Y> for () where (): Y { - fn foo(_x: &()) {} -} - -fn main () {} diff --git a/tests/ui/issues/issue-50825.rs b/tests/ui/issues/issue-50825.rs deleted file mode 100644 index 1ece2e9fc..000000000 --- a/tests/ui/issues/issue-50825.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -// regression test for issue #50825 -// Make sure that the built-in bound {integer}: Sized is preferred over -// the u64: Sized bound in the where clause. - -fn foo(y: &[()]) -where - u64: Sized, -{ - y[0] -} - -fn main () { - foo(&[()]); -} diff --git a/tests/ui/issues/issue-51714.rs b/tests/ui/issues/issue-51714.rs index 8716524d6..03b50b796 100644 --- a/tests/ui/issues/issue-51714.rs +++ b/tests/ui/issues/issue-51714.rs @@ -1,9 +1,9 @@ fn main() { -//~^ NOTE: not the enclosing function body -//~| NOTE: not the enclosing function body -//~| NOTE: not the enclosing function body -//~| NOTE: not the enclosing function body - |_: [_; return || {}] | {}; + //~^ NOTE: not the enclosing function body + //~| NOTE: not the enclosing function body + //~| NOTE: not the enclosing function body + //~| NOTE: not the enclosing function body + |_: [_; return || {}]| {}; //~^ ERROR: return statement outside of function body [E0572] //~| NOTE: the return is part of this body... diff --git a/tests/ui/issues/issue-51714.stderr b/tests/ui/issues/issue-51714.stderr index 514d69c1c..e53e10afc 100644 --- a/tests/ui/issues/issue-51714.stderr +++ b/tests/ui/issues/issue-51714.stderr @@ -1,13 +1,13 @@ error[E0572]: return statement outside of function body - --> $DIR/issue-51714.rs:6:14 + --> $DIR/issue-51714.rs:6:13 | LL | / fn main() { LL | | LL | | LL | | LL | | -LL | | |_: [_; return || {}] | {}; - | | ^^^^^^^^^^^^ the return is part of this body... +LL | | |_: [_; return || {}]| {}; + | | ^^^^^^^^^^^^ the return is part of this body... ... | LL | | LL | | } diff --git a/tests/ui/issues/issue-52049.stderr b/tests/ui/issues/issue-52049.stderr index b25dbd1cb..0812976cf 100644 --- a/tests/ui/issues/issue-52049.stderr +++ b/tests/ui/issues/issue-52049.stderr @@ -2,12 +2,10 @@ error[E0716]: temporary value dropped while borrowed --> $DIR/issue-52049.rs:6:10 | LL | foo(&unpromotable(5u32)); - | -----^^^^^^^^^^^^^^^^^^- + | -----^^^^^^^^^^^^^^^^^^-- temporary value is freed at the end of this statement | | | | | creates a temporary value which is freed while still in use | argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement error: aborting due to previous error diff --git a/tests/ui/issues/issue-5439.stderr b/tests/ui/issues/issue-5439.stderr index dc8f8b878..a91e4b31f 100644 --- a/tests/ui/issues/issue-5439.stderr +++ b/tests/ui/issues/issue-5439.stderr @@ -4,7 +4,7 @@ error[E0560]: struct `Foo` has no field named `nonexistent` LL | return Box::new(Foo { nonexistent: self, foo: i }); | ^^^^^^^^^^^ `Foo` does not have this field | - = note: available fields are: `foo` + = note: all struct fields are already assigned error: aborting due to previous error diff --git a/tests/ui/issues/issue-5883.rs b/tests/ui/issues/issue-5883.rs index 82866b355..f9dd2c54d 100644 --- a/tests/ui/issues/issue-5883.rs +++ b/tests/ui/issues/issue-5883.rs @@ -6,7 +6,7 @@ struct Struct { fn new_struct( r: dyn A + 'static //~ ERROR the size for values of type -) -> Struct { //~ ERROR the size for values of type +) -> Struct { Struct { r: r } } diff --git a/tests/ui/issues/issue-5883.stderr b/tests/ui/issues/issue-5883.stderr index ffff403e0..a3e2531b5 100644 --- a/tests/ui/issues/issue-5883.stderr +++ b/tests/ui/issues/issue-5883.stderr @@ -15,22 +15,6 @@ help: function arguments must have a statically known size, borrowed types alway LL | r: &dyn A + 'static | + -error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:9:6 - | -LL | ) -> Struct { - | ^^^^^^ doesn't have a size known at compile-time -LL | Struct { r: r } - | --------------- this returned value is of type `Struct` - | - = help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)` -note: required because it appears within the type `Struct` - --> $DIR/issue-5883.rs:3:8 - | -LL | struct Struct { - | ^^^^^^ - = note: the return type of a function must have a statically known size - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-67552.rs b/tests/ui/issues/issue-67552.rs index ec1997ccd..7336b873d 100644 --- a/tests/ui/issues/issue-67552.rs +++ b/tests/ui/issues/issue-67552.rs @@ -1,6 +1,7 @@ // build-fail // compile-flags: -Copt-level=0 // normalize-stderr-test: ".nll/" -> "/" +// ignore-compare-mode-next-solver (hangs) fn main() { rec(Empty); diff --git a/tests/ui/issues/issue-67552.stderr b/tests/ui/issues/issue-67552.stderr index 4746f918b..f93ed67da 100644 --- a/tests/ui/issues/issue-67552.stderr +++ b/tests/ui/issues/issue-67552.stderr @@ -1,11 +1,11 @@ error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` - --> $DIR/issue-67552.rs:29:9 + --> $DIR/issue-67552.rs:30:9 | LL | rec(identity(&mut it)) | ^^^^^^^^^^^^^^^^^^^^^^ | note: `rec` defined here - --> $DIR/issue-67552.rs:22:1 + --> $DIR/issue-67552.rs:23:1 | LL | / fn rec(mut it: T) LL | | where diff --git a/tests/ui/issues/issue-78115.rs b/tests/ui/issues/issue-78115.rs deleted file mode 100644 index ac18470c6..000000000 --- a/tests/ui/issues/issue-78115.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Regression test for issue #78115: "ICE: variable should be placed in scope earlier" - -// check-pass -// edition:2018 - -#[allow(dead_code)] -struct Foo { - a: () -} - -async fn _bar() { - let foo = Foo { a: () }; - match foo { - Foo { a: _a } | Foo { a: _a } if true => {} - _ => {} - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-85461.rs b/tests/ui/issues/issue-85461.rs index 965510887..092105df2 100644 --- a/tests/ui/issues/issue-85461.rs +++ b/tests/ui/issues/issue-85461.rs @@ -1,6 +1,7 @@ // compile-flags: -Cinstrument-coverage -Ccodegen-units=4 --crate-type dylib -Copt-level=0 // build-pass // needs-profiler-support +// needs-dynamic-linking // Regression test for #85461 where MSVC sometimes fails to link instrument-coverage binaries // with dead code and #[inline(always)]. diff --git a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr index 3cb5e44c7..7f1b9c38e 100644 --- a/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr +++ b/tests/ui/iterators/invalid-iterator-chain-with-int-infer.stderr @@ -6,8 +6,8 @@ LL | let x = Some(()).iter().map(|()| 1).sum::(); | = help: the trait `Sum<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain-with-int-infer.rs:2:29 | diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr index f3dceca7e..a2688107d 100644 --- a/tests/ui/iterators/invalid-iterator-chain.stderr +++ b/tests/ui/iterators/invalid-iterator-chain.stderr @@ -24,8 +24,8 @@ LL | println!("{}", scores.sum::()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:12:10 | @@ -49,8 +49,8 @@ LL | .sum::(), | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:25:14 | @@ -81,8 +81,8 @@ LL | .sum::(), | = help: the trait `Sum` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:33:14 | @@ -109,8 +109,8 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::()); | = help: the trait `Sum<()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:38:38 | @@ -130,8 +130,8 @@ LL | println!("{}", vec![(), ()].iter().sum::()); | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:39:33 | diff --git a/tests/ui/iterators/issue-58952-filter-type-length.rs b/tests/ui/iterators/issue-58952-filter-type-length.rs index 6d12db8d1..8e9cc84ec 100644 --- a/tests/ui/iterators/issue-58952-filter-type-length.rs +++ b/tests/ui/iterators/issue-58952-filter-type-length.rs @@ -1,4 +1,6 @@ // run-pass +// ignore-compare-mode-next-solver (hangs) + //! This snippet causes the type length to blowup exponentially, //! so check that we don't accidentally exceed the type length limit. // FIXME: Once the size of iterator adaptors is further reduced, diff --git a/tests/ui/layout/cannot-transmute-unnormalizable-type.rs b/tests/ui/layout/cannot-transmute-unnormalizable-type.rs new file mode 100644 index 000000000..d2b6e1d8e --- /dev/null +++ b/tests/ui/layout/cannot-transmute-unnormalizable-type.rs @@ -0,0 +1,22 @@ +trait Trait { + type RefTarget; +} + +impl Trait for () +where + Missing: Trait, + //~^ ERROR cannot find type `Missing` in this scope +{ + type RefTarget = (); +} + +struct Other { + data: <() as Trait>::RefTarget, +} + +fn main() { + unsafe { + std::mem::transmute::, Option<&Other>>(None); + //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types + } +} diff --git a/tests/ui/layout/cannot-transmute-unnormalizable-type.stderr b/tests/ui/layout/cannot-transmute-unnormalizable-type.stderr new file mode 100644 index 000000000..dd5119318 --- /dev/null +++ b/tests/ui/layout/cannot-transmute-unnormalizable-type.stderr @@ -0,0 +1,19 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/cannot-transmute-unnormalizable-type.rs:7:5 + | +LL | Missing: Trait, + | ^^^^^^^ not found in this scope + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/cannot-transmute-unnormalizable-type.rs:19:9 + | +LL | std::mem::transmute::, Option<&Other>>(None); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `Option<()>` (8 bits) + = note: target type: `Option<&Other>` (unable to determine layout for `Other` because `<() as Trait>::RefTarget` cannot be normalized) + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0412, E0512. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/let-else/let-else-ref-bindings.stderr b/tests/ui/let-else/let-else-ref-bindings.stderr index ada1805e7..0886d7f17 100644 --- a/tests/ui/let-else/let-else-ref-bindings.stderr +++ b/tests/ui/let-else/let-else-ref-bindings.stderr @@ -6,6 +6,10 @@ LL | let Some(ref a): Option<&[u8]> = some else { return }; | = note: expected enum `Option<&[u8]>` found enum `Option>` +help: try using `.as_deref()` to convert `Option>` to `Option<&[u8]>` + | +LL | let Some(ref a): Option<&[u8]> = some.as_deref() else { return }; + | +++++++++++ error[E0308]: mismatched types --> $DIR/let-else-ref-bindings.rs:20:38 @@ -15,6 +19,11 @@ LL | let Some(ref a): Option<&[u8]> = &some else { return }; | = note: expected enum `Option<&[u8]>` found reference `&Option>` +help: try using `.as_deref()` to convert `&Option>` to `Option<&[u8]>` + | +LL - let Some(ref a): Option<&[u8]> = &some else { return }; +LL + let Some(ref a): Option<&[u8]> = some.as_deref() else { return }; + | error[E0308]: mismatched types --> $DIR/let-else-ref-bindings.rs:24:34 @@ -26,6 +35,10 @@ LL | let Some(a): Option<&[u8]> = some else { return }; | = note: expected enum `Option<&[u8]>` found enum `Option>` +help: try using `.as_deref()` to convert `Option>` to `Option<&[u8]>` + | +LL | let Some(a): Option<&[u8]> = some.as_deref() else { return }; + | +++++++++++ error[E0308]: mismatched types --> $DIR/let-else-ref-bindings.rs:27:34 @@ -37,6 +50,11 @@ LL | let Some(a): Option<&[u8]> = &some else { return }; | = note: expected enum `Option<&[u8]>` found reference `&Option>` +help: try using `.as_deref()` to convert `&Option>` to `Option<&[u8]>` + | +LL - let Some(a): Option<&[u8]> = &some else { return }; +LL + let Some(a): Option<&[u8]> = some.as_deref() else { return }; + | error[E0308]: mismatched types --> $DIR/let-else-ref-bindings.rs:44:46 diff --git a/tests/ui/lexer/lex-bad-char-literals-1.stderr b/tests/ui/lexer/lex-bad-char-literals-1.stderr index e6ff1f662..9dc0a3380 100644 --- a/tests/ui/lexer/lex-bad-char-literals-1.stderr +++ b/tests/ui/lexer/lex-bad-char-literals-1.stderr @@ -16,7 +16,7 @@ error: unknown character escape: `\u{25cf}` LL | '\●' | ^ unknown character escape | - = help: for more information, visit + = help: for more information, visit help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal | LL | r"\●" @@ -28,7 +28,7 @@ error: unknown character escape: `\u{25cf}` LL | "\●" | ^ unknown character escape | - = help: for more information, visit + = help: for more information, visit help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal | LL | r"\●" diff --git a/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr b/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr index 3602de8dd..598f14241 100644 --- a/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr +++ b/tests/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr @@ -10,7 +10,7 @@ LL | let read = &refcell as &RefCell; | -------- cast requires that `foo` is borrowed for `'static` ... LL | } - | - `foo` dropped here while still borrowed + | - `foo` dropped here while still borrowed error: lifetime may not live long enough --> $DIR/issue-90600-expected-return-static-indirect.rs:9:16 diff --git a/tests/ui/limits/huge-array-simple-32.rs b/tests/ui/limits/huge-array-simple-32.rs index 2290e3d5e..f25b88874 100644 --- a/tests/ui/limits/huge-array-simple-32.rs +++ b/tests/ui/limits/huge-array-simple-32.rs @@ -1,9 +1,6 @@ // ignore-64bit // build-fail -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" #![allow(arithmetic_overflow)] fn main() { diff --git a/tests/ui/limits/huge-array-simple-32.stderr b/tests/ui/limits/huge-array-simple-32.stderr index 31e120df6..d1e4e6295 100644 --- a/tests/ui/limits/huge-array-simple-32.stderr +++ b/tests/ui/limits/huge-array-simple-32.stderr @@ -1,5 +1,5 @@ error: values of the type `[u8; 2147516416]` are too big for the current architecture - --> $DIR/huge-array-simple-32.rs:10:9 + --> $DIR/huge-array-simple-32.rs:7:9 | LL | let _fat: [u8; (1<<31)+(1<<15)] = | ^^^^ diff --git a/tests/ui/limits/huge-array-simple-64.rs b/tests/ui/limits/huge-array-simple-64.rs index 02c961fc5..c5778c428 100644 --- a/tests/ui/limits/huge-array-simple-64.rs +++ b/tests/ui/limits/huge-array-simple-64.rs @@ -1,9 +1,6 @@ // build-fail // ignore-32bit -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" #![allow(arithmetic_overflow)] fn main() { diff --git a/tests/ui/limits/huge-array-simple-64.stderr b/tests/ui/limits/huge-array-simple-64.stderr index c5d3fe85d..5791b6439 100644 --- a/tests/ui/limits/huge-array-simple-64.stderr +++ b/tests/ui/limits/huge-array-simple-64.stderr @@ -1,5 +1,5 @@ error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture - --> $DIR/huge-array-simple-64.rs:10:9 + --> $DIR/huge-array-simple-64.rs:7:9 | LL | let _fat: [u8; (1<<61)+(1<<31)] = | ^^^^ diff --git a/tests/ui/limits/huge-array.rs b/tests/ui/limits/huge-array.rs index 3070801f8..811cf25dd 100644 --- a/tests/ui/limits/huge-array.rs +++ b/tests/ui/limits/huge-array.rs @@ -1,8 +1,4 @@ -// FIXME https://github.com/rust-lang/rust/issues/59774 - // build-fail -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" fn generic(t: T) { let s: [T; 1518600000] = [t; 1518600000]; diff --git a/tests/ui/limits/huge-array.stderr b/tests/ui/limits/huge-array.stderr index 817458b73..24adb33b0 100644 --- a/tests/ui/limits/huge-array.stderr +++ b/tests/ui/limits/huge-array.stderr @@ -1,5 +1,5 @@ error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the current architecture - --> $DIR/huge-array.rs:8:9 + --> $DIR/huge-array.rs:4:9 | LL | let s: [T; 1518600000] = [t; 1518600000]; | ^ diff --git a/tests/ui/limits/huge-enum.rs b/tests/ui/limits/huge-enum.rs index 39ea6e11b..dd4bae60d 100644 --- a/tests/ui/limits/huge-enum.rs +++ b/tests/ui/limits/huge-enum.rs @@ -2,10 +2,6 @@ // normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE" // normalize-stderr-test "\[u32; \d+\]" -> "TYPE" -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" - #[cfg(target_pointer_width = "32")] type BIG = Option<[u32; (1<<29)-1]>; diff --git a/tests/ui/limits/huge-enum.stderr b/tests/ui/limits/huge-enum.stderr index a1456e1a8..5e2bda9be 100644 --- a/tests/ui/limits/huge-enum.stderr +++ b/tests/ui/limits/huge-enum.stderr @@ -1,5 +1,5 @@ error: values of the type `Option` are too big for the current architecture - --> $DIR/huge-enum.rs:16:9 + --> $DIR/huge-enum.rs:12:9 | LL | let big: BIG = None; | ^^^ diff --git a/tests/ui/limits/huge-struct.rs b/tests/ui/limits/huge-struct.rs index 02f38d860..904e2774b 100644 --- a/tests/ui/limits/huge-struct.rs +++ b/tests/ui/limits/huge-struct.rs @@ -3,10 +3,6 @@ // normalize-stderr-test "S1M" -> "SXX" // error-pattern: too big for the current -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" - struct S32 { v0: T, v1: T, diff --git a/tests/ui/limits/huge-struct.stderr b/tests/ui/limits/huge-struct.stderr index f0ee88e59..ce14bc5b8 100644 --- a/tests/ui/limits/huge-struct.stderr +++ b/tests/ui/limits/huge-struct.stderr @@ -1,5 +1,5 @@ error: values of the type `SXX>>` are too big for the current architecture - --> $DIR/huge-struct.rs:50:9 + --> $DIR/huge-struct.rs:46:9 | LL | let fat: Option>>> = None; | ^^^ diff --git a/tests/ui/limits/issue-15919-32.rs b/tests/ui/limits/issue-15919-32.rs index 3c93f14cc..3254cb2c5 100644 --- a/tests/ui/limits/issue-15919-32.rs +++ b/tests/ui/limits/issue-15919-32.rs @@ -1,10 +1,6 @@ // ignore-64bit // build-fail -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" - fn main() { let x = [0usize; 0xffff_ffff]; //~ ERROR too big } diff --git a/tests/ui/limits/issue-15919-32.stderr b/tests/ui/limits/issue-15919-32.stderr index 0d79fc0c7..f9e48a52c 100644 --- a/tests/ui/limits/issue-15919-32.stderr +++ b/tests/ui/limits/issue-15919-32.stderr @@ -1,5 +1,5 @@ error: values of the type `[usize; usize::MAX]` are too big for the current architecture - --> $DIR/issue-15919-32.rs:9:9 + --> $DIR/issue-15919-32.rs:5:9 | LL | let x = [0usize; 0xffff_ffff]; | ^ diff --git a/tests/ui/limits/issue-15919-64.rs b/tests/ui/limits/issue-15919-64.rs index 3ecbd34ea..272e8800d 100644 --- a/tests/ui/limits/issue-15919-64.rs +++ b/tests/ui/limits/issue-15919-64.rs @@ -1,10 +1,6 @@ // build-fail // ignore-32bit -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" - fn main() { let x = [0usize; 0xffff_ffff_ffff_ffff]; //~ ERROR too big } diff --git a/tests/ui/limits/issue-15919-64.stderr b/tests/ui/limits/issue-15919-64.stderr index 3399d644e..167272890 100644 --- a/tests/ui/limits/issue-15919-64.stderr +++ b/tests/ui/limits/issue-15919-64.stderr @@ -1,5 +1,5 @@ error: values of the type `[usize; usize::MAX]` are too big for the current architecture - --> $DIR/issue-15919-64.rs:9:9 + --> $DIR/issue-15919-64.rs:5:9 | LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; | ^ diff --git a/tests/ui/limits/issue-17913.rs b/tests/ui/limits/issue-17913.rs index 56cf5d831..6b37d6f05 100644 --- a/tests/ui/limits/issue-17913.rs +++ b/tests/ui/limits/issue-17913.rs @@ -2,10 +2,6 @@ // normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; usize::MAX]" // error-pattern: too big for the current architecture -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" - #[cfg(target_pointer_width = "64")] fn main() { let n = 0_usize; diff --git a/tests/ui/limits/issue-56762.rs b/tests/ui/limits/issue-56762.rs index fb0a270f1..ed7ee4da8 100644 --- a/tests/ui/limits/issue-56762.rs +++ b/tests/ui/limits/issue-56762.rs @@ -1,8 +1,5 @@ // only-x86_64 -// FIXME https://github.com/rust-lang/rust/issues/59774 -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" const HUGE_SIZE: usize = !0usize / 8; diff --git a/tests/ui/limits/issue-56762.stderr b/tests/ui/limits/issue-56762.stderr index e6b9c6762..29f2a8859 100644 --- a/tests/ui/limits/issue-56762.stderr +++ b/tests/ui/limits/issue-56762.stderr @@ -1,11 +1,11 @@ error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture - --> $DIR/issue-56762.rs:19:1 + --> $DIR/issue-56762.rs:16:1 | LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture - --> $DIR/issue-56762.rs:21:1 + --> $DIR/issue-56762.rs:18:1 | LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/linkage-attr/incompatible-flavor.rs b/tests/ui/linkage-attr/incompatible-flavor.rs new file mode 100644 index 000000000..90c2b612f --- /dev/null +++ b/tests/ui/linkage-attr/incompatible-flavor.rs @@ -0,0 +1,6 @@ +// compile-flags: --target=x86_64-unknown-linux-gnu -C linker-flavor=msvc --crate-type=rlib +// error-pattern: linker flavor `msvc` is incompatible with the current target +// needs-llvm-components: + +#![feature(no_core)] +#![no_core] diff --git a/tests/ui/linkage-attr/incompatible-flavor.stderr b/tests/ui/linkage-attr/incompatible-flavor.stderr new file mode 100644 index 000000000..aabdd14b6 --- /dev/null +++ b/tests/ui/linkage-attr/incompatible-flavor.stderr @@ -0,0 +1,6 @@ +error: linker flavor `msvc` is incompatible with the current target + | + = note: compatible flavors are: gnu, gnu-lld, gnu-cc, gnu-lld-cc, gcc, ld, ld.lld + +error: aborting due to previous error + diff --git a/tests/ui/linkage-attr/issue-10755.rs b/tests/ui/linkage-attr/issue-10755.rs index afd2dc46c..0df5d842c 100644 --- a/tests/ui/linkage-attr/issue-10755.rs +++ b/tests/ui/linkage-attr/issue-10755.rs @@ -1,6 +1,6 @@ // build-fail // dont-check-compiler-stderr -// compile-flags: -C linker=llllll -C linker-flavor=ld +// compile-flags: -C linker=llllll // error-pattern: `llllll` // Before, the error-pattern checked for "not found". On WSL with appendWindowsPath=true, running diff --git a/tests/ui/linkage-attr/linkage3.rs b/tests/ui/linkage-attr/linkage3.rs index 112eb1d3b..cac10af63 100644 --- a/tests/ui/linkage-attr/linkage3.rs +++ b/tests/ui/linkage-attr/linkage3.rs @@ -1,8 +1,4 @@ -// FIXME https://github.com/rust-lang/rust/issues/59774 - // check-fail -// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> "" -// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" #![feature(linkage)] diff --git a/tests/ui/linkage-attr/linkage3.stderr b/tests/ui/linkage-attr/linkage3.stderr index f2579c6e8..dbb5880ab 100644 --- a/tests/ui/linkage-attr/linkage3.stderr +++ b/tests/ui/linkage-attr/linkage3.stderr @@ -1,5 +1,5 @@ error: invalid linkage specified - --> $DIR/linkage3.rs:11:5 + --> $DIR/linkage3.rs:7:5 | LL | static foo: *const i32; | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/linkage-attr/unstable-flavor.bpf.stderr b/tests/ui/linkage-attr/unstable-flavor.bpf.stderr new file mode 100644 index 000000000..594a46176 --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.bpf.stderr @@ -0,0 +1,2 @@ +error: the linker flavor `bpf-linker` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values + diff --git a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr new file mode 100644 index 000000000..714c09df5 --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr @@ -0,0 +1,2 @@ +error: the linker flavor `ptx-linker` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values + diff --git a/tests/ui/linkage-attr/unstable-flavor.rs b/tests/ui/linkage-attr/unstable-flavor.rs new file mode 100644 index 000000000..b58fd055f --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.rs @@ -0,0 +1,14 @@ +// Even though this test only checks 2 of the 10 or so unstable linker flavors, it exercizes the +// unique codepath checking all unstable options (see `LinkerFlavorCli::is_unstable` and its +// caller). If it passes, all the other unstable options are rejected as well. +// +// revisions: bpf ptx +// [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf-linker --crate-type=rlib +// [bpf] error-pattern: linker flavor `bpf-linker` is unstable, the `-Z unstable-options` flag +// [bpf] needs-llvm-components: +// [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx-linker --crate-type=rlib +// [ptx] error-pattern: linker flavor `ptx-linker` is unstable, the `-Z unstable-options` flag +// [ptx] needs-llvm-components: + +#![feature(no_core)] +#![no_core] diff --git a/tests/ui/lint/invalid-nan-comparison-suggestion.fixed b/tests/ui/lint/invalid-nan-comparison-suggestion.fixed new file mode 100644 index 000000000..feafc6c1b --- /dev/null +++ b/tests/ui/lint/invalid-nan-comparison-suggestion.fixed @@ -0,0 +1,36 @@ +// check-pass +// run-rustfix + +fn main() { + let x = 5f32; + let _ = x.is_nan(); + //~^ WARN incorrect NaN comparison + let _ = !x.is_nan(); + //~^ WARN incorrect NaN comparison + + let x = 5f64; + let _ = x.is_nan(); + //~^ WARN incorrect NaN comparison + let _ = !x.is_nan(); + //~^ WARN incorrect NaN comparison + + let b = &2.3f32; + if !b.is_nan() {} + //~^ WARN incorrect NaN comparison + + let b = &2.3f32; + if !b.is_nan() {} + //~^ WARN incorrect NaN comparison + + let _ = + !b.is_nan(); + + #[allow(unused_macros)] + macro_rules! nan { () => { f32::NAN }; } + macro_rules! number { () => { 5f32 }; } + + let _ = number!().is_nan(); + //~^ WARN incorrect NaN comparison + let _ = !number!().is_nan(); + //~^ WARN incorrect NaN comparison +} diff --git a/tests/ui/lint/invalid-nan-comparison-suggestion.rs b/tests/ui/lint/invalid-nan-comparison-suggestion.rs new file mode 100644 index 000000000..ad5eb66e5 --- /dev/null +++ b/tests/ui/lint/invalid-nan-comparison-suggestion.rs @@ -0,0 +1,39 @@ +// check-pass +// run-rustfix + +fn main() { + let x = 5f32; + let _ = x == f32::NAN; + //~^ WARN incorrect NaN comparison + let _ = x != f32::NAN; + //~^ WARN incorrect NaN comparison + + let x = 5f64; + let _ = x == f64::NAN; + //~^ WARN incorrect NaN comparison + let _ = x != f64::NAN; + //~^ WARN incorrect NaN comparison + + let b = &2.3f32; + if b != &f32::NAN {} + //~^ WARN incorrect NaN comparison + + let b = &2.3f32; + if b != { &f32::NAN } {} + //~^ WARN incorrect NaN comparison + + let _ = + b != { + //~^ WARN incorrect NaN comparison + &f32::NAN + }; + + #[allow(unused_macros)] + macro_rules! nan { () => { f32::NAN }; } + macro_rules! number { () => { 5f32 }; } + + let _ = nan!() == number!(); + //~^ WARN incorrect NaN comparison + let _ = number!() != nan!(); + //~^ WARN incorrect NaN comparison +} diff --git a/tests/ui/lint/invalid-nan-comparison-suggestion.stderr b/tests/ui/lint/invalid-nan-comparison-suggestion.stderr new file mode 100644 index 000000000..c310341de --- /dev/null +++ b/tests/ui/lint/invalid-nan-comparison-suggestion.stderr @@ -0,0 +1,114 @@ +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:6:13 + | +LL | let _ = x == f32::NAN; + | ^^^^^^^^^^^^^ + | + = note: `#[warn(invalid_nan_comparisons)]` on by default +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - let _ = x == f32::NAN; +LL + let _ = x.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:8:13 + | +LL | let _ = x != f32::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - let _ = x != f32::NAN; +LL + let _ = !x.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:12:13 + | +LL | let _ = x == f64::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - let _ = x == f64::NAN; +LL + let _ = x.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:14:13 + | +LL | let _ = x != f64::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - let _ = x != f64::NAN; +LL + let _ = !x.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:18:8 + | +LL | if b != &f32::NAN {} + | ^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - if b != &f32::NAN {} +LL + if !b.is_nan() {} + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:22:8 + | +LL | if b != { &f32::NAN } {} + | ^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - if b != { &f32::NAN } {} +LL + if !b.is_nan() {} + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:26:9 + | +LL | / b != { +LL | | +LL | | &f32::NAN +LL | | }; + | |_________^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - b != { +LL + !b.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:35:13 + | +LL | let _ = nan!() == number!(); + | ^^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - let _ = nan!() == number!(); +LL + let _ = number!().is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison-suggestion.rs:37:13 + | +LL | let _ = number!() != nan!(); + | ^^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - let _ = number!() != nan!(); +LL + let _ = !number!().is_nan(); + | + +warning: 9 warnings emitted + diff --git a/tests/ui/lint/invalid-nan-comparison.rs b/tests/ui/lint/invalid-nan-comparison.rs new file mode 100644 index 000000000..d7e793ca5 --- /dev/null +++ b/tests/ui/lint/invalid-nan-comparison.rs @@ -0,0 +1,51 @@ +// check-pass + +fn main() { + f32(); + f64(); +} + +const TEST: bool = 5f32 == f32::NAN; +//~^ WARN incorrect NaN comparison + +fn f32() { + macro_rules! number { () => { 5f32 }; } + let x = number!(); + x == f32::NAN; + //~^ WARN incorrect NaN comparison + x != f32::NAN; + //~^ WARN incorrect NaN comparison + x < f32::NAN; + //~^ WARN incorrect NaN comparison + x > f32::NAN; + //~^ WARN incorrect NaN comparison + x <= f32::NAN; + //~^ WARN incorrect NaN comparison + x >= f32::NAN; + //~^ WARN incorrect NaN comparison + number!() == f32::NAN; + //~^ WARN incorrect NaN comparison + f32::NAN != number!(); + //~^ WARN incorrect NaN comparison +} + +fn f64() { + macro_rules! number { () => { 5f64 }; } + let x = number!(); + x == f64::NAN; + //~^ WARN incorrect NaN comparison + x != f64::NAN; + //~^ WARN incorrect NaN comparison + x < f64::NAN; + //~^ WARN incorrect NaN comparison + x > f64::NAN; + //~^ WARN incorrect NaN comparison + x <= f64::NAN; + //~^ WARN incorrect NaN comparison + x >= f64::NAN; + //~^ WARN incorrect NaN comparison + number!() == f64::NAN; + //~^ WARN incorrect NaN comparison + f64::NAN != number!(); + //~^ WARN incorrect NaN comparison +} diff --git a/tests/ui/lint/invalid-nan-comparison.stderr b/tests/ui/lint/invalid-nan-comparison.stderr new file mode 100644 index 000000000..054c06d38 --- /dev/null +++ b/tests/ui/lint/invalid-nan-comparison.stderr @@ -0,0 +1,159 @@ +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:8:20 + | +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 + | +LL | x == f32::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - x == f32::NAN; +LL + x.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:16:5 + | +LL | x != f32::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - x != f32::NAN; +LL + !x.is_nan(); + | + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:18:5 + | +LL | x < f32::NAN; + | ^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:20:5 + | +LL | x > f32::NAN; + | ^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:22:5 + | +LL | x <= f32::NAN; + | ^^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:24:5 + | +LL | x >= f32::NAN; + | ^^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:26:5 + | +LL | number!() == f32::NAN; + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - number!() == f32::NAN; +LL + number!().is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:28:5 + | +LL | f32::NAN != number!(); + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - f32::NAN != number!(); +LL + !number!().is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:35:5 + | +LL | x == f64::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - x == f64::NAN; +LL + x.is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:37:5 + | +LL | x != f64::NAN; + | ^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - x != f64::NAN; +LL + !x.is_nan(); + | + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:39:5 + | +LL | x < f64::NAN; + | ^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:41:5 + | +LL | x > f64::NAN; + | ^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:43:5 + | +LL | x <= f64::NAN; + | ^^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN is not orderable + --> $DIR/invalid-nan-comparison.rs:45:5 + | +LL | x >= f64::NAN; + | ^^^^^^^^^^^^^ + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:47:5 + | +LL | number!() == f64::NAN; + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - number!() == f64::NAN; +LL + number!().is_nan(); + | + +warning: incorrect NaN comparison, NaN cannot be directly compared to itself + --> $DIR/invalid-nan-comparison.rs:49:5 + | +LL | f64::NAN != number!(); + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: use `f32::is_nan()` or `f64::is_nan()` instead + | +LL - f64::NAN != number!(); +LL + !number!().is_nan(); + | + +warning: 17 warnings emitted + diff --git a/tests/ui/lint/invalid_from_utf8.rs b/tests/ui/lint/invalid_from_utf8.rs new file mode 100644 index 000000000..9c8c63681 --- /dev/null +++ b/tests/ui/lint/invalid_from_utf8.rs @@ -0,0 +1,93 @@ +// check-pass + +#![feature(concat_bytes)] +#![warn(invalid_from_utf8_unchecked)] +#![warn(invalid_from_utf8)] + +pub fn from_utf8_unchecked_mut() { + // Valid + unsafe { + std::str::from_utf8_unchecked_mut(&mut [99, 108, 105, 112, 112, 121]); + std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']); + + let x = 0xA0; + std::str::from_utf8_unchecked_mut(&mut [0xC0, x]); + } + + // Invalid + unsafe { + std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `std::str::from_utf8_unchecked_mut` + std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `std::str::from_utf8_unchecked_mut` + } +} + +pub fn from_utf8_unchecked() { + // Valid + unsafe { + std::str::from_utf8_unchecked(&[99, 108, 105, 112, 112, 121]); + std::str::from_utf8_unchecked(&[b'c', b'l', b'i', b'p', b'p', b'y']); + std::str::from_utf8_unchecked(b"clippy"); + + let x = 0xA0; + std::str::from_utf8_unchecked(&[0xC0, x]); + } + + // Invalid + unsafe { + std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `std::str::from_utf8_unchecked` + std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `std::str::from_utf8_unchecked` + std::str::from_utf8_unchecked(b"cl\x82ippy"); + //~^ WARN calls to `std::str::from_utf8_unchecked` + std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy")); + //~^ WARN calls to `std::str::from_utf8_unchecked` + } +} + +pub fn from_utf8_mut() { + // Valid + { + std::str::from_utf8_mut(&mut [99, 108, 105, 112, 112, 121]); + std::str::from_utf8_mut(&mut [b'c', b'l', b'i', b'p', b'p', b'y']); + + let x = 0xa0; + std::str::from_utf8_mut(&mut [0xc0, x]); + } + + // Invalid + { + std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `std::str::from_utf8_mut` + std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `std::str::from_utf8_mut` + } +} + +pub fn from_utf8() { + // Valid + { + std::str::from_utf8(&[99, 108, 105, 112, 112, 121]); + std::str::from_utf8(&[b'c', b'l', b'i', b'p', b'p', b'y']); + std::str::from_utf8(b"clippy"); + + let x = 0xA0; + std::str::from_utf8(&[0xC0, x]); + } + + // Invalid + { + std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]); + //~^ WARN calls to `std::str::from_utf8` + std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + //~^ WARN calls to `std::str::from_utf8` + std::str::from_utf8(b"cl\x82ippy"); + //~^ WARN calls to `std::str::from_utf8` + std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy")); + //~^ WARN calls to `std::str::from_utf8` + } +} + +fn main() {} diff --git a/tests/ui/lint/invalid_from_utf8.stderr b/tests/ui/lint/invalid_from_utf8.stderr new file mode 100644 index 000000000..8e00d3bf8 --- /dev/null +++ b/tests/ui/lint/invalid_from_utf8.stderr @@ -0,0 +1,110 @@ +warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:19:9 + | +LL | std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + | +note: the lint level is defined here + --> $DIR/invalid_from_utf8.rs:4:9 + | +LL | #![warn(invalid_from_utf8_unchecked)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:21:9 + | +LL | std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:39:9 + | +LL | std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:41:9 + | +LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:43:9 + | +LL | std::str::from_utf8_unchecked(b"cl\x82ippy"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior + --> $DIR/invalid_from_utf8.rs:45:9 + | +LL | std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:62:9 + | +LL | std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + | +note: the lint level is defined here + --> $DIR/invalid_from_utf8.rs:5:9 + | +LL | #![warn(invalid_from_utf8)] + | ^^^^^^^^^^^^^^^^^ + +warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:64:9 + | +LL | std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with a invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:82:9 + | +LL | std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]); + | ^^^^^^^^^^^^^^^^^^^^-----------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with a invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:84:9 + | +LL | std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']); + | ^^^^^^^^^^^^^^^^^^^^----------------------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with a invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:86:9 + | +LL | std::str::from_utf8(b"cl\x82ippy"); + | ^^^^^^^^^^^^^^^^^^^^-------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: calls to `std::str::from_utf8` with a invalid literal always return an error + --> $DIR/invalid_from_utf8.rs:88:9 + | +LL | std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy")); + | ^^^^^^^^^^^^^^^^^^^^---------------------------------^ + | | + | the literal was valid UTF-8 up to the 2 bytes + +warning: 12 warnings emitted + diff --git a/tests/ui/lint/issue-99387.rs b/tests/ui/lint/issue-99387.rs index 616eb935e..ba5031167 100644 --- a/tests/ui/lint/issue-99387.rs +++ b/tests/ui/lint/issue-99387.rs @@ -1,4 +1,5 @@ -// check-pass +//! Test that we don't follow through projections to find +//! opaque types. #![feature(type_alias_impl_trait)] #![allow(private_in_public)] @@ -18,6 +19,7 @@ impl<'a> Tr for &'a () { } pub fn ohno<'a>() -> <&'a () as Tr>::Item { + //~^ ERROR item constrains opaque type that is not in its signature None.into_iter() } diff --git a/tests/ui/lint/issue-99387.stderr b/tests/ui/lint/issue-99387.stderr new file mode 100644 index 000000000..3a46ce7e1 --- /dev/null +++ b/tests/ui/lint/issue-99387.stderr @@ -0,0 +1,15 @@ +error: item constrains opaque type that is not in its signature + --> $DIR/issue-99387.rs:21:22 + | +LL | pub fn ohno<'a>() -> <&'a () as Tr>::Item { + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this item must mention the opaque type in its signature in order to be able to register hidden types +note: this item must mention the opaque type in its signature in order to be able to register hidden types + --> $DIR/issue-99387.rs:21:8 + | +LL | pub fn ohno<'a>() -> <&'a () as Tr>::Item { + | ^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/lint/lint-attr-everywhere-early.rs b/tests/ui/lint/lint-attr-everywhere-early.rs index 0c820ef9a..ae32ec426 100644 --- a/tests/ui/lint/lint-attr-everywhere-early.rs +++ b/tests/ui/lint/lint-attr-everywhere-early.rs @@ -147,7 +147,7 @@ fn expressions() { #![deny(unsafe_code)] unsafe {} //~ ERROR usage of an `unsafe` block } - let block_tail = { + let block_tail: () = { #[deny(unsafe_code)] unsafe {} //~ ERROR usage of an `unsafe` block }; diff --git a/tests/ui/lint/lint-attr-everywhere-late.rs b/tests/ui/lint/lint-attr-everywhere-late.rs index a24355bab..c3acdeda4 100644 --- a/tests/ui/lint/lint-attr-everywhere-late.rs +++ b/tests/ui/lint/lint-attr-everywhere-late.rs @@ -172,7 +172,7 @@ fn expressions() { #![deny(enum_intrinsics_non_enums)] discriminant::(&123); //~ ERROR the return value of } - let block_tail = { + let block_tail: () = { #[deny(enum_intrinsics_non_enums)] discriminant::(&123); //~ ERROR the return value of }; diff --git a/tests/ui/lint/lint-ctypes-113436-1.rs b/tests/ui/lint/lint-ctypes-113436-1.rs new file mode 100644 index 000000000..1ca59c686 --- /dev/null +++ b/tests/ui/lint/lint-ctypes-113436-1.rs @@ -0,0 +1,28 @@ +#![deny(improper_ctypes_definitions)] + +#[repr(C)] +pub struct Foo { + a: u8, + b: (), +} + +extern "C" fn foo(x: Foo) -> Foo { + todo!() +} + +struct NotSafe(u32); + +#[repr(C)] +pub struct Bar { + a: u8, + b: (), + c: NotSafe, +} + +extern "C" fn bar(x: Bar) -> Bar { + //~^ ERROR `extern` fn uses type `NotSafe`, which is not FFI-safe + //~^^ ERROR `extern` fn uses type `NotSafe`, which is not FFI-safe + todo!() +} + +fn main() {} diff --git a/tests/ui/lint/lint-ctypes-113436-1.stderr b/tests/ui/lint/lint-ctypes-113436-1.stderr new file mode 100644 index 000000000..7b63043f0 --- /dev/null +++ b/tests/ui/lint/lint-ctypes-113436-1.stderr @@ -0,0 +1,35 @@ +error: `extern` fn uses type `NotSafe`, which is not FFI-safe + --> $DIR/lint-ctypes-113436-1.rs:22:22 + | +LL | extern "C" fn bar(x: Bar) -> Bar { + | ^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/lint-ctypes-113436-1.rs:13:1 + | +LL | struct NotSafe(u32); + | ^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/lint-ctypes-113436-1.rs:1:9 + | +LL | #![deny(improper_ctypes_definitions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `extern` fn uses type `NotSafe`, which is not FFI-safe + --> $DIR/lint-ctypes-113436-1.rs:22:30 + | +LL | extern "C" fn bar(x: Bar) -> Bar { + | ^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/lint-ctypes-113436-1.rs:13:1 + | +LL | struct NotSafe(u32); + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/lint-ctypes-113436.rs b/tests/ui/lint/lint-ctypes-113436.rs new file mode 100644 index 000000000..4f733b5bb --- /dev/null +++ b/tests/ui/lint/lint-ctypes-113436.rs @@ -0,0 +1,34 @@ +// check-pass +#![deny(improper_ctypes_definitions)] + +#[repr(C)] +pub struct Wrap(T); + +#[repr(transparent)] +pub struct TransparentWrap(T); + +pub extern "C" fn f() -> Wrap<()> { + todo!() +} + +const _: extern "C" fn() -> Wrap<()> = f; + +pub extern "C" fn ff() -> Wrap> { + todo!() +} + +const _: extern "C" fn() -> Wrap> = ff; + +pub extern "C" fn g() -> TransparentWrap<()> { + todo!() +} + +const _: extern "C" fn() -> TransparentWrap<()> = g; + +pub extern "C" fn gg() -> TransparentWrap> { + todo!() +} + +const _: extern "C" fn() -> TransparentWrap> = gg; + +fn main() {} diff --git a/tests/ui/lint/lint-ctypes-113900.rs b/tests/ui/lint/lint-ctypes-113900.rs new file mode 100644 index 000000000..ac4ff1ae2 --- /dev/null +++ b/tests/ui/lint/lint-ctypes-113900.rs @@ -0,0 +1,12 @@ +// check-pass + +// Extending `improper_ctypes` to check external-ABI fn-ptrs means that it can encounter +// projections which cannot be normalized - unsurprisingly, this shouldn't crash the compiler. + +trait Bar { + type Assoc; +} + +type Foo = extern "C" fn() -> ::Assoc; + +fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73249-2.rs b/tests/ui/lint/lint-ctypes-73249-2.rs index 691047c8a..f30377d6c 100644 --- a/tests/ui/lint/lint-ctypes-73249-2.rs +++ b/tests/ui/lint/lint-ctypes-73249-2.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] #![deny(improper_ctypes)] -pub trait Baz {} +trait Baz {} impl Baz for () {} @@ -9,7 +9,7 @@ type Qux = impl Baz; fn assign() -> Qux {} -pub trait Foo { +trait Foo { type Assoc: 'static; } @@ -18,12 +18,12 @@ impl Foo for () { } #[repr(transparent)] -pub struct A { +struct A { x: &'static ::Assoc, } extern "C" { - pub fn lint_me() -> A<()>; //~ ERROR: uses type `Qux` + fn lint_me() -> A<()>; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73249-2.stderr b/tests/ui/lint/lint-ctypes-73249-2.stderr index 8073c33dd..49fa54114 100644 --- a/tests/ui/lint/lint-ctypes-73249-2.stderr +++ b/tests/ui/lint/lint-ctypes-73249-2.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73249-2.rs:26:25 + --> $DIR/lint-ctypes-73249-2.rs:26:21 | -LL | pub fn lint_me() -> A<()>; - | ^^^^^ not FFI-safe +LL | fn lint_me() -> A<()>; + | ^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/lint-ctypes-73251-1.rs b/tests/ui/lint/lint-ctypes-73251-1.rs index 145ba784f..fc11f23a1 100644 --- a/tests/ui/lint/lint-ctypes-73251-1.rs +++ b/tests/ui/lint/lint-ctypes-73251-1.rs @@ -1,13 +1,13 @@ #![feature(type_alias_impl_trait)] #![deny(improper_ctypes)] -pub trait Baz {} +trait Baz {} impl Baz for u32 {} type Qux = impl Baz; -pub trait Foo { +trait Foo { type Assoc; } @@ -20,7 +20,7 @@ fn assign() -> Qux { } extern "C" { - pub fn lint_me() -> ::Assoc; //~ ERROR: uses type `Qux` + fn lint_me() -> ::Assoc; //~ ERROR: uses type `Qux` } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73251-1.stderr b/tests/ui/lint/lint-ctypes-73251-1.stderr index 9f43576ad..b4eb921b9 100644 --- a/tests/ui/lint/lint-ctypes-73251-1.stderr +++ b/tests/ui/lint/lint-ctypes-73251-1.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73251-1.rs:23:25 + --> $DIR/lint-ctypes-73251-1.rs:23:21 | -LL | pub fn lint_me() -> ::Assoc; - | ^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn lint_me() -> ::Assoc; + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/lint-ctypes-73251-2.rs b/tests/ui/lint/lint-ctypes-73251-2.rs index df71a9457..fbe0a58f3 100644 --- a/tests/ui/lint/lint-ctypes-73251-2.rs +++ b/tests/ui/lint/lint-ctypes-73251-2.rs @@ -33,7 +33,7 @@ fn use_of_b() -> AliasB { } extern "C" { - pub fn lint_me() -> ::Assoc; //~ ERROR: uses type `AliasA` + fn lint_me() -> ::Assoc; //~ ERROR: uses type `AliasA` } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-73251-2.stderr b/tests/ui/lint/lint-ctypes-73251-2.stderr index 0b3de379c..e44cd45bd 100644 --- a/tests/ui/lint/lint-ctypes-73251-2.stderr +++ b/tests/ui/lint/lint-ctypes-73251-2.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `AliasA`, which is not FFI-safe - --> $DIR/lint-ctypes-73251-2.rs:36:25 + --> $DIR/lint-ctypes-73251-2.rs:36:21 | -LL | pub fn lint_me() -> ::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | fn lint_me() -> ::Assoc; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/lint-ctypes-73251.rs b/tests/ui/lint/lint-ctypes-73251.rs index ebc2ca77b..a00d1a75a 100644 --- a/tests/ui/lint/lint-ctypes-73251.rs +++ b/tests/ui/lint/lint-ctypes-73251.rs @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] #![deny(improper_ctypes)] -pub trait Foo { +trait Foo { type Assoc; } @@ -16,7 +16,7 @@ type Bar = impl Foo; fn assign() -> Bar {} extern "C" { - pub fn lint_me() -> ::Assoc; + fn lint_me() -> ::Assoc; } fn main() {} diff --git a/tests/ui/lint/lint-ctypes-94223.rs b/tests/ui/lint/lint-ctypes-94223.rs new file mode 100644 index 000000000..70dd2a71f --- /dev/null +++ b/tests/ui/lint/lint-ctypes-94223.rs @@ -0,0 +1,42 @@ +#![crate_type = "lib"] +#![deny(improper_ctypes_definitions)] + +pub fn bad(f: extern "C" fn([u8])) {} +//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe + +pub fn bad_twice(f: Result) {} +//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe +//~^^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe + +struct BadStruct(extern "C" fn([u8])); +//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe + +enum BadEnum { + A(extern "C" fn([u8])), + //~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe +} + +enum BadUnion { + A(extern "C" fn([u8])), + //~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe +} + +type Foo = extern "C" fn([u8]); +//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe + +pub struct FfiUnsafe; + +#[allow(improper_ctypes_definitions)] +extern "C" fn f(_: FfiUnsafe) { + unimplemented!() +} + +pub static BAD: extern "C" fn(FfiUnsafe) = f; +//~^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe + +pub static BAD_TWICE: Result = Ok(f); +//~^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe +//~^^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe + +pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f; +//~^ ERROR `extern` fn uses type `FfiUnsafe`, which is not FFI-safe diff --git a/tests/ui/lint/lint-ctypes-94223.stderr b/tests/ui/lint/lint-ctypes-94223.stderr new file mode 100644 index 000000000..49e64ed51 --- /dev/null +++ b/tests/ui/lint/lint-ctypes-94223.stderr @@ -0,0 +1,126 @@ +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:4:15 + | +LL | pub fn bad(f: extern "C" fn([u8])) {} + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent +note: the lint level is defined here + --> $DIR/lint-ctypes-94223.rs:2:9 + | +LL | #![deny(improper_ctypes_definitions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:7:28 + | +LL | pub fn bad_twice(f: Result) {} + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:7:49 + | +LL | pub fn bad_twice(f: Result) {} + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:11:18 + | +LL | struct BadStruct(extern "C" fn([u8])); + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:15:7 + | +LL | A(extern "C" fn([u8])), + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:20:7 + | +LL | A(extern "C" fn([u8])), + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + +error: `extern` fn uses type `[u8]`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:24:12 + | +LL | type Foo = extern "C" fn([u8]); + | ^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider using a raw pointer instead + = note: slices have no C equivalent + +error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:34:17 + | +LL | pub static BAD: extern "C" fn(FfiUnsafe) = f; + | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/lint-ctypes-94223.rs:27:1 + | +LL | pub struct FfiUnsafe; + | ^^^^^^^^^^^^^^^^^^^^ + +error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:37:30 + | +LL | pub static BAD_TWICE: Result = Ok(f); + | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/lint-ctypes-94223.rs:27:1 + | +LL | pub struct FfiUnsafe; + | ^^^^^^^^^^^^^^^^^^^^ + +error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:37:56 + | +LL | pub static BAD_TWICE: Result = Ok(f); + | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/lint-ctypes-94223.rs:27:1 + | +LL | pub struct FfiUnsafe; + | ^^^^^^^^^^^^^^^^^^^^ + +error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe + --> $DIR/lint-ctypes-94223.rs:41:22 + | +LL | pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f; + | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct + = note: this struct has unspecified layout +note: the type is defined here + --> $DIR/lint-ctypes-94223.rs:27:1 + | +LL | pub struct FfiUnsafe; + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 11 previous errors + diff --git a/tests/ui/lint/lint-unnecessary-parens.fixed b/tests/ui/lint/lint-unnecessary-parens.fixed index 9c144324f..bafac05d8 100644 --- a/tests/ui/lint/lint-unnecessary-parens.fixed +++ b/tests/ui/lint/lint-unnecessary-parens.fixed @@ -35,6 +35,14 @@ pub fn passes_unused_parens_lint() -> &'static (dyn Trait) { panic!() } +pub fn parens_with_keyword(e: &[()]) -> i32 { + if true {} //~ ERROR unnecessary parentheses around `if` + while true {} //~ ERROR unnecessary parentheses around `while` + for _ in e {} //~ ERROR unnecessary parentheses around `for` + match 1 { _ => ()} //~ ERROR unnecessary parentheses around `match` + return 1; //~ ERROR unnecessary parentheses around `return` value +} + macro_rules! baz { ($($foo:expr),+) => { ($($foo),*) diff --git a/tests/ui/lint/lint-unnecessary-parens.rs b/tests/ui/lint/lint-unnecessary-parens.rs index 4fd9cabb3..ce537a4dc 100644 --- a/tests/ui/lint/lint-unnecessary-parens.rs +++ b/tests/ui/lint/lint-unnecessary-parens.rs @@ -35,6 +35,14 @@ pub fn passes_unused_parens_lint() -> &'static (dyn Trait) { panic!() } +pub fn parens_with_keyword(e: &[()]) -> i32 { + if(true) {} //~ ERROR unnecessary parentheses around `if` + while(true) {} //~ ERROR unnecessary parentheses around `while` + for _ in(e) {} //~ ERROR unnecessary parentheses around `for` + match(1) { _ => ()} //~ ERROR unnecessary parentheses around `match` + return(1); //~ ERROR unnecessary parentheses around `return` value +} + macro_rules! baz { ($($foo:expr),+) => { ($($foo),*) diff --git a/tests/ui/lint/lint-unnecessary-parens.stderr b/tests/ui/lint/lint-unnecessary-parens.stderr index e13620f06..2ad07530f 100644 --- a/tests/ui/lint/lint-unnecessary-parens.stderr +++ b/tests/ui/lint/lint-unnecessary-parens.stderr @@ -63,8 +63,68 @@ LL - (5) LL + 5 | +error: unnecessary parentheses around `if` condition + --> $DIR/lint-unnecessary-parens.rs:39:7 + | +LL | if(true) {} + | ^ ^ + | +help: remove these parentheses + | +LL - if(true) {} +LL + if true {} + | + +error: unnecessary parentheses around `while` condition + --> $DIR/lint-unnecessary-parens.rs:40:10 + | +LL | while(true) {} + | ^ ^ + | +help: remove these parentheses + | +LL - while(true) {} +LL + while true {} + | + +error: unnecessary parentheses around `for` iterator expression + --> $DIR/lint-unnecessary-parens.rs:41:13 + | +LL | for _ in(e) {} + | ^ ^ + | +help: remove these parentheses + | +LL - for _ in(e) {} +LL + for _ in e {} + | + +error: unnecessary parentheses around `match` scrutinee expression + --> $DIR/lint-unnecessary-parens.rs:42:10 + | +LL | match(1) { _ => ()} + | ^ ^ + | +help: remove these parentheses + | +LL - match(1) { _ => ()} +LL + match 1 { _ => ()} + | + +error: unnecessary parentheses around `return` value + --> $DIR/lint-unnecessary-parens.rs:43:11 + | +LL | return(1); + | ^ ^ + | +help: remove these parentheses + | +LL - return(1); +LL + return 1; + | + error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:44:31 + --> $DIR/lint-unnecessary-parens.rs:52:31 | LL | pub const CONST_ITEM: usize = (10); | ^ ^ @@ -76,7 +136,7 @@ LL + pub const CONST_ITEM: usize = 10; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:45:33 + --> $DIR/lint-unnecessary-parens.rs:53:33 | LL | pub static STATIC_ITEM: usize = (10); | ^ ^ @@ -88,7 +148,7 @@ LL + pub static STATIC_ITEM: usize = 10; | error: unnecessary parentheses around function argument - --> $DIR/lint-unnecessary-parens.rs:49:9 + --> $DIR/lint-unnecessary-parens.rs:57:9 | LL | bar((true)); | ^ ^ @@ -100,7 +160,7 @@ LL + bar(true); | error: unnecessary parentheses around `if` condition - --> $DIR/lint-unnecessary-parens.rs:51:8 + --> $DIR/lint-unnecessary-parens.rs:59:8 | LL | if (true) {} | ^ ^ @@ -112,7 +172,7 @@ LL + if true {} | error: unnecessary parentheses around `while` condition - --> $DIR/lint-unnecessary-parens.rs:52:11 + --> $DIR/lint-unnecessary-parens.rs:60:11 | LL | while (true) {} | ^ ^ @@ -124,7 +184,7 @@ LL + while true {} | error: unnecessary parentheses around `match` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:53:11 + --> $DIR/lint-unnecessary-parens.rs:61:11 | LL | match (true) { | ^ ^ @@ -136,7 +196,7 @@ LL + match true { | error: unnecessary parentheses around `let` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:56:16 + --> $DIR/lint-unnecessary-parens.rs:64:16 | LL | if let 1 = (1) {} | ^ ^ @@ -148,7 +208,7 @@ LL + if let 1 = 1 {} | error: unnecessary parentheses around `let` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:57:19 + --> $DIR/lint-unnecessary-parens.rs:65:19 | LL | while let 1 = (2) {} | ^ ^ @@ -160,7 +220,7 @@ LL + while let 1 = 2 {} | error: unnecessary parentheses around method argument - --> $DIR/lint-unnecessary-parens.rs:73:24 + --> $DIR/lint-unnecessary-parens.rs:81:24 | LL | X { y: false }.foo((true)); | ^ ^ @@ -172,7 +232,7 @@ LL + X { y: false }.foo(true); | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:75:18 + --> $DIR/lint-unnecessary-parens.rs:83:18 | LL | let mut _a = (0); | ^ ^ @@ -184,7 +244,7 @@ LL + let mut _a = 0; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:76:10 + --> $DIR/lint-unnecessary-parens.rs:84:10 | LL | _a = (0); | ^ ^ @@ -196,7 +256,7 @@ LL + _a = 0; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:77:11 + --> $DIR/lint-unnecessary-parens.rs:85:11 | LL | _a += (1); | ^ ^ @@ -207,5 +267,5 @@ LL - _a += (1); LL + _a += 1; | -error: aborting due to 17 previous errors +error: aborting due to 22 previous errors diff --git a/tests/ui/lint/opaque-ty-ffi-unsafe.rs b/tests/ui/lint/opaque-ty-ffi-unsafe.rs index b7cc38e99..5faeac9ed 100644 --- a/tests/ui/lint/opaque-ty-ffi-unsafe.rs +++ b/tests/ui/lint/opaque-ty-ffi-unsafe.rs @@ -3,12 +3,12 @@ type A = impl Fn(); -pub fn ret_closure() -> A { +pub(crate) fn ret_closure() -> A { || {} } extern "C" { - pub fn a(_: A); + pub(crate) fn a(_: A); //~^ ERROR `extern` block uses type `A`, which is not FFI-safe [improper_ctypes] } diff --git a/tests/ui/lint/opaque-ty-ffi-unsafe.stderr b/tests/ui/lint/opaque-ty-ffi-unsafe.stderr index 33aa95854..ba9e18bcc 100644 --- a/tests/ui/lint/opaque-ty-ffi-unsafe.stderr +++ b/tests/ui/lint/opaque-ty-ffi-unsafe.stderr @@ -1,8 +1,8 @@ error: `extern` block uses type `A`, which is not FFI-safe - --> $DIR/opaque-ty-ffi-unsafe.rs:11:17 + --> $DIR/opaque-ty-ffi-unsafe.rs:11:24 | -LL | pub fn a(_: A); - | ^ not FFI-safe +LL | pub(crate) fn a(_: A); + | ^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs new file mode 100644 index 000000000..996382049 --- /dev/null +++ b/tests/ui/lint/reference_casting.rs @@ -0,0 +1,51 @@ +// check-fail + +#![feature(ptr_from_ref)] +#![deny(invalid_reference_casting)] + +extern "C" { + // N.B., mutability can be easily incorrect in FFI calls -- as + // in C, the default is mutable pointers. + fn ffi(c: *mut u8); + fn int_ffi(c: *mut i32); +} + +fn main() { + let s = String::from("Hello"); + let a = &s; + unsafe { + let num = &3i32; + let mut_num = &mut 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 + + // 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; + } +} diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr new file mode 100644 index 000000000..d5b9bbef6 --- /dev/null +++ b/tests/ui/lint/reference_casting.stderr @@ -0,0 +1,68 @@ +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 + | +LL | (*(a as *const _ as *mut String)).push_str(" world"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/reference_casting.rs:4:9 + | +LL | #![deny(invalid_reference_casting)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 + | +LL | *(a as *const _ as *mut _) = String::from("Replaced"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 + | +LL | *(a as *const _ as *mut String) += " world"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 + | +LL | let _num = &mut *(num as *const i32 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:28:25 + | +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:30:20 + | +LL | let _num = *{ 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:32:9 + | +LL | *std::ptr::from_ref(num).cast_mut() += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 + | +LL | *std::ptr::from_ref({ num }).cast_mut() += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 + | +LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +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 + | +LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors + diff --git a/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr b/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr index 5087807b6..159a54873 100644 --- a/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr +++ b/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr @@ -4,7 +4,7 @@ error: trivial numeric cast: `i32` as `i32` LL | let lugubrious = 12i32 as i32; | ^^^^^^^^^^^^ | - = help: cast can be replaced by coercion; this might require type ascription or a temporary variable + = help: cast can be replaced by coercion; this might require a temporary variable note: the lint level is defined here --> $DIR/trivial-casts-featuring-type-ascription.rs:1:24 | @@ -17,7 +17,7 @@ error: trivial cast: `&u32` as `*const u32` LL | let _ = haunted as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ | - = help: cast can be replaced by coercion; this might require type ascription or a temporary variable + = help: cast can be replaced by coercion; this might require a temporary variable note: the lint level is defined here --> $DIR/trivial-casts-featuring-type-ascription.rs:1:9 | diff --git a/tests/ui/lint/type-overflow.stderr b/tests/ui/lint/type-overflow.stderr index 62cb1f7f4..e7c90dcc8 100644 --- a/tests/ui/lint/type-overflow.stderr +++ b/tests/ui/lint/type-overflow.stderr @@ -16,17 +16,33 @@ warning: literal out of range for `i8` --> $DIR/type-overflow.rs:10:16 | LL | let fail = 0b1000_0001i8; - | ^^^^^^^^^^^^^ help: consider using the type `u8` instead: `0b1000_0001u8` + | ^^^^^^^^^^^^^ | = note: the literal `0b1000_0001i8` (decimal `129`) does not fit into the type `i8` and will become `-127i8` +help: consider using the type `u8` instead + | +LL | let fail = 0b1000_0001u8; + | ~~~~~~~~~~~~~ +help: to use as a negative number (decimal `-127`), consider using the type `u8` for the literal and cast it to `i8` + | +LL | let fail = 0b1000_0001u8 as i8; + | ~~~~~~~~~~~~~~~~~~~ warning: literal out of range for `i64` --> $DIR/type-overflow.rs:12:16 | LL | let fail = 0x8000_0000_0000_0000i64; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using the type `u64` instead: `0x8000_0000_0000_0000u64` + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the literal `0x8000_0000_0000_0000i64` (decimal `9223372036854775808`) does not fit into the type `i64` and will become `-9223372036854775808i64` +help: consider using the type `u64` instead + | +LL | let fail = 0x8000_0000_0000_0000u64; + | ~~~~~~~~~~~~~~~~~~~~~~~~ +help: to use as a negative number (decimal `-9223372036854775808`), consider using the type `u64` for the literal and cast it to `i64` + | +LL | let fail = 0x8000_0000_0000_0000u64 as i64; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: literal out of range for `u32` --> $DIR/type-overflow.rs:14:16 @@ -44,6 +60,10 @@ LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000; | = note: the literal `0x8000_0000_0000_0000_0000_0000_0000_0000` (decimal `170141183460469231731687303715884105728`) does not fit into the type `i128` and will become `-170141183460469231731687303715884105728i128` = help: consider using the type `u128` instead +help: to use as a negative number (decimal `-170141183460469231731687303715884105728`), consider using the type `u128` for the literal and cast it to `i128` + | +LL | let fail: i128 = 0x8000_0000_0000_0000_0000_0000_0000_0000u128 as i128; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: literal out of range for `i32` --> $DIR/type-overflow.rs:19:16 @@ -53,6 +73,10 @@ LL | let fail = 0x8FFF_FFFF_FFFF_FFFE; | = note: the literal `0x8FFF_FFFF_FFFF_FFFE` (decimal `10376293541461622782`) does not fit into the type `i32` and will become `-2i32` = help: consider using the type `i128` instead +help: to use as a negative number (decimal `-2`), consider using the type `u32` for the literal and cast it to `i32` + | +LL | let fail = 0x8FFF_FFFF_FFFF_FFFEu32 as i32; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ warning: literal out of range for `i8` --> $DIR/type-overflow.rs:21:17 diff --git a/tests/ui/lint/undropped_manually_drops.rs b/tests/ui/lint/undropped_manually_drops.rs new file mode 100644 index 000000000..7286121a4 --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops.rs @@ -0,0 +1,19 @@ +// check-fail + +struct S; + +fn main() { + let mut manual1 = std::mem::ManuallyDrop::new(S); + let mut manual2 = std::mem::ManuallyDrop::new(S); + let mut manual3 = std::mem::ManuallyDrop::new(S); + + drop(std::mem::ManuallyDrop::new(S)); //~ ERROR calls to `std::mem::drop` + drop(manual1); //~ ERROR calls to `std::mem::drop` + drop({ manual3 }); //~ ERROR calls to `std::mem::drop` + + // These lines will drop `S` and should be okay. + unsafe { + std::mem::ManuallyDrop::drop(&mut std::mem::ManuallyDrop::new(S)); + std::mem::ManuallyDrop::drop(&mut manual2); + } +} diff --git a/tests/ui/lint/undropped_manually_drops.stderr b/tests/ui/lint/undropped_manually_drops.stderr new file mode 100644 index 000000000..156b647eb --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops.stderr @@ -0,0 +1,42 @@ +error: calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing + --> $DIR/undropped_manually_drops.rs:10:5 + | +LL | drop(std::mem::ManuallyDrop::new(S)); + | ^^^^^------------------------------^ + | | + | argument has type `ManuallyDrop` + | + = note: `#[deny(undropped_manually_drops)]` on by default +help: use `std::mem::ManuallyDrop::into_inner` to get the inner value + | +LL | drop(std::mem::ManuallyDrop::into_inner(std::mem::ManuallyDrop::new(S))); + | +++++++++++++++++++++++++++++++++++ + + +error: calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing + --> $DIR/undropped_manually_drops.rs:11:5 + | +LL | drop(manual1); + | ^^^^^-------^ + | | + | argument has type `ManuallyDrop` + | +help: use `std::mem::ManuallyDrop::into_inner` to get the inner value + | +LL | drop(std::mem::ManuallyDrop::into_inner(manual1)); + | +++++++++++++++++++++++++++++++++++ + + +error: calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing + --> $DIR/undropped_manually_drops.rs:12:5 + | +LL | drop({ manual3 }); + | ^^^^^-----------^ + | | + | argument has type `ManuallyDrop` + | +help: use `std::mem::ManuallyDrop::into_inner` to get the inner value + | +LL | drop(std::mem::ManuallyDrop::into_inner({ manual3 })); + | +++++++++++++++++++++++++++++++++++ + + +error: aborting due to 3 previous errors + diff --git a/tests/ui/lint/unused/lint-unused-extern-crate.rs b/tests/ui/lint/unused/lint-unused-extern-crate.rs index d5e4da526..79df58b70 100644 --- a/tests/ui/lint/unused/lint-unused-extern-crate.rs +++ b/tests/ui/lint/unused/lint-unused-extern-crate.rs @@ -31,5 +31,5 @@ mod foo { fn main() { lint_unused_extern_crate3::foo(); - let y = foo(); + foo(); } diff --git a/tests/ui/lint/unused/lint-unused-imports.rs b/tests/ui/lint/unused/lint-unused-imports.rs index 4754d8880..953992ecf 100644 --- a/tests/ui/lint/unused/lint-unused-imports.rs +++ b/tests/ui/lint/unused/lint-unused-imports.rs @@ -86,5 +86,5 @@ fn main() { let mut b = 4; swap(&mut a, &mut b); test::C.b(); - let _a = foo(); + foo(); } diff --git a/tests/ui/lint/unused/lint-unused-variables.rs b/tests/ui/lint/unused/lint-unused-variables.rs index 6850e9992..621c6ef84 100644 --- a/tests/ui/lint/unused/lint-unused-variables.rs +++ b/tests/ui/lint/unused/lint-unused-variables.rs @@ -74,6 +74,6 @@ fn main() { b: i32, //~^ ERROR unused variable: `b` | {}; - let _ = a(1, 2); - let _ = b(1, 2); + a(1, 2); + b(1, 2); } diff --git a/tests/ui/lint/unused/must-use-block-expr.fixed b/tests/ui/lint/unused/must-use-block-expr.fixed new file mode 100644 index 000000000..642012812 --- /dev/null +++ b/tests/ui/lint/unused/must-use-block-expr.fixed @@ -0,0 +1,36 @@ +// run-rustfix +// check-pass + +#![warn(unused_must_use)] + +#[must_use] +fn foo() -> i32 { + 42 +} + +fn bar() { + { + let _ = foo(); + //~^ WARN unused return value + } +} + +fn baz() { + { + let _ = foo(); + //~^ WARN unused return value + }; +} + +fn main() { + bar(); + baz(); + { + let _ = 1 + 2; + //~^ WARN unused arithmetic operation + } + { + let _ = 1 + 2; + //~^ WARN unused arithmetic operation + }; +} diff --git a/tests/ui/lint/unused/must-use-block-expr.rs b/tests/ui/lint/unused/must-use-block-expr.rs new file mode 100644 index 000000000..e0a680aa0 --- /dev/null +++ b/tests/ui/lint/unused/must-use-block-expr.rs @@ -0,0 +1,36 @@ +// run-rustfix +// check-pass + +#![warn(unused_must_use)] + +#[must_use] +fn foo() -> i32 { + 42 +} + +fn bar() { + { + foo(); + //~^ WARN unused return value + } +} + +fn baz() { + { + foo() + //~^ WARN unused return value + }; +} + +fn main() { + bar(); + baz(); + { + 1 + 2; + //~^ WARN unused arithmetic operation + } + { + 1 + 2 + //~^ WARN unused arithmetic operation + }; +} diff --git a/tests/ui/lint/unused/must-use-block-expr.stderr b/tests/ui/lint/unused/must-use-block-expr.stderr new file mode 100644 index 000000000..d821beb1d --- /dev/null +++ b/tests/ui/lint/unused/must-use-block-expr.stderr @@ -0,0 +1,51 @@ +warning: unused return value of `foo` that must be used + --> $DIR/must-use-block-expr.rs:13:9 + | +LL | foo(); + | ^^^^^ + | +note: the lint level is defined here + --> $DIR/must-use-block-expr.rs:4:9 + | +LL | #![warn(unused_must_use)] + | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo(); + | +++++++ + +warning: unused return value of `foo` that must be used + --> $DIR/must-use-block-expr.rs:20:9 + | +LL | foo() + | ^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo(); + | +++++++ + + +warning: unused arithmetic operation that must be used + --> $DIR/must-use-block-expr.rs:29:9 + | +LL | 1 + 2; + | ^^^^^ the arithmetic operation produces a value + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = 1 + 2; + | +++++++ + +warning: unused arithmetic operation that must be used + --> $DIR/must-use-block-expr.rs:33:9 + | +LL | 1 + 2 + | ^^^^^ the arithmetic operation produces a value + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = 1 + 2; + | +++++++ + + +warning: 4 warnings emitted + diff --git a/tests/ui/lint/unused_import_warning_issue_45268.rs b/tests/ui/lint/unused_import_warning_issue_45268.rs index 5ae482863..7aa4d4959 100644 --- a/tests/ui/lint/unused_import_warning_issue_45268.rs +++ b/tests/ui/lint/unused_import_warning_issue_45268.rs @@ -31,15 +31,15 @@ use test::B; // This is used by the test2::func() through import of super mod test2 { use super::*; pub fn func() { - let _ = <()>::a(); - let _ = ().b(); + <()>::a(); + ().b(); test3::inner_func(); } mod test3 { use super::*; pub fn inner_func() { - let _ = <()>::a(); - let _ = ().b(); + <()>::a(); + ().b(); } } } diff --git a/tests/ui/loops/dont-suggest-break-thru-item.rs b/tests/ui/loops/dont-suggest-break-thru-item.rs new file mode 100644 index 000000000..b46ba89e8 --- /dev/null +++ b/tests/ui/loops/dont-suggest-break-thru-item.rs @@ -0,0 +1,55 @@ +// edition:2021 + +#![feature(inline_const)] + +fn closure() { + loop { + let closure = || { + if true { + Err(1) + //~^ ERROR mismatched types + } + + Ok(()) + }; + } +} + +fn async_block() { + loop { + let fut = async { + if true { + Err(1) + //~^ ERROR mismatched types + } + + Ok(()) + }; + } +} + +fn fn_item() { + let _ = loop { + fn foo() -> Result<(), ()> { + if true { + Err(1) + //~^ ERROR mismatched types + } + Err(()) + } + }; +} + +fn const_block() { + let _ = loop { + const { + if true { + Err(1) + //~^ ERROR mismatched types + } + Err(()) + }; + }; +} + +fn main() {} diff --git a/tests/ui/loops/dont-suggest-break-thru-item.stderr b/tests/ui/loops/dont-suggest-break-thru-item.stderr new file mode 100644 index 000000000..4fce47151 --- /dev/null +++ b/tests/ui/loops/dont-suggest-break-thru-item.stderr @@ -0,0 +1,55 @@ +error[E0308]: mismatched types + --> $DIR/dont-suggest-break-thru-item.rs:9:17 + | +LL | / if true { +LL | | Err(1) + | | ^^^^^^ expected `()`, found `Result<_, {integer}>` +LL | | +LL | | } + | |_____________- expected this to be `()` + | + = note: expected unit type `()` + found enum `Result<_, {integer}>` + +error[E0308]: mismatched types + --> $DIR/dont-suggest-break-thru-item.rs:22:17 + | +LL | / if true { +LL | | Err(1) + | | ^^^^^^ expected `()`, found `Result<_, {integer}>` +LL | | +LL | | } + | |_____________- expected this to be `()` + | + = note: expected unit type `()` + found enum `Result<_, {integer}>` + +error[E0308]: mismatched types + --> $DIR/dont-suggest-break-thru-item.rs:35:17 + | +LL | / if true { +LL | | Err(1) + | | ^^^^^^ expected `()`, found `Result<_, {integer}>` +LL | | +LL | | } + | |_____________- expected this to be `()` + | + = note: expected unit type `()` + found enum `Result<_, {integer}>` + +error[E0308]: mismatched types + --> $DIR/dont-suggest-break-thru-item.rs:47:17 + | +LL | / if true { +LL | | Err(1) + | | ^^^^^^ expected `()`, found `Result<_, {integer}>` +LL | | +LL | | } + | |_____________- expected this to be `()` + | + = note: expected unit type `()` + found enum `Result<_, {integer}>` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/macros/auxiliary/proc_macro_sequence.rs b/tests/ui/macros/auxiliary/proc_macro_sequence.rs index 1331480d8..2f69cbc94 100644 --- a/tests/ui/macros/auxiliary/proc_macro_sequence.rs +++ b/tests/ui/macros/auxiliary/proc_macro_sequence.rs @@ -8,11 +8,6 @@ extern crate proc_macro; use proc_macro::{quote, Span, TokenStream, TokenTree}; -fn assert_same_span(a: Span, b: Span) { - assert_eq!(a.start(), b.start()); - assert_eq!(a.end(), b.end()); -} - // This macro generates a macro with the same macro definition as `manual_foo` in // `same-sequence-span.rs` but with the same span for all sequences. #[proc_macro] diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index 8cd9a63b8..b726e1862 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -3,21 +3,37 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env` | LL | env::current_dir; | ^^^ use of undeclared crate or module `env` - -error[E0433]: failed to resolve: use of undeclared crate or module `vec` - --> $DIR/builtin-prelude-no-accidents.rs:7:14 | -LL | type B = vec::Vec; - | ^^^ - | | - | use of undeclared crate or module `vec` - | help: a struct with a similar name exists (notice the capitalization): `Vec` +help: consider importing this module + | +LL + use std::env; + | error[E0433]: failed to resolve: use of undeclared crate or module `panic` --> $DIR/builtin-prelude-no-accidents.rs:6:14 | LL | type A = panic::PanicInfo; | ^^^^^ use of undeclared crate or module `panic` + | +help: consider importing this module + | +LL + use std::panic; + | + +error[E0433]: failed to resolve: use of undeclared crate or module `vec` + --> $DIR/builtin-prelude-no-accidents.rs:7:14 + | +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; + | error: aborting due to 3 previous errors diff --git a/tests/ui/macros/builtin-std-paths-fail.stderr b/tests/ui/macros/builtin-std-paths-fail.stderr index ba6261011..004a39043 100644 --- a/tests/ui/macros/builtin-std-paths-fail.stderr +++ b/tests/ui/macros/builtin-std-paths-fail.stderr @@ -93,6 +93,9 @@ error[E0433]: failed to resolve: could not find `test` in `std` | LL | #[std::test] | ^^^^ could not find `test` in `std` + | +note: found an item that was configured out + --> $SRC_DIR/std/src/lib.rs:LL:COL error: aborting due to 16 previous errors diff --git a/tests/ui/macros/format-args-temporaries.rs b/tests/ui/macros/format-args-temporaries.rs index 59323828b..1ff6e3f80 100644 --- a/tests/ui/macros/format-args-temporaries.rs +++ b/tests/ui/macros/format-args-temporaries.rs @@ -27,27 +27,27 @@ impl<'a> Display for MutexGuard<'a> { } fn main() { - let _print = { + let _print: () = { let mutex = Mutex; print!("{}", mutex.lock()) /* no semicolon */ }; - let _println = { + let _println: () = { let mutex = Mutex; println!("{}", mutex.lock()) /* no semicolon */ }; - let _eprint = { + let _eprint: () = { let mutex = Mutex; eprint!("{}", mutex.lock()) /* no semicolon */ }; - let _eprintln = { + let _eprintln: () = { let mutex = Mutex; eprintln!("{}", mutex.lock()) /* no semicolon */ }; - let _panic = { + let _panic: () = { let mutex = Mutex; panic!("{}", mutex.lock()) /* no semicolon */ }; diff --git a/tests/ui/macros/issue-112342-1.rs b/tests/ui/macros/issue-112342-1.rs new file mode 100644 index 000000000..bd2abe7f6 --- /dev/null +++ b/tests/ui/macros/issue-112342-1.rs @@ -0,0 +1,49 @@ +// same as #95267, ignore doc comment although it's a bug. + +macro_rules! m1 { + ( + $( + /// + )* + //~^^^ERROR repetition matches empty token tree + ) => {}; +} + +m1! {} + +macro_rules! m2 { + ( + $( + /// + )+ + //~^^^ERROR repetition matches empty token tree + ) => {}; +} + +m2! {} + +macro_rules! m3 { + ( + $( + /// + )? + //~^^^ERROR repetition matches empty token tree + ) => {}; +} + +m3! {} + + +macro_rules! m4 { + ( + $( + /// + /// + )* + //~^^^^ERROR repetition matches empty token tree + ) => {}; +} + +m4! {} + +fn main() {} diff --git a/tests/ui/macros/issue-112342-1.stderr b/tests/ui/macros/issue-112342-1.stderr new file mode 100644 index 000000000..f2d82bf59 --- /dev/null +++ b/tests/ui/macros/issue-112342-1.stderr @@ -0,0 +1,64 @@ +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:6:13 + | +LL | /// + | ^^^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:5:10 + | +LL | $( + | __________^ +LL | | /// +LL | | )* + | |_________^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:17:13 + | +LL | /// + | ^^^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:16:10 + | +LL | $( + | __________^ +LL | | /// +LL | | )+ + | |_________^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:28:13 + | +LL | /// + | ^^^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:27:10 + | +LL | $( + | __________^ +LL | | /// +LL | | )? + | |_________^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:40:13 + | +LL | / /// +LL | | /// + | |_______________^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:39:10 + | +LL | $( + | __________^ +LL | | /// +LL | | /// +LL | | )* + | |_________^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/macros/issue-112342-2.rs b/tests/ui/macros/issue-112342-2.rs new file mode 100644 index 000000000..e797aff94 --- /dev/null +++ b/tests/ui/macros/issue-112342-2.rs @@ -0,0 +1,39 @@ +// check-pass + +// same as #95267, ignore doc comment although it's a bug. + +macro_rules! m1 { + ( + $( + /// + $expr: expr, + )* + ) => {}; +} + +m1! {} + +macro_rules! m2 { + ( + $( + /// + $expr: expr, + /// + )* + ) => {}; +} + +m2! {} + +macro_rules! m3 { + ( + $( + /// + $tt: tt, + )* + ) => {}; +} + +m3! {} + +fn main() {} diff --git a/tests/ui/macros/issue-112342-2.stderr b/tests/ui/macros/issue-112342-2.stderr new file mode 100644 index 000000000..8c1b6f947 --- /dev/null +++ b/tests/ui/macros/issue-112342-2.stderr @@ -0,0 +1,24 @@ +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:8:13 + | +LL | /// + | ^^^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:19:13 + | +LL | /// + | ^^^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:21:13 + | +LL | /// + | ^^^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:31:13 + | +LL | /// + | ^^^ + diff --git a/tests/ui/macros/issue-88228.rs b/tests/ui/macros/issue-88228.rs index 60ba2eab7..ec55a2625 100644 --- a/tests/ui/macros/issue-88228.rs +++ b/tests/ui/macros/issue-88228.rs @@ -1,14 +1,14 @@ // compile-flags: -Z deduplicate-diagnostics=yes // edition:2018 -mod hey { +mod hey { //~ HELP consider importing this derive macro + //~^ HELP consider importing this macro pub use Copy as Bla; pub use std::println as bla; } #[derive(Bla)] //~^ ERROR cannot find derive macro `Bla` -//~| HELP consider importing this derive macro struct A; #[derive(println)] @@ -19,5 +19,4 @@ struct B; fn main() { bla!(); //~^ ERROR cannot find macro `bla` - //~| HELP consider importing this macro } diff --git a/tests/ui/macros/issue-88228.stderr b/tests/ui/macros/issue-88228.stderr index fe8a1deae..f9d0ac95d 100644 --- a/tests/ui/macros/issue-88228.stderr +++ b/tests/ui/macros/issue-88228.stderr @@ -4,8 +4,10 @@ error: cannot find macro `bla` in this scope LL | bla!(); | ^^^ | - = help: consider importing this macro: - crate::hey::bla +help: consider importing this macro through its public re-export + | +LL + use crate::hey::bla; + | error: cannot find derive macro `println` in this scope --> $DIR/issue-88228.rs:14:10 @@ -16,13 +18,15 @@ LL | #[derive(println)] = note: `println` is in scope, but it is a function-like macro error: cannot find derive macro `Bla` in this scope - --> $DIR/issue-88228.rs:9:10 + --> $DIR/issue-88228.rs:10:10 | LL | #[derive(Bla)] | ^^^ | - = help: consider importing this derive macro: - crate::hey::Bla +help: consider importing this derive macro through its public re-export + | +LL + use crate::hey::Bla; + | error: aborting due to 3 previous errors diff --git a/tests/ui/macros/macro-comma-support-rpass.rs b/tests/ui/macros/macro-comma-support-rpass.rs index cb019792e..2f08ad3c3 100644 --- a/tests/ui/macros/macro-comma-support-rpass.rs +++ b/tests/ui/macros/macro-comma-support-rpass.rs @@ -170,8 +170,8 @@ fn format_args() { #[test] fn include() { - let _ = include!("auxiliary/macro-comma-support.rs"); - let _ = include!("auxiliary/macro-comma-support.rs",); + include!("auxiliary/macro-comma-support.rs"); + include!("auxiliary/macro-comma-support.rs",); } #[test] diff --git a/tests/ui/macros/macro-outer-attributes.stderr b/tests/ui/macros/macro-outer-attributes.stderr index 0bdc3416f..0418e6116 100644 --- a/tests/ui/macros/macro-outer-attributes.stderr +++ b/tests/ui/macros/macro-outer-attributes.stderr @@ -4,6 +4,11 @@ error[E0425]: cannot find function `bar` in module `a` LL | a::bar(); | ^^^ not found in `a` | +note: found an item that was configured out + --> $DIR/macro-outer-attributes.rs:9:14 + | +LL | pub fn bar() { }); + | ^^^ help: consider importing this function | LL + use b::bar; diff --git a/tests/ui/macros/macro-use-wrong-name.stderr b/tests/ui/macros/macro-use-wrong-name.stderr index ca5f0f190..36339542a 100644 --- a/tests/ui/macros/macro-use-wrong-name.stderr +++ b/tests/ui/macros/macro-use-wrong-name.stderr @@ -2,15 +2,21 @@ error: cannot find macro `macro_two` in this scope --> $DIR/macro-use-wrong-name.rs:7:5 | LL | macro_two!(); - | ^^^^^^^^^ help: a macro with a similar name exists: `macro_one` + | ^^^^^^^^^ | ::: $DIR/auxiliary/two_macros.rs:2:1 | LL | macro_rules! macro_one { () => ("one") } | ---------------------- similarly named macro `macro_one` defined here | - = help: consider importing this macro: - two_macros::macro_two +help: a macro with a similar name exists + | +LL | macro_one!(); + | ~~~~~~~~~ +help: consider importing this macro + | +LL + use two_macros::macro_two; + | error: aborting due to previous error diff --git a/tests/ui/macros/same-sequence-span.stderr b/tests/ui/macros/same-sequence-span.stderr index bdd191e8e..3242a32e2 100644 --- a/tests/ui/macros/same-sequence-span.stderr +++ b/tests/ui/macros/same-sequence-span.stderr @@ -17,15 +17,14 @@ LL | $(= $z:tt)* error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments --> $DIR/same-sequence-span.rs:19:1 | +LL | | } + | |_________________________________^ not allowed after `expr` fragments +LL | LL | proc_macro_sequence::make_foo!(); | ^------------------------------- | | | _in this macro invocation | | -LL | | -LL | | -LL | | fn main() {} - | |_________________________________^ not allowed after `expr` fragments | = note: allowed there are: `=>`, `,` or `;` = note: this error originates in the macro `proc_macro_sequence::make_foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/match/issue-112438.rs b/tests/ui/match/issue-112438.rs new file mode 100644 index 000000000..15f380f7f --- /dev/null +++ b/tests/ui/match/issue-112438.rs @@ -0,0 +1,11 @@ +// run-pass +#![feature(inline_const_pat)] +#![allow(dead_code)] +#![allow(incomplete_features)] +fn foo() { + match 0 { + const { 1 << 5 } | _ => {} + } +} + +fn main() {} diff --git a/tests/ui/match/issue-113012.rs b/tests/ui/match/issue-113012.rs new file mode 100644 index 000000000..da7a8b65b --- /dev/null +++ b/tests/ui/match/issue-113012.rs @@ -0,0 +1,12 @@ +// run-pass + +#![allow(dead_code)] +struct Foo(()); + +const FOO: Foo = Foo(match 0 { + 0.. => (), + _ => (), +}); + +fn main() { +} diff --git a/tests/ui/match/issue-70972-dyn-trait.rs b/tests/ui/match/issue-70972-dyn-trait.rs index 97d161c59..df28c474a 100644 --- a/tests/ui/match/issue-70972-dyn-trait.rs +++ b/tests/ui/match/issue-70972-dyn-trait.rs @@ -4,7 +4,7 @@ fn main() { let a: &dyn Send = &7u32; match a { F => panic!(), - //~^ ERROR `&dyn Send` cannot be used in patterns + //~^ ERROR `dyn Send` cannot be used in patterns _ => {} } } diff --git a/tests/ui/match/issue-70972-dyn-trait.stderr b/tests/ui/match/issue-70972-dyn-trait.stderr index 7581070eb..f4dc910c3 100644 --- a/tests/ui/match/issue-70972-dyn-trait.stderr +++ b/tests/ui/match/issue-70972-dyn-trait.stderr @@ -1,4 +1,4 @@ -error: `&dyn Send` cannot be used in patterns +error: `dyn Send` cannot be used in patterns --> $DIR/issue-70972-dyn-trait.rs:6:9 | LL | F => panic!(), diff --git a/tests/ui/mir/issue-101844.rs b/tests/ui/mir/issue-101844.rs index da8a25f5f..72ceefa4f 100644 --- a/tests/ui/mir/issue-101844.rs +++ b/tests/ui/mir/issue-101844.rs @@ -67,7 +67,7 @@ where MS::Item: Into<()>, { // Error: Apparently Balance::new doesn't exist during MIR validation - let _ = ImplShoulExist::::access_fn(ms); + ImplShoulExist::::access_fn(ms); } fn main() {} diff --git a/tests/ui/mir/issue-112269.rs b/tests/ui/mir/issue-112269.rs new file mode 100644 index 000000000..8b9b16647 --- /dev/null +++ b/tests/ui/mir/issue-112269.rs @@ -0,0 +1,9 @@ +pub fn main() { + const x: i32 = 4; + let x: i32 = 3; + //~^ ERROR refutable pattern in local binding + + const y: i32 = 3; + let y = 4; + //~^ ERROR refutable pattern in local binding +} diff --git a/tests/ui/mir/issue-112269.stderr b/tests/ui/mir/issue-112269.stderr new file mode 100644 index 000000000..f5b796027 --- /dev/null +++ b/tests/ui/mir/issue-112269.stderr @@ -0,0 +1,31 @@ +error[E0005]: refutable pattern in local binding + --> $DIR/issue-112269.rs:3:9 + | +LL | let x: i32 = 3; + | ^ + | | + | patterns `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered + | missing patterns are not covered because `x` is interpreted as a constant pattern, not a new variable + | help: introduce a variable instead: `x_var` + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `i32` + +error[E0005]: refutable pattern in local binding + --> $DIR/issue-112269.rs:7:9 + | +LL | let y = 4; + | ^ + | | + | patterns `i32::MIN..=2_i32` and `4_i32..=i32::MAX` not covered + | missing patterns are not covered because `y` is interpreted as a constant pattern, not a new variable + | help: introduce a variable instead: `y_var` + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/mir/issue-80949.rs b/tests/ui/mir/issue-80949.rs index 7e34a4f5c..96b63e93a 100644 --- a/tests/ui/mir/issue-80949.rs +++ b/tests/ui/mir/issue-80949.rs @@ -28,7 +28,7 @@ fn may_panic(_: X) { } fn main() { let dyn_trait = make_dyn_trait(&()); let storage = vec![()]; - let _x = may_panic(()); + may_panic(()); let storage_ref = &storage; diff(dyn_trait, storage_ref); } diff --git a/tests/ui/mir/issue66339.rs b/tests/ui/mir/issue66339.rs index 2507af38c..f25afd560 100644 --- a/tests/ui/mir/issue66339.rs +++ b/tests/ui/mir/issue66339.rs @@ -5,7 +5,7 @@ fn foo() { let bar = |_| { }; - let _ = bar("a"); + bar("a"); } fn main() { diff --git a/tests/ui/mir/ssa-analysis-regression-50041.rs b/tests/ui/mir/ssa-analysis-regression-50041.rs index ebc3e2f8c..534f1c465 100644 --- a/tests/ui/mir/ssa-analysis-regression-50041.rs +++ b/tests/ui/mir/ssa-analysis-regression-50041.rs @@ -13,13 +13,10 @@ struct Unique(NonNull); pub struct Box(Unique); impl Drop for Box { - fn drop(&mut self) {} -} - -#[lang = "box_free"] -#[inline(always)] -unsafe fn box_free(ptr: Unique) { - dealloc(ptr.0.0) + #[inline(always)] + fn drop(&mut self) { + dealloc(self.0.0.0) + } } #[inline(never)] diff --git a/tests/ui/mir/thir-constparam-temp.rs b/tests/ui/mir/thir-constparam-temp.rs index cdc5910b3..7eedc325d 100644 --- a/tests/ui/mir/thir-constparam-temp.rs +++ b/tests/ui/mir/thir-constparam-temp.rs @@ -3,7 +3,9 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] struct Yikes; impl Yikes { diff --git a/tests/ui/mir/thir-constparam-temp.stderr b/tests/ui/mir/thir-constparam-temp.stderr index b77d67e08..d50747e54 100644 --- a/tests/ui/mir/thir-constparam-temp.stderr +++ b/tests/ui/mir/thir-constparam-temp.stderr @@ -1,5 +1,5 @@ warning: taking a mutable reference to a `const` item - --> $DIR/thir-constparam-temp.rs:14:5 + --> $DIR/thir-constparam-temp.rs:16:5 | LL | YIKES.mut_self() | ^^^^^^^^^^^^^^^^ @@ -7,12 +7,12 @@ LL | YIKES.mut_self() = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: mutable reference created due to call to this method - --> $DIR/thir-constparam-temp.rs:10:5 + --> $DIR/thir-constparam-temp.rs:12:5 | LL | fn mut_self(&mut self) {} | ^^^^^^^^^^^^^^^^^^^^^^ note: `const` item defined here - --> $DIR/thir-constparam-temp.rs:13:8 + --> $DIR/thir-constparam-temp.rs:15:8 | LL | fn foo() { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mismatched_types/E0053.stderr b/tests/ui/mismatched_types/E0053.stderr index 154f2fcbe..d0bd5b46c 100644 --- a/tests/ui/mismatched_types/E0053.stderr +++ b/tests/ui/mismatched_types/E0053.stderr @@ -22,7 +22,7 @@ LL | fn bar(&mut self) { } | ^^^^^^^^^ | | | types differ in mutability - | help: change the self-receiver type to match the trait: `self: &Bar` + | help: change the self-receiver type to match the trait: `&self` | note: type in trait --> $DIR/E0053.rs:3:12 diff --git a/tests/ui/mismatched_types/binops.stderr b/tests/ui/mismatched_types/binops.stderr index 3585587ed..b18ab7f76 100644 --- a/tests/ui/mismatched_types/binops.stderr +++ b/tests/ui/mismatched_types/binops.stderr @@ -6,14 +6,14 @@ LL | 1 + Some(1); | = help: the trait `Add>` is not implemented for `{integer}` = help: the following other types implement trait `Add`: - <&'a f32 as Add> - <&'a f64 as Add> - <&'a i128 as Add> - <&'a i16 as Add> - <&'a i32 as Add> - <&'a i64 as Add> - <&'a i8 as Add> - <&'a isize as Add> + + > + + > + + > + + > and 48 others error[E0277]: cannot subtract `Option<{integer}>` from `usize` @@ -24,10 +24,10 @@ LL | 2 as usize - Some(1); | = help: the trait `Sub>` is not implemented for `usize` = help: the following other types implement trait `Sub`: + + > <&'a usize as Sub> <&usize as Sub<&usize>> - > - error[E0277]: cannot multiply `{integer}` by `()` --> $DIR/binops.rs:4:7 @@ -37,14 +37,14 @@ LL | 3 * (); | = help: the trait `Mul<()>` is not implemented for `{integer}` = help: the following other types implement trait `Mul`: - <&'a f32 as Mul> - <&'a f64 as Mul> - <&'a i128 as Mul> - <&'a i16 as Mul> - <&'a i32 as Mul> - <&'a i64 as Mul> - <&'a i8 as Mul> - <&'a isize as Mul> + + > + + > + + > + + > and 49 others error[E0277]: cannot divide `{integer}` by `&str` @@ -55,14 +55,14 @@ LL | 4 / ""; | = help: the trait `Div<&str>` is not implemented for `{integer}` = help: the following other types implement trait `Div`: - <&'a f32 as Div> - <&'a f64 as Div> - <&'a i128 as Div> - <&'a i16 as Div> - <&'a i32 as Div> - <&'a i64 as Div> - <&'a i8 as Div> - <&'a isize as Div> + + > + + > + + > + + > and 54 others error[E0277]: can't compare `{integer}` with `String` @@ -73,14 +73,14 @@ LL | 5 < String::new(); | = help: the trait `PartialOrd` is not implemented for `{integer}` = help: the following other types implement trait `PartialOrd`: - f32 - f64 - i128 + isize + i8 i16 i32 i64 - i8 - isize + i128 + usize + u8 and 6 others error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` @@ -91,14 +91,14 @@ LL | 6 == Ok(1); | = help: the trait `PartialEq>` is not implemented for `{integer}` = help: the following other types implement trait `PartialEq`: - f32 - f64 - i128 + isize + i8 i16 i32 i64 - i8 - isize + i128 + usize + u8 and 6 others error: aborting due to 6 previous errors diff --git a/tests/ui/mismatched_types/issue-112036.rs b/tests/ui/mismatched_types/issue-112036.rs new file mode 100644 index 000000000..e63471e97 --- /dev/null +++ b/tests/ui/mismatched_types/issue-112036.rs @@ -0,0 +1,7 @@ +struct Foo; + +impl Drop for Foo { + fn drop(self) {} //~ ERROR method `drop` has an incompatible type for trait +} + +fn main() {} diff --git a/tests/ui/mismatched_types/issue-112036.stderr b/tests/ui/mismatched_types/issue-112036.stderr new file mode 100644 index 000000000..a883aba35 --- /dev/null +++ b/tests/ui/mismatched_types/issue-112036.stderr @@ -0,0 +1,15 @@ +error[E0053]: method `drop` has an incompatible type for trait + --> $DIR/issue-112036.rs:4:13 + | +LL | fn drop(self) {} + | ^^^^ + | | + | expected `&mut Foo`, found `Foo` + | help: change the self-receiver type to match the trait: `&mut self` + | + = note: expected signature `fn(&mut Foo)` + found signature `fn(Foo)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.rs b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.rs new file mode 100644 index 000000000..5febbbe39 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.rs @@ -0,0 +1,9 @@ +fn deref_int(a: &i32) -> i32 { + *a +} + +fn main() { + // https://github.com/rust-lang/rust/issues/112293 + let _has_inference_vars: Option = Some(0).map(deref_int); + //~^ ERROR type mismatch in function arguments +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr new file mode 100644 index 000000000..71c4729e3 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr @@ -0,0 +1,24 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef-inference-var.rs:7:56 + | +LL | fn deref_int(a: &i32) -> i32 { + | ---------------------------- found signature defined here +... +LL | let _has_inference_vars: Option = Some(0).map(deref_int); + | --- ^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn({integer}) -> _` + 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 + | +LL - fn deref_int(a: &i32) -> i32 { +LL + fn deref_int(a: i32) -> i32 { + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs new file mode 100644 index 000000000..ac0831ce6 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs @@ -0,0 +1,34 @@ +fn produces_string() -> Option { + Some("my cool string".to_owned()) +} + +fn takes_str_but_too_many_refs(_: &&str) -> Option<()> { + Some(()) +} + +fn no_args() -> Option<()> { + Some(()) +} + +extern "C" fn takes_str_but_wrong_abi(_: &str) -> Option<()> { + Some(()) +} + +unsafe fn takes_str_but_unsafe(_: &str) -> Option<()> { + Some(()) +} + +struct TypeWithoutDeref; + +fn main() { + let _ = produces_string().and_then(takes_str_but_too_many_refs); + //~^ ERROR type mismatch in function arguments + let _ = produces_string().and_then(takes_str_but_wrong_abi); + //~^ ERROR expected a `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + let _ = produces_string().and_then(takes_str_but_unsafe); + //~^ ERROR expected a `FnOnce<(String,)>` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + let _ = produces_string().and_then(no_args); + //~^ ERROR function is expected to take 1 argument, but it takes 0 arguments + let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); + //~^ ERROR type mismatch in function arguments +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr new file mode 100644 index 000000000..ecfbd27b1 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr @@ -0,0 +1,75 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef-unfixable.rs:24:40 + | +LL | fn takes_str_but_too_many_refs(_: &&str) -> Option<()> { + | ------------------------------------------------------ found signature defined here +... +LL | let _ = produces_string().and_then(takes_str_but_too_many_refs); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a, 'b> fn(&'a &'b str) -> _` +note: required by a bound in `Option::::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0277]: expected a `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + --> $DIR/suggest-option-asderef-unfixable.rs:26:40 + | +LL | let _ = produces_string().and_then(takes_str_but_wrong_abi); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + | | + | required by a bound introduced by this call + | + = help: the trait `FnOnce<(String,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` +note: required by a bound in `Option::::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0277]: expected a `FnOnce<(String,)>` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + --> $DIR/suggest-option-asderef-unfixable.rs:28:40 + | +LL | let _ = produces_string().and_then(takes_str_but_unsafe); + | -------- ^^^^^^^^^^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }` + | | + | required by a bound introduced by this call + | + = help: the trait `FnOnce<(String,)>` is not implemented for fn item `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + = note: unsafe function cannot be called generically without an unsafe block +note: required by a bound in `Option::::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0593]: function is expected to take 1 argument, but it takes 0 arguments + --> $DIR/suggest-option-asderef-unfixable.rs:30:40 + | +LL | fn no_args() -> Option<()> { + | -------------------------- takes 0 arguments +... +LL | let _ = produces_string().and_then(no_args); + | -------- ^^^^^^^ expected function that takes 1 argument + | | + | required by a bound introduced by this call + | +note: required by a bound in `Option::::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef-unfixable.rs:32:45 + | +LL | fn takes_str_but_too_many_refs(_: &&str) -> Option<()> { + | ------------------------------------------------------ found signature defined here +... +LL | let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(TypeWithoutDeref) -> _` + found function signature `for<'a, 'b> fn(&'a &'b str) -> _` +note: required by a bound in `Option::::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0277, E0593, E0631. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/mismatched_types/suggest-option-asderef.fixed b/tests/ui/mismatched_types/suggest-option-asderef.fixed new file mode 100644 index 000000000..5c42ece3c --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef.fixed @@ -0,0 +1,39 @@ +// run-rustfix + +fn produces_string() -> Option { + Some("my cool string".to_owned()) +} + +fn takes_str(_: &str) -> Option<()> { + Some(()) +} + +fn takes_str_mut(_: &mut str) -> Option<()> { + Some(()) +} + +fn generic(_: T) -> Option<()> { + Some(()) +} + +fn generic_ref(_: T) -> Option<()> { + //~^ HELP do not borrow the argument + Some(()) +} + +fn main() { + let _: Option<()> = produces_string().as_deref().and_then(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option> = produces_string().as_deref().map(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option> = produces_string().as_deref_mut().map(takes_str_mut); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref_mut()` first + let _ = produces_string().and_then(generic); + + let _ = produces_string().as_deref().and_then(generic_ref); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef.rs b/tests/ui/mismatched_types/suggest-option-asderef.rs new file mode 100644 index 000000000..a5278b8fb --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef.rs @@ -0,0 +1,39 @@ +// run-rustfix + +fn produces_string() -> Option { + Some("my cool string".to_owned()) +} + +fn takes_str(_: &str) -> Option<()> { + Some(()) +} + +fn takes_str_mut(_: &mut str) -> Option<()> { + Some(()) +} + +fn generic(_: T) -> Option<()> { + Some(()) +} + +fn generic_ref(_: &T) -> Option<()> { + //~^ HELP do not borrow the argument + Some(()) +} + +fn main() { + let _: Option<()> = produces_string().and_then(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option> = produces_string().map(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option> = produces_string().map(takes_str_mut); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref_mut()` first + let _ = produces_string().and_then(generic); + + let _ = produces_string().and_then(generic_ref); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef.stderr b/tests/ui/mismatched_types/suggest-option-asderef.stderr new file mode 100644 index 000000000..01341603d --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef.stderr @@ -0,0 +1,88 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:25:52 + | +LL | fn takes_str(_: &str) -> Option<()> { + | ----------------------------------- found signature defined here +... +LL | let _: Option<()> = produces_string().and_then(takes_str); + | -------- ^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a str) -> _` +note: required by a bound in `Option::::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: call `Option::as_deref()` first + | +LL | let _: Option<()> = produces_string().as_deref().and_then(takes_str); + | +++++++++++ + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:28:55 + | +LL | fn takes_str(_: &str) -> Option<()> { + | ----------------------------------- found signature defined here +... +LL | let _: Option> = produces_string().map(takes_str); + | --- ^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a str) -> _` +note: required by a bound in `Option::::map` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: call `Option::as_deref()` first + | +LL | let _: Option> = produces_string().as_deref().map(takes_str); + | +++++++++++ + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:31:55 + | +LL | fn takes_str_mut(_: &mut str) -> Option<()> { + | ------------------------------------------- found signature defined here +... +LL | let _: Option> = produces_string().map(takes_str_mut); + | --- ^^^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a mut str) -> _` +note: required by a bound in `Option::::map` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: call `Option::as_deref_mut()` first + | +LL | let _: Option> = produces_string().as_deref_mut().map(takes_str_mut); + | +++++++++++++++ + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:36:40 + | +LL | fn generic_ref(_: &T) -> Option<()> { + | -------------------------------------- found signature defined here +... +LL | let _ = produces_string().and_then(generic_ref); + | -------- ^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + 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 + | +LL - fn generic_ref(_: &T) -> Option<()> { +LL + fn generic_ref(_: T) -> Option<()> { + | +help: call `Option::as_deref()` first + | +LL | let _ = produces_string().as_deref().and_then(generic_ref); + | +++++++++++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/missing/missing-macro-use.stderr b/tests/ui/missing/missing-macro-use.stderr index 99e291cda..e1d80f52d 100644 --- a/tests/ui/missing/missing-macro-use.stderr +++ b/tests/ui/missing/missing-macro-use.stderr @@ -4,8 +4,10 @@ error: cannot find macro `macro_two` in this scope LL | macro_two!(); | ^^^^^^^^^ | - = help: consider importing this macro: - two_macros::macro_two +help: consider importing this macro + | +LL + use two_macros::macro_two; + | error: aborting due to previous error diff --git a/tests/ui/never_type/diverging-fallback-control-flow.rs b/tests/ui/never_type/diverging-fallback-control-flow.rs index 45a3362fa..9f6cfc799 100644 --- a/tests/ui/never_type/diverging-fallback-control-flow.rs +++ b/tests/ui/never_type/diverging-fallback-control-flow.rs @@ -48,7 +48,7 @@ fn assignment_rev() { } fn if_then_else() { - let _x = if true { + let _x: () = if true { UnitDefault::default() } else { return; @@ -56,7 +56,7 @@ fn if_then_else() { } fn if_then_else_rev() { - let _x = if true { + let _x: () = if true { return; } else { UnitDefault::default() @@ -64,21 +64,21 @@ fn if_then_else_rev() { } fn match_arm() { - let _x = match Ok(UnitDefault::default()) { + let _x: () = match Ok(UnitDefault::default()) { Ok(v) => v, Err(()) => return, }; } fn match_arm_rev() { - let _x = match Ok(UnitDefault::default()) { + let _x: () = match Ok(UnitDefault::default()) { Err(()) => return, Ok(v) => v, }; } fn loop_break() { - let _x = loop { + let _x: () = loop { if false { break return; } else { @@ -88,7 +88,7 @@ fn loop_break() { } fn loop_break_rev() { - let _x = loop { + let _x: () = loop { if false { break return; } else { diff --git a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr index 3215c4669..df29fe227 100644 --- a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr +++ b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr @@ -7,8 +7,8 @@ LL | unconstrained_arg(return); | required by a bound introduced by this call | = help: the following other types implement trait `Test`: - () i32 + () = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) = help: did you intend to use the type `()` here instead? note: required by a bound in `unconstrained_arg` diff --git a/tests/ui/never_type/issue-13352.stderr b/tests/ui/never_type/issue-13352.stderr index 2d22da0b4..406785bfe 100644 --- a/tests/ui/never_type/issue-13352.stderr +++ b/tests/ui/never_type/issue-13352.stderr @@ -6,10 +6,10 @@ LL | 2_usize + (loop {}); | = help: the trait `Add<()>` is not implemented for `usize` = help: the following other types implement trait `Add`: + + > <&'a usize as Add> <&usize as Add<&usize>> - > - error: aborting due to previous error diff --git a/tests/ui/nll/assign-while-to-immutable.rs b/tests/ui/nll/assign-while-to-immutable.rs index c803321b5..24eaa8a23 100644 --- a/tests/ui/nll/assign-while-to-immutable.rs +++ b/tests/ui/nll/assign-while-to-immutable.rs @@ -4,8 +4,8 @@ // check-pass fn main() { - let x = while false { + let x: () = while false { break; }; - let y = 'l: while break 'l {}; + let y: () = 'l: while break 'l {}; } diff --git a/tests/ui/nll/issue-112604-closure-output-normalize.rs b/tests/ui/nll/issue-112604-closure-output-normalize.rs new file mode 100644 index 000000000..e4c954eeb --- /dev/null +++ b/tests/ui/nll/issue-112604-closure-output-normalize.rs @@ -0,0 +1,49 @@ +//check-pass + +use higher_kinded_types::*; +mod higher_kinded_types { + pub(crate) trait HKT { + type Of<'lt>; + } + + pub(crate) trait WithLifetime<'lt> { + type T; + } + + impl WithLifetime<'any>> HKT for T { + type Of<'lt> = >::T; + } +} + +trait Trait { + type Gat<'lt>; +} + +impl Trait for () { + type Gat<'lt> = (); +} + +/// Same as `Trait`, but using HKTs rather than GATs +trait HTrait { + type Hat: ?Sized + HKT; +} + +impl HTrait for T { + type Hat = dyn for<'lt> WithLifetime<'lt, T = T::Gat<'lt>>; +} + +impl Trait for Box> { + type Gat<'lt> = Hat::Of<'lt>; +} + +fn existential() -> impl for<'a> Trait = ()> {} + +fn dyn_hoops( + _: T, +) -> Box WithLifetime<'a, T = T::Gat<'a>>>> { + loop {} +} + +fn main() { + let _ = || -> _ { dyn_hoops(existential()) }; +} diff --git a/tests/ui/nll/issue-53119.rs b/tests/ui/nll/issue-53119.rs index 03c9c071c..015b72367 100644 --- a/tests/ui/nll/issue-53119.rs +++ b/tests/ui/nll/issue-53119.rs @@ -1,4 +1,6 @@ // check-pass +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next use std::ops::Deref; diff --git a/tests/ui/nll/issue-54943-3.rs b/tests/ui/nll/issue-54943-3.rs index 077eb1563..348b48dba 100644 --- a/tests/ui/nll/issue-54943-3.rs +++ b/tests/ui/nll/issue-54943-3.rs @@ -13,7 +13,7 @@ fn foo(_: T) { } fn bar<'a>() { return; - let _x = foo::>(Vec::<&'a u32>::new()); + foo::>(Vec::<&'a u32>::new()); } fn main() {} diff --git a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr index da4b9595c..ba885d1b9 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -1,4 +1,4 @@ -error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds +error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a), T, ReEarlyBound(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a)])` captures lifetime that does not appear in bounds --> $DIR/impl-trait-captures.rs:11:5 | LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { @@ -8,7 +8,7 @@ LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { LL | x | ^ | -help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(2, 'a)])` captures `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` lifetime bound +help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a), T, ReEarlyBound(DefId(0:14 ~ impl_trait_captures[aeb9]::foo::{opaque#0}::'a), 2, 'a)])` captures `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` lifetime bound | LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) { | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/tests/ui/nll/user-annotations/normalization-2.stderr b/tests/ui/nll/user-annotations/normalization-2.stderr index 5299282ea..6b0dcb414 100644 --- a/tests/ui/nll/user-annotations/normalization-2.stderr +++ b/tests/ui/nll/user-annotations/normalization-2.stderr @@ -147,7 +147,7 @@ LL | fn test_variants<'a, 'b, 'c>() { | -- lifetime `'b` defined here ... LL | >::Tuple(); - | ^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` + | ^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` error: lifetime may not live long enough --> $DIR/normalization-2.rs:93:5 diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr index c4abcb784..2fba94d07 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr @@ -76,37 +76,37 @@ error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:47:36 diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr index c4abcb784..2fba94d07 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr @@ -76,37 +76,37 @@ error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:47:36 diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr index c4abcb784..2fba94d07 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr @@ -76,37 +76,37 @@ error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:47:36 diff --git a/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr b/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr index 8f0eef237..e1825eb5b 100644 --- a/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr +++ b/tests/ui/numbers-arithmetic/not-suggest-float-literal.stderr @@ -6,10 +6,10 @@ LL | x + 100.0 | = help: the trait `Add<{float}>` is not implemented for `u8` = help: the following other types implement trait `Add`: + + > <&'a u8 as Add> <&u8 as Add<&u8>> - > - error[E0277]: cannot add `&str` to `f64` --> $DIR/not-suggest-float-literal.rs:6:7 @@ -19,10 +19,10 @@ LL | x + "foo" | = help: the trait `Add<&str>` is not implemented for `f64` = help: the following other types implement trait `Add`: + + > <&'a f64 as Add> <&f64 as Add<&f64>> - > - error[E0277]: cannot add `{integer}` to `f64` --> $DIR/not-suggest-float-literal.rs:11:7 @@ -32,10 +32,10 @@ LL | x + y | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add`: + + > <&'a f64 as Add> <&f64 as Add<&f64>> - > - error[E0277]: cannot subtract `{float}` from `u8` --> $DIR/not-suggest-float-literal.rs:15:7 @@ -45,10 +45,10 @@ LL | x - 100.0 | = help: the trait `Sub<{float}>` is not implemented for `u8` = help: the following other types implement trait `Sub`: + + > <&'a u8 as Sub> <&u8 as Sub<&u8>> - > - error[E0277]: cannot subtract `&str` from `f64` --> $DIR/not-suggest-float-literal.rs:19:7 @@ -58,10 +58,10 @@ LL | x - "foo" | = help: the trait `Sub<&str>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - error[E0277]: cannot subtract `{integer}` from `f64` --> $DIR/not-suggest-float-literal.rs:24:7 @@ -71,10 +71,10 @@ LL | x - y | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - error[E0277]: cannot multiply `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:28:7 @@ -84,10 +84,10 @@ LL | x * 100.0 | = help: the trait `Mul<{float}>` is not implemented for `u8` = help: the following other types implement trait `Mul`: + + > <&'a u8 as Mul> <&u8 as Mul<&u8>> - > - error[E0277]: cannot multiply `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:32:7 @@ -97,10 +97,10 @@ LL | x * "foo" | = help: the trait `Mul<&str>` is not implemented for `f64` = help: the following other types implement trait `Mul`: + + > <&'a f64 as Mul> <&f64 as Mul<&f64>> - > - error[E0277]: cannot multiply `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:37:7 @@ -110,10 +110,10 @@ LL | x * y | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul`: + + > <&'a f64 as Mul> <&f64 as Mul<&f64>> - > - error[E0277]: cannot divide `u8` by `{float}` --> $DIR/not-suggest-float-literal.rs:41:7 @@ -123,11 +123,11 @@ LL | x / 100.0 | = help: the trait `Div<{float}>` is not implemented for `u8` = help: the following other types implement trait `Div`: + + > + > <&'a u8 as Div> <&u8 as Div<&u8>> - > - > - error[E0277]: cannot divide `f64` by `&str` --> $DIR/not-suggest-float-literal.rs:45:7 @@ -137,10 +137,10 @@ LL | x / "foo" | = help: the trait `Div<&str>` is not implemented for `f64` = help: the following other types implement trait `Div`: + + > <&'a f64 as Div> <&f64 as Div<&f64>> - > - error[E0277]: cannot divide `f64` by `{integer}` --> $DIR/not-suggest-float-literal.rs:50:7 @@ -150,10 +150,10 @@ LL | x / y | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div`: + + > <&'a f64 as Div> <&f64 as Div<&f64>> - > - error: aborting due to 12 previous errors diff --git a/tests/ui/numbers-arithmetic/suggest-float-literal.stderr b/tests/ui/numbers-arithmetic/suggest-float-literal.stderr index 03779d356..929a9e3b5 100644 --- a/tests/ui/numbers-arithmetic/suggest-float-literal.stderr +++ b/tests/ui/numbers-arithmetic/suggest-float-literal.stderr @@ -6,10 +6,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Add`: + + > <&'a f32 as Add> <&f32 as Add<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -23,10 +23,10 @@ LL | x + 100 | = help: the trait `Add<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Add`: + + > <&'a f64 as Add> <&f64 as Add<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x + 100.0 @@ -40,10 +40,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Sub`: + + > <&'a f32 as Sub> <&f32 as Sub<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -57,10 +57,10 @@ LL | x - 100 | = help: the trait `Sub<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Sub`: + + > <&'a f64 as Sub> <&f64 as Sub<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x - 100.0 @@ -74,10 +74,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Mul`: + + > <&'a f32 as Mul> <&f32 as Mul<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -91,10 +91,10 @@ LL | x * 100 | = help: the trait `Mul<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Mul`: + + > <&'a f64 as Mul> <&f64 as Mul<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x * 100.0 @@ -108,10 +108,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f32` = help: the following other types implement trait `Div`: + + > <&'a f32 as Div> <&f32 as Div<&f32>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 @@ -125,10 +125,10 @@ LL | x / 100 | = help: the trait `Div<{integer}>` is not implemented for `f64` = help: the following other types implement trait `Div`: + + > <&'a f64 as Div> <&f64 as Div<&f64>> - > - help: consider using a floating-point literal by writing it with `.0` | LL | x / 100.0 diff --git a/tests/ui/object-safety/assoc_type_bounds_sized.rs b/tests/ui/object-safety/assoc_type_bounds_sized.rs index 61ad3cf9d..6d10ceeb1 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized.rs @@ -1,9 +1,24 @@ +//! This test checks that associated types only need to be +//! mentioned in trait objects, if they don't require `Self: Sized`. + +// check-pass + trait Foo { type Bar where Self: Sized; } -fn foo(_: &dyn Foo) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn foo(_: &dyn Foo) {} + +trait Other: Sized {} + +trait Boo { + type Assoc + where + Self: Other; +} + +fn boo(_: &dyn Boo) {} fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized.stderr b/tests/ui/object-safety/assoc_type_bounds_sized.stderr deleted file mode 100644 index 49d624f9b..000000000 --- a/tests/ui/object-safety/assoc_type_bounds_sized.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified - --> $DIR/assoc_type_bounds_sized.rs:7:16 - | -LL | type Bar - | -------- `Bar` defined here -... -LL | fn foo(_: &dyn Foo) {} - | ^^^ help: specify the associated type: `Foo` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs new file mode 100644 index 000000000..647b72a75 --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs @@ -0,0 +1,25 @@ +//! This test checks that even if some associated types have +//! `where Self: Sized` bounds, those without still need to be +//! mentioned in trait objects. + +trait Foo { + type Bar + where + Self: Sized; + type Bop; +} + +fn foo(_: &dyn Foo) {} +//~^ ERROR the value of the associated type `Bop` (from trait `Foo`) must be specified + +trait Bar { + type Bop; + type Bar + where + Self: Sized; +} + +fn bar(_: &dyn Bar) {} +//~^ ERROR the value of the associated type `Bop` (from trait `Bar`) must be specified + +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr new file mode 100644 index 000000000..e4c44334b --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr @@ -0,0 +1,21 @@ +error[E0191]: the value of the associated type `Bop` (from trait `Foo`) must be specified + --> $DIR/assoc_type_bounds_sized_others.rs:12:16 + | +LL | type Bop; + | -------- `Bop` defined here +... +LL | fn foo(_: &dyn Foo) {} + | ^^^ help: specify the associated type: `Foo` + +error[E0191]: the value of the associated type `Bop` (from trait `Bar`) must be specified + --> $DIR/assoc_type_bounds_sized_others.rs:22:16 + | +LL | type Bop; + | -------- `Bop` defined here +... +LL | fn bar(_: &dyn Bar) {} + | ^^^ help: specify the associated type: `Bar` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0191`. diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs new file mode 100644 index 000000000..800624e31 --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.rs @@ -0,0 +1,17 @@ +// check-pass + +trait Foo { + type Bar + where + Self: Sized; +} + +fn foo(_: &dyn Foo) {} +//~^ WARN: unnecessary associated type bound for not object safe associated type +//~| WARN: unnecessary associated type bound for not object safe associated type +//~| WARN: unnecessary associated type bound for not object safe associated type + +#[allow(unused_associated_type_bounds)] +fn bar(_: &dyn Foo) {} + +fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr new file mode 100644 index 000000000..d0a4179fe --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized_unnecessary.stderr @@ -0,0 +1,27 @@ +warning: unnecessary associated type bound for not object safe associated type + --> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20 + | +LL | fn foo(_: &dyn Foo) {} + | ^^^^^^^^ help: remove this bound + | + = note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`. + = note: `#[warn(unused_associated_type_bounds)]` on by default + +warning: unnecessary associated type bound for not object safe associated type + --> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20 + | +LL | fn foo(_: &dyn Foo) {} + | ^^^^^^^^ help: remove this bound + | + = note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`. + +warning: unnecessary associated type bound for not object safe associated type + --> $DIR/assoc_type_bounds_sized_unnecessary.rs:9:20 + | +LL | fn foo(_: &dyn Foo) {} + | ^^^^^^^^ help: remove this bound + | + = note: this associated type has a `where Self: Sized` bound. Thus, while the associated type can be specified, it cannot be used in any way, because trait objects are not `Sized`. + +warning: 3 warnings emitted + diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.rs b/tests/ui/object-safety/assoc_type_bounds_sized_used.rs new file mode 100644 index 000000000..cf5345b1c --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.rs @@ -0,0 +1,20 @@ +//! This test checks that even if some associated types have +//! `where Self: Sized` bounds, those without still need to be +//! mentioned in trait objects. + +trait Bop { + type Bar: Default + where + Self: Sized; +} + +fn bop() { + let _ = ::Bar::default(); + //~^ ERROR: trait bounds were not satisfied + //~| ERROR: the size for values of type `T` cannot be known at compilation time +} + +fn main() { + bop::(); + //~^ ERROR: the size for values of type `dyn Bop` cannot be known at compilation time +} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr new file mode 100644 index 000000000..f8488d842 --- /dev/null +++ b/tests/ui/object-safety/assoc_type_bounds_sized_used.stderr @@ -0,0 +1,53 @@ +error[E0599]: the function or associated item `default` exists for associated type `::Bar`, but its trait bounds were not satisfied + --> $DIR/assoc_type_bounds_sized_used.rs:12:30 + | +LL | let _ = ::Bar::default(); + | ^^^^^^^ function or associated item cannot be called on `::Bar` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `T: Sized` + which is required by `::Bar: Default` +help: consider restricting the type parameter to satisfy the trait bound + | +LL | fn bop() where T: Sized { + | ++++++++++++++ + +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/assoc_type_bounds_sized_used.rs:12:13 + | +LL | fn bop() { + | - this type parameter needs to be `Sized` +LL | let _ = ::Bar::default(); + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | +note: required by a bound in `Bop::Bar` + --> $DIR/assoc_type_bounds_sized_used.rs:8:15 + | +LL | type Bar: Default + | --- required by a bound in this associated type +LL | where +LL | Self: Sized; + | ^^^^^ required by this bound in `Bop::Bar` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - fn bop() { +LL + fn bop() { + | + +error[E0277]: the size for values of type `dyn Bop` cannot be known at compilation time + --> $DIR/assoc_type_bounds_sized_used.rs:18:11 + | +LL | bop::(); + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Bop` +note: required by a bound in `bop` + --> $DIR/assoc_type_bounds_sized_used.rs:11:11 + | +LL | fn bop() { + | ^^^ required by this bound in `bop` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs index 3b8dc0b84..e393b159e 100644 --- a/tests/ui/offset-of/offset-of-dst-field.rs +++ b/tests/ui/offset-of/offset-of-dst-field.rs @@ -36,6 +36,8 @@ fn main() { offset_of!(Alpha, z); //~ ERROR the size for values of type offset_of!(Beta, z); //~ ERROR the size for values of type offset_of!(Gamma, z); //~ ERROR the size for values of type + offset_of!((u8, dyn Trait), 0); // ok + offset_of!((u8, dyn Trait), 1); //~ ERROR the size for values of type } fn delta() { diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr index 128c783d5..658678dc4 100644 --- a/tests/ui/offset-of/offset-of-dst-field.stderr +++ b/tests/ui/offset-of/offset-of-dst-field.stderr @@ -25,26 +25,17 @@ LL | offset_of!(Gamma, z); = help: the trait `Sized` is not implemented for `Extern` = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the size for values of type `Extern` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:43:5 - | -LL | offset_of!(Delta, z); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `Extern` - = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:44:5 + --> $DIR/offset-of-dst-field.rs:40:5 | -LL | offset_of!(Delta, z); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | offset_of!((u8, dyn Trait), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `dyn Trait` = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:42:5 + --> $DIR/offset-of-dst-field.rs:44:5 | LL | offset_of!(Delta, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -57,11 +48,29 @@ LL | struct Alpha { | ^^^^^ = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0277]: the size for values of type `Extern` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:45:5 + | +LL | offset_of!(Delta, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `Extern` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:46:5 + | +LL | offset_of!(Delta, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Trait` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:48:5 + --> $DIR/offset-of-dst-field.rs:50:5 | LL | fn generic_with_maybe_sized() -> usize { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | offset_of!(Delta, z) | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | @@ -72,6 +81,6 @@ LL - fn generic_with_maybe_sized() -> usize { LL + fn generic_with_maybe_sized() -> usize { | -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/offset-of/offset-of-must-use.rs b/tests/ui/offset-of/offset-of-must-use.rs new file mode 100644 index 000000000..e30145d7a --- /dev/null +++ b/tests/ui/offset-of/offset-of-must-use.rs @@ -0,0 +1,9 @@ +// check-pass + +#![feature(offset_of)] +#![warn(unused)] + +fn main() { + core::mem::offset_of!((String,), 0); + //~^ WARN unused return value of `must_use` that must be used +} diff --git a/tests/ui/offset-of/offset-of-must-use.stderr b/tests/ui/offset-of/offset-of-must-use.stderr new file mode 100644 index 000000000..5fe387a72 --- /dev/null +++ b/tests/ui/offset-of/offset-of-must-use.stderr @@ -0,0 +1,16 @@ +warning: unused return value of `must_use` that must be used + --> $DIR/offset-of-must-use.rs:7:5 + | +LL | core::mem::offset_of!((String,), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/offset-of-must-use.rs:4:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: `#[warn(unused_must_use)]` implied by `#[warn(unused)]` + = note: this warning originates in the macro `core::mem::offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: 1 warning emitted + diff --git a/tests/ui/offset-of/offset-of-output-type.stderr b/tests/ui/offset-of/offset-of-output-type.stderr index 6f8c94750..6133f3263 100644 --- a/tests/ui/offset-of/offset-of-output-type.stderr +++ b/tests/ui/offset-of/offset-of-output-type.stderr @@ -2,9 +2,7 @@ error[E0308]: mismatched types --> $DIR/offset-of-output-type.rs:12:17 | LL | let _: u8 = offset_of!(S, v); - | -- ^^^^^^^^^^^^^^^^ expected `u8`, found `usize` - | | - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `u8`, found `usize` | = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -12,9 +10,7 @@ error[E0308]: mismatched types --> $DIR/offset-of-output-type.rs:13:18 | LL | let _: u16 = offset_of!(S, v); - | --- ^^^^^^^^^^^^^^^^ expected `u16`, found `usize` - | | - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `u16`, found `usize` | = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -22,9 +18,7 @@ error[E0308]: mismatched types --> $DIR/offset-of-output-type.rs:14:18 | LL | let _: u32 = offset_of!(S, v); - | --- ^^^^^^^^^^^^^^^^ expected `u32`, found `usize` - | | - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `u32`, found `usize` | = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -32,9 +26,7 @@ error[E0308]: mismatched types --> $DIR/offset-of-output-type.rs:15:18 | LL | let _: u64 = offset_of!(S, v); - | --- ^^^^^^^^^^^^^^^^ expected `u64`, found `usize` - | | - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `u64`, found `usize` | = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -42,9 +34,7 @@ error[E0308]: mismatched types --> $DIR/offset-of-output-type.rs:16:20 | LL | let _: isize = offset_of!(S, v); - | ----- ^^^^^^^^^^^^^^^^ expected `isize`, found `usize` - | | - | expected due to this + | ^^^^^^^^^^^^^^^^ expected `isize`, found `usize` | = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/offset-of/offset-of-tuple-nested.rs b/tests/ui/offset-of/offset-of-tuple-nested.rs new file mode 100644 index 000000000..00fbb6bf8 --- /dev/null +++ b/tests/ui/offset-of/offset-of-tuple-nested.rs @@ -0,0 +1,32 @@ +// run-pass +// Test for issue #112204 -- make sure this goes through the entire compilation pipeline, +// similar to why `offset-of-unsized.rs` is also build-pass + +#![feature(offset_of)] +#![feature(builtin_syntax)] + +use std::mem::offset_of; + +type ComplexTup = ((u8, (u8, (u8, u16), u8)), (u8, u32, u16)); + +fn main() { + println!("{}", offset_of!(((u8, u8), u8), 0)); + println!("{}", offset_of!(((u8, u8), u8), 1)); + println!("{}", offset_of!(((u8, (u8, u8)), (u8, u8, u8)), 0.1.0)); + + // Complex case: do all combinations of spacings because the spacing determines what gets + // sent to the lexer. + println!("{}", offset_of!(ComplexTup, 0.1.1.1)); + println!("{}", builtin # offset_of(ComplexTup, 0. 1.1.1)); + println!("{}", offset_of!(ComplexTup, 0 . 1.1.1)); + println!("{}", offset_of!(ComplexTup, 0 .1.1.1)); + println!("{}", offset_of!(ComplexTup, 0.1 .1.1)); + println!("{}", offset_of!(ComplexTup, 0.1 . 1.1)); + println!("{}", offset_of!(ComplexTup, 0.1. 1.1)); + println!("{}", builtin # offset_of(ComplexTup, 0.1.1. 1)); + println!("{}", offset_of!(ComplexTup, 0.1.1 . 1)); + println!("{}", offset_of!(ComplexTup, 0.1.1 .1)); + + println!("{}", offset_of!(((u8, u16), (u32, u16, u8)), 0.0)); + println!("{}", offset_of!(((u8, u16), (u32, u16, u8)), 1.2)); +} diff --git a/tests/ui/offset-of/offset-of-tuple.rs b/tests/ui/offset-of/offset-of-tuple.rs new file mode 100644 index 000000000..e31b037ee --- /dev/null +++ b/tests/ui/offset-of/offset-of-tuple.rs @@ -0,0 +1,54 @@ +#![feature(offset_of)] +#![feature(builtin_syntax)] + +use std::mem::offset_of; + +fn main() { + offset_of!((u8, u8), _0); //~ ERROR no field `_0` + offset_of!((u8, u8), 01); //~ ERROR no field `01` + offset_of!((u8, u8), 1e2); //~ ERROR no field `1e2` + offset_of!((u8, u8), 1_u8); //~ ERROR no field `1_` + //~| ERROR suffixes on a tuple index + offset_of!((u8, u8), +1); //~ ERROR no rules expected + offset_of!((u8, u8), -1); //~ ERROR no rules expected + offset_of!((u8, u8), 1.); //~ ERROR expected identifier, found `)` + offset_of!((u8, u8), 1 .); //~ ERROR unexpected end of macro + builtin # offset_of((u8, u8), 1e2); //~ ERROR no field `1e2` + builtin # offset_of((u8, u8), _0); //~ ERROR no field `_0` + builtin # offset_of((u8, u8), 01); //~ ERROR no field `01` + builtin # offset_of((u8, u8), 1_u8); //~ ERROR no field `1_` + //~| ERROR suffixes on a tuple index + // We need to put these into curly braces, otherwise only one of the + // errors will be emitted and the others suppressed. + { builtin # offset_of((u8, u8), +1) }; //~ ERROR expected identifier, found `+` + { builtin # offset_of((u8, u8), 1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of((u8, u8), 1 .) }; //~ ERROR expected identifier, found `)` +} + +type ComplexTup = ((u8, (u8, u8)), u8); + +fn nested() { + offset_of!(((u8, u16), (u32, u16, u8)), 0.2); //~ ERROR no field `2` + offset_of!(((u8, u16), (u32, u16, u8)), 1.2); + offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0); //~ ERROR no field `0` + + // All combinations of spaces (this sends different tokens to the parser) + offset_of!(ComplexTup, 0.0.1.); //~ ERROR expected identifier + offset_of!(ComplexTup, 0 .0.1.); //~ ERROR unexpected end of macro + offset_of!(ComplexTup, 0 . 0.1.); //~ ERROR unexpected end of macro + offset_of!(ComplexTup, 0. 0.1.); //~ ERROR no rules expected + offset_of!(ComplexTup, 0.0 .1.); //~ ERROR expected identifier, found `)` + offset_of!(ComplexTup, 0.0 . 1.); //~ ERROR expected identifier, found `)` + offset_of!(ComplexTup, 0.0. 1.); //~ ERROR expected identifier, found `)` + + // Test for builtin too to ensure that the builtin syntax can also handle these cases + // We need to put these into curly braces, otherwise only one of the + // errors will be emitted and the others suppressed. + { builtin # offset_of(ComplexTup, 0.0.1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of(ComplexTup, 0 .0.1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of(ComplexTup, 0 . 0.1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of(ComplexTup, 0. 0.1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of(ComplexTup, 0.0 .1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of(ComplexTup, 0.0 . 1.) }; //~ ERROR expected identifier, found `)` + { builtin # offset_of(ComplexTup, 0.0. 1.) }; //~ ERROR expected identifier, found `)` +} diff --git a/tests/ui/offset-of/offset-of-tuple.stderr b/tests/ui/offset-of/offset-of-tuple.stderr new file mode 100644 index 000000000..ed9523458 --- /dev/null +++ b/tests/ui/offset-of/offset-of-tuple.stderr @@ -0,0 +1,226 @@ +error: suffixes on a tuple index are invalid + --> $DIR/offset-of-tuple.rs:19:35 + | +LL | builtin # offset_of((u8, u8), 1_u8); + | ^^^^ invalid suffix `u8` + +error: expected identifier, found `+` + --> $DIR/offset-of-tuple.rs:23:37 + | +LL | { builtin # offset_of((u8, u8), +1) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:24:39 + | +LL | { builtin # offset_of((u8, u8), 1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:25:40 + | +LL | { builtin # offset_of((u8, u8), 1 .) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:47:45 + | +LL | { builtin # offset_of(ComplexTup, 0.0.1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:48:46 + | +LL | { builtin # offset_of(ComplexTup, 0 .0.1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:49:47 + | +LL | { builtin # offset_of(ComplexTup, 0 . 0.1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:50:46 + | +LL | { builtin # offset_of(ComplexTup, 0. 0.1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:51:46 + | +LL | { builtin # offset_of(ComplexTup, 0.0 .1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:52:47 + | +LL | { builtin # offset_of(ComplexTup, 0.0 . 1.) }; + | ^ expected identifier + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:53:46 + | +LL | { builtin # offset_of(ComplexTup, 0.0. 1.) }; + | ^ expected identifier + +error: suffixes on a tuple index are invalid + --> $DIR/offset-of-tuple.rs:10:26 + | +LL | offset_of!((u8, u8), 1_u8); + | ^^^^ invalid suffix `u8` + +error: no rules expected the token `1` + --> $DIR/offset-of-tuple.rs:12:27 + | +LL | offset_of!((u8, u8), +1); + | ^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: no rules expected the token `1` + --> $DIR/offset-of-tuple.rs:13:27 + | +LL | offset_of!((u8, u8), -1); + | ^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:14:5 + | +LL | offset_of!((u8, u8), 1.); + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: unexpected end of macro invocation + --> $DIR/offset-of-tuple.rs:15:29 + | +LL | offset_of!((u8, u8), 1 .); + | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fields:tt` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:36:5 + | +LL | offset_of!(ComplexTup, 0.0.1.); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: unexpected end of macro invocation + --> $DIR/offset-of-tuple.rs:37:35 + | +LL | offset_of!(ComplexTup, 0 .0.1.); + | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fields:tt` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + +error: unexpected end of macro invocation + --> $DIR/offset-of-tuple.rs:38:36 + | +LL | offset_of!(ComplexTup, 0 . 0.1.); + | ^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$fields:tt` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + +error: no rules expected the token `0.1` + --> $DIR/offset-of-tuple.rs:39:31 + | +LL | offset_of!(ComplexTup, 0. 0.1.); + | ^^^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:40:5 + | +LL | offset_of!(ComplexTup, 0.0 .1.); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:41:5 + | +LL | offset_of!(ComplexTup, 0.0 . 1.); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected identifier, found `)` + --> $DIR/offset-of-tuple.rs:42:5 + | +LL | offset_of!(ComplexTup, 0.0. 1.); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + | + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0609]: no field `_0` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:7:26 + | +LL | offset_of!((u8, u8), _0); + | ^^ + +error[E0609]: no field `01` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:8:26 + | +LL | offset_of!((u8, u8), 01); + | ^^ + +error[E0609]: no field `1e2` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:9:26 + | +LL | offset_of!((u8, u8), 1e2); + | ^^^ + +error[E0609]: no field `1_` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:10:26 + | +LL | offset_of!((u8, u8), 1_u8); + | ^^^^ + +error[E0609]: no field `1e2` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:16:35 + | +LL | builtin # offset_of((u8, u8), 1e2); + | ^^^ + +error[E0609]: no field `_0` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:17:35 + | +LL | builtin # offset_of((u8, u8), _0); + | ^^ + +error[E0609]: no field `01` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:18:35 + | +LL | builtin # offset_of((u8, u8), 01); + | ^^ + +error[E0609]: no field `1_` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:19:35 + | +LL | builtin # offset_of((u8, u8), 1_u8); + | ^^^^ + +error[E0609]: no field `2` on type `(u8, u16)` + --> $DIR/offset-of-tuple.rs:31:47 + | +LL | offset_of!(((u8, u16), (u32, u16, u8)), 0.2); + | ^ + +error[E0609]: no field `0` on type `u8` + --> $DIR/offset-of-tuple.rs:33:49 + | +LL | offset_of!(((u8, u16), (u32, u16, u8)), 1.2.0); + | ^ + +error: aborting due to 33 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/offset-of/offset-of-unsized.rs b/tests/ui/offset-of/offset-of-unsized.rs new file mode 100644 index 000000000..49c8328da --- /dev/null +++ b/tests/ui/offset-of/offset-of-unsized.rs @@ -0,0 +1,16 @@ +// build-pass +// regression test for #112051, not in `offset-of-dst` as the issue is in codegen, +// and isn't triggered in the presence of typeck errors + +#![feature(offset_of)] + +struct S { + a: u64, + b: T, +} +trait Tr {} + +fn main() { + let _a = core::mem::offset_of!(S, a); + let _b = core::mem::offset_of!((u64, dyn Tr), 0); +} diff --git a/tests/ui/on-unimplemented/multiple-impls.stderr b/tests/ui/on-unimplemented/multiple-impls.stderr index d628b159a..3d0e36db7 100644 --- a/tests/ui/on-unimplemented/multiple-impls.stderr +++ b/tests/ui/on-unimplemented/multiple-impls.stderr @@ -8,8 +8,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:33:5 @@ -19,8 +19,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:37:33 @@ -32,8 +32,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:37:5 @@ -43,8 +43,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:41:33 @@ -56,8 +56,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:41:5 @@ -67,8 +67,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:33:5 @@ -78,8 +78,8 @@ LL | Index::index(&[] as &[i32], 2u32); | = help: the trait `Index` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:37:5 @@ -89,8 +89,8 @@ LL | Index::index(&[] as &[i32], Foo(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:41:5 @@ -100,8 +100,8 @@ LL | Index::index(&[] as &[i32], Bar(2u32)); | = help: the trait `Index>` is not implemented for `[i32]` = help: the following other types implement trait `Index`: - <[i32] as Index>> <[i32] as Index>> + <[i32] as Index>> error: aborting due to 9 previous errors diff --git a/tests/ui/on-unimplemented/slice-index.stderr b/tests/ui/on-unimplemented/slice-index.stderr index a7ec3bda8..b9bca211f 100644 --- a/tests/ui/on-unimplemented/slice-index.stderr +++ b/tests/ui/on-unimplemented/slice-index.stderr @@ -16,8 +16,8 @@ LL | x[..1i32]; | = help: the trait `SliceIndex<[i32]>` is not implemented for `RangeTo` = help: the following other types implement trait `SliceIndex`: - as SliceIndex<[T]>> as SliceIndex> + as SliceIndex<[T]>> = note: required for `[i32]` to implement `Index>` error: aborting due to 2 previous errors diff --git a/tests/ui/on-unimplemented/sum.stderr b/tests/ui/on-unimplemented/sum.stderr index 2a316dba7..a2357e49b 100644 --- a/tests/ui/on-unimplemented/sum.stderr +++ b/tests/ui/on-unimplemented/sum.stderr @@ -6,8 +6,8 @@ LL | vec![(), ()].iter().sum::(); | = help: the trait `Sum<&()>` is not implemented for `i32` = help: the following other types implement trait `Sum`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/sum.rs:4:18 | @@ -26,8 +26,8 @@ LL | vec![(), ()].iter().product::(); | = help: the trait `Product<&()>` is not implemented for `i32` = help: the following other types implement trait `Product`: - > + > note: the method call chain might not have had the expected associated types --> $DIR/sum.rs:7:18 | diff --git a/tests/ui/packed/issue-27060-2.stderr b/tests/ui/packed/issue-27060-2.stderr index 0836ceaec..cf5f4e530 100644 --- a/tests/ui/packed/issue-27060-2.stderr +++ b/tests/ui/packed/issue-27060-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/issue-27060-2.rs:3:11 | LL | pub struct Bad { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | data: T, | ^ doesn't have a size known at compile-time | diff --git a/tests/ui/parser/bad-escape-suggest-raw-string.rs b/tests/ui/parser/bad-escape-suggest-raw-string.rs index 978b92cbc..06df82d28 100644 --- a/tests/ui/parser/bad-escape-suggest-raw-string.rs +++ b/tests/ui/parser/bad-escape-suggest-raw-string.rs @@ -2,6 +2,6 @@ fn main() { let ok = r"ab\[c"; let bad = "ab\[c"; //~^ ERROR unknown character escape: `[` - //~| HELP for more information, visit + //~| HELP for more information, visit //~| HELP if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal } diff --git a/tests/ui/parser/bad-escape-suggest-raw-string.stderr b/tests/ui/parser/bad-escape-suggest-raw-string.stderr index fc34bd328..45d24bc0f 100644 --- a/tests/ui/parser/bad-escape-suggest-raw-string.stderr +++ b/tests/ui/parser/bad-escape-suggest-raw-string.stderr @@ -4,7 +4,7 @@ error: unknown character escape: `[` LL | let bad = "ab\[c"; | ^ unknown character escape | - = help: for more information, visit + = help: for more information, visit help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal | LL | let bad = r"ab\[c"; diff --git a/tests/ui/parser/bad-interpolated-block.stderr b/tests/ui/parser/bad-interpolated-block.stderr index 2a0999afd..651036c51 100644 --- a/tests/ui/parser/bad-interpolated-block.stderr +++ b/tests/ui/parser/bad-interpolated-block.stderr @@ -10,6 +10,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | 'lab: { $b }; + | + + error: cannot use a `block` macro fragment here --> $DIR/bad-interpolated-block.rs:6:16 @@ -23,6 +27,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | unsafe { $b }; + | + + error: cannot use a `block` macro fragment here --> $DIR/bad-interpolated-block.rs:7:23 @@ -34,6 +42,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | |x: u8| -> () { $b }; + | + + error: aborting due to 3 previous errors diff --git a/tests/ui/parser/byte-literals.stderr b/tests/ui/parser/byte-literals.stderr index efa55ae05..5b414c892 100644 --- a/tests/ui/parser/byte-literals.stderr +++ b/tests/ui/parser/byte-literals.stderr @@ -4,7 +4,7 @@ error: unknown byte escape: `f` LL | static FOO: u8 = b'\f'; | ^ unknown byte escape | - = help: for more information, visit + = help: for more information, visit error: unknown byte escape: `f` --> $DIR/byte-literals.rs:6:8 @@ -12,7 +12,7 @@ error: unknown byte escape: `f` LL | b'\f'; | ^ unknown byte escape | - = help: for more information, visit + = help: for more information, visit error: invalid character in numeric character escape: `Z` --> $DIR/byte-literals.rs:7:10 diff --git a/tests/ui/parser/byte-string-literals.stderr b/tests/ui/parser/byte-string-literals.stderr index 5b96cc3d1..655b6998e 100644 --- a/tests/ui/parser/byte-string-literals.stderr +++ b/tests/ui/parser/byte-string-literals.stderr @@ -4,7 +4,7 @@ error: unknown byte escape: `f` LL | static FOO: &'static [u8] = b"\f"; | ^ unknown byte escape | - = help: for more information, visit + = help: for more information, visit error: unknown byte escape: `f` --> $DIR/byte-string-literals.rs:4:8 @@ -12,7 +12,7 @@ error: unknown byte escape: `f` LL | b"\f"; | ^ unknown byte escape | - = help: for more information, visit + = help: for more information, visit error: invalid character in numeric character escape: `Z` --> $DIR/byte-string-literals.rs:5:10 diff --git a/tests/ui/parser/foreign-ty-semantic-fail.rs b/tests/ui/parser/foreign-ty-semantic-fail.rs index 96b15232b..4d30086e7 100644 --- a/tests/ui/parser/foreign-ty-semantic-fail.rs +++ b/tests/ui/parser/foreign-ty-semantic-fail.rs @@ -15,4 +15,5 @@ extern "C" { //~^ ERROR incorrect `type` inside `extern` block type E: where; + //~^ ERROR `type`s inside `extern` blocks cannot have `where` clauses } diff --git a/tests/ui/parser/foreign-ty-semantic-fail.stderr b/tests/ui/parser/foreign-ty-semantic-fail.stderr index 588e4966a..2b400dfea 100644 --- a/tests/ui/parser/foreign-ty-semantic-fail.stderr +++ b/tests/ui/parser/foreign-ty-semantic-fail.stderr @@ -61,5 +61,16 @@ LL | type D = u8; | = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html -error: aborting due to 6 previous errors +error: `type`s inside `extern` blocks cannot have `where` clauses + --> $DIR/foreign-ty-semantic-fail.rs:17:13 + | +LL | extern "C" { + | ---------- `extern` block begins here +... +LL | type E: where; + | ^^^^^ help: remove the `where` clause + | + = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html + +error: aborting due to 7 previous errors diff --git a/tests/ui/parser/issue-112188.fixed b/tests/ui/parser/issue-112188.fixed new file mode 100644 index 000000000..5e73d8e38 --- /dev/null +++ b/tests/ui/parser/issue-112188.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo { x: i32 } + +fn main() { + let f = Foo { x: 0 }; + let Foo { .. } = f; + let Foo { .. } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; + let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` +} diff --git a/tests/ui/parser/issue-112188.rs b/tests/ui/parser/issue-112188.rs new file mode 100644 index 000000000..27ca192e5 --- /dev/null +++ b/tests/ui/parser/issue-112188.rs @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo { x: i32 } + +fn main() { + let f = Foo { x: 0 }; + let Foo { .. } = f; + let Foo { .., } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; + let Foo { .., x } = f; //~ ERROR expected `}`, found `,` + let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` +} diff --git a/tests/ui/parser/issue-112188.stderr b/tests/ui/parser/issue-112188.stderr new file mode 100644 index 000000000..6d2d8e6a3 --- /dev/null +++ b/tests/ui/parser/issue-112188.stderr @@ -0,0 +1,37 @@ +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:10:17 + | +LL | let Foo { .., } = f; + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:12:17 + | +LL | let Foo { .., x } = f; + | --^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | +help: move the `..` to the end of the field list + | +LL - let Foo { .., x } = f; +LL + let Foo { x, .. } = f; + | + +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:13:17 + | +LL | let Foo { .., x, .. } = f; + | --^- + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | help: remove the starting `..` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issue-113342.rs b/tests/ui/parser/issue-113342.rs new file mode 100644 index 000000000..18b502736 --- /dev/null +++ b/tests/ui/parser/issue-113342.rs @@ -0,0 +1,9 @@ +#[link(name = "my_c_library")] +extern "C" { + fn my_c_function(x: i32) -> bool; +} + +#[no_mangle] +extern "C" pub fn id(x: i32) -> i32 { x } //~ ERROR expected `fn`, found keyword `pub` + +fn main() {} diff --git a/tests/ui/parser/issue-113342.stderr b/tests/ui/parser/issue-113342.stderr new file mode 100644 index 000000000..a0c5e665f --- /dev/null +++ b/tests/ui/parser/issue-113342.stderr @@ -0,0 +1,11 @@ +error: expected `fn`, found keyword `pub` + --> $DIR/issue-113342.rs:7:12 + | +LL | extern "C" pub fn id(x: i32) -> i32 { x } + | -----------^^^ + | | | + | | expected `fn` + | help: visibility `pub` must come before `extern "C"`: `pub extern "C"` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issue-49257.stderr b/tests/ui/parser/issue-49257.stderr index 846467f7f..97e16f88b 100644 --- a/tests/ui/parser/issue-49257.stderr +++ b/tests/ui/parser/issue-49257.stderr @@ -25,7 +25,7 @@ LL | let Point { .., y } = p; help: move the `..` to the end of the field list | LL - let Point { .., y } = p; -LL + let Point { y , .. } = p; +LL + let Point { y, .. } = p; | error: expected `}`, found `,` diff --git a/tests/ui/parser/issues/issue-111692.rs b/tests/ui/parser/issues/issue-111692.rs new file mode 100644 index 000000000..56096f706 --- /dev/null +++ b/tests/ui/parser/issues/issue-111692.rs @@ -0,0 +1,32 @@ +mod module { + #[derive(Eq, PartialEq)] + pub struct Type { + pub x: u8, + pub y: u8, + } + + pub const C: u8 = 32u8; +} + +fn test(x: module::Type) { + if x == module::Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + +fn test2(x: module::Type) { + if x ==module::Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + + +fn test3(x: module::Type) { + if x == Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + +fn test4(x: module::Type) { + if x == demo_module::Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + +fn main() { } diff --git a/tests/ui/parser/issues/issue-111692.stderr b/tests/ui/parser/issues/issue-111692.stderr new file mode 100644 index 000000000..068b0483b --- /dev/null +++ b/tests/ui/parser/issues/issue-111692.stderr @@ -0,0 +1,46 @@ +error: invalid struct literal + --> $DIR/issue-111692.rs:12:21 + | +LL | if x == module::Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x == (module::Type { x: module::C, y: 1 }) { + | + + + +error: invalid struct literal + --> $DIR/issue-111692.rs:17:20 + | +LL | if x ==module::Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x ==(module::Type { x: module::C, y: 1 }) { + | + + + +error: invalid struct literal + --> $DIR/issue-111692.rs:23:13 + | +LL | if x == Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x == (Type { x: module::C, y: 1 }) { + | + + + +error: invalid struct literal + --> $DIR/issue-111692.rs:28:26 + | +LL | if x == demo_module::Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x == (demo_module::Type { x: module::C, y: 1 }) { + | + + + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-112458.rs b/tests/ui/parser/issues/issue-112458.rs new file mode 100644 index 000000000..36895450c --- /dev/null +++ b/tests/ui/parser/issues/issue-112458.rs @@ -0,0 +1,4 @@ +fn main() { + println!("{}", x.); //~ ERROR unexpected token: `)` + //~^ ERROR cannot find value `x` in this scope +} diff --git a/tests/ui/parser/issues/issue-112458.stderr b/tests/ui/parser/issues/issue-112458.stderr new file mode 100644 index 000000000..54a8f1d03 --- /dev/null +++ b/tests/ui/parser/issues/issue-112458.stderr @@ -0,0 +1,15 @@ +error: unexpected token: `)` + --> $DIR/issue-112458.rs:2:22 + | +LL | println!("{}", x.); + | ^ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-112458.rs:2:20 + | +LL | println!("{}", x.); + | ^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/labeled-no-colon-expr.stderr b/tests/ui/parser/labeled-no-colon-expr.stderr index 62288fe15..4d61d9c14 100644 --- a/tests/ui/parser/labeled-no-colon-expr.stderr +++ b/tests/ui/parser/labeled-no-colon-expr.stderr @@ -77,6 +77,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | 'l5 { $b }; + | + + error: labeled expression must be followed by `:` --> $DIR/labeled-no-colon-expr.rs:14:8 diff --git a/tests/ui/parser/lit-err-in-macro.rs b/tests/ui/parser/lit-err-in-macro.rs new file mode 100644 index 000000000..cff8ee6b4 --- /dev/null +++ b/tests/ui/parser/lit-err-in-macro.rs @@ -0,0 +1,10 @@ +macro_rules! f { + ($abi:literal) => { + extern $abi fn f() {} + } +} + +f!("Foo"__); +//~^ ERROR suffixes on string literals are invalid + +fn main() {} diff --git a/tests/ui/parser/lit-err-in-macro.stderr b/tests/ui/parser/lit-err-in-macro.stderr new file mode 100644 index 000000000..a61fb5c85 --- /dev/null +++ b/tests/ui/parser/lit-err-in-macro.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/lit-err-in-macro.rs:7:4 + | +LL | f!("Foo"__); + | ^^^^^^^ invalid suffix `__` + +error: aborting due to previous error + diff --git a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr b/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr index 7fd7ffc94..dedbad909 100644 --- a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr +++ b/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr @@ -4,7 +4,7 @@ error: invalid struct literal LL | if Example { a: one(), }.is_pos() { | ^^^^^^^^^^^^^^^^^^^^^ | -help: you might need to surround the struct literal in parentheses +help: you might need to surround the struct literal with parentheses | LL | if (Example { a: one(), }).is_pos() { | + + diff --git a/tests/ui/parser/typod-const-in-const-param-def.rs b/tests/ui/parser/typod-const-in-const-param-def.rs new file mode 100644 index 000000000..85d3ebba5 --- /dev/null +++ b/tests/ui/parser/typod-const-in-const-param-def.rs @@ -0,0 +1,16 @@ +pub fn foo() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +pub fn bar() {} +// OK + +pub fn baz() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +pub fn qux() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +pub fn quux() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +fn main() {} diff --git a/tests/ui/parser/typod-const-in-const-param-def.stderr b/tests/ui/parser/typod-const-in-const-param-def.stderr new file mode 100644 index 000000000..75d73c6ea --- /dev/null +++ b/tests/ui/parser/typod-const-in-const-param-def.stderr @@ -0,0 +1,46 @@ +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:1:12 + | +LL | pub fn foo() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn foo() {} + | ~~~~~ + +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:7:12 + | +LL | pub fn baz() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn baz() {} + | ~~~~~ + +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:10:15 + | +LL | pub fn qux() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn qux() {} + | ~~~~~ + +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:13:16 + | +LL | pub fn quux() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn quux() {} + | ~~~~~ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/utf16-be-without-bom.stderr b/tests/ui/parser/utf16-be-without-bom.stderr index 768d2c531..c041f3ecf 100644 Binary files a/tests/ui/parser/utf16-be-without-bom.stderr and b/tests/ui/parser/utf16-be-without-bom.stderr differ diff --git a/tests/ui/parser/utf16-le-without-bom.stderr b/tests/ui/parser/utf16-le-without-bom.stderr index 4f4b91e39..cc2220441 100644 Binary files a/tests/ui/parser/utf16-le-without-bom.stderr and b/tests/ui/parser/utf16-le-without-bom.stderr differ diff --git a/tests/ui/pattern/byte-string-inference.rs b/tests/ui/pattern/byte-string-inference.rs new file mode 100644 index 000000000..b1517de6b --- /dev/null +++ b/tests/ui/pattern/byte-string-inference.rs @@ -0,0 +1,15 @@ +// check-pass + +fn load() -> Option { + todo!() +} + +fn main() { + while let Some(tag) = load() { + match &tag { + b"NAME" => {} + b"DATA" => {} + _ => {} + } + } +} diff --git a/tests/ui/pattern/issue-110508.rs b/tests/ui/pattern/issue-110508.rs new file mode 100644 index 000000000..1024ff055 --- /dev/null +++ b/tests/ui/pattern/issue-110508.rs @@ -0,0 +1,38 @@ +// run-pass + +#[derive(PartialEq, Eq)] +pub enum Foo { + FooA(()), + FooB(Vec<()>), +} + +impl Foo { + const A1: Foo = Foo::FooA(()); + const A2: Foo = Self::FooA(()); + const A3: Self = Foo::FooA(()); + const A4: Self = Self::FooA(()); +} + +fn main() { + let foo = Foo::FooA(()); + + match foo { + Foo::A1 => {}, + _ => {}, + } + + match foo { + Foo::A2 => {}, + _ => {}, + } + + match foo { + Foo::A3 => {}, + _ => {}, + } + + match foo { + Foo::A4 => {}, + _ => {}, + } +} diff --git a/tests/ui/pattern/issue-72565.rs b/tests/ui/pattern/issue-72565.rs index 1e262fd50..21edb26de 100644 --- a/tests/ui/pattern/issue-72565.rs +++ b/tests/ui/pattern/issue-72565.rs @@ -3,6 +3,6 @@ const F: &'static dyn PartialEq = &7u32; fn main() { let a: &dyn PartialEq = &7u32; match a { - F => panic!(), //~ ERROR: `&dyn PartialEq` cannot be used in patterns + F => panic!(), //~ ERROR: `dyn PartialEq` cannot be used in patterns } } diff --git a/tests/ui/pattern/issue-72565.stderr b/tests/ui/pattern/issue-72565.stderr index 2f82616b2..051972069 100644 --- a/tests/ui/pattern/issue-72565.stderr +++ b/tests/ui/pattern/issue-72565.stderr @@ -1,4 +1,4 @@ -error: `&dyn PartialEq` cannot be used in patterns +error: `dyn PartialEq` cannot be used in patterns --> $DIR/issue-72565.rs:6:9 | LL | F => panic!(), diff --git a/tests/ui/pattern/issue-94866.rs b/tests/ui/pattern/issue-94866.rs new file mode 100644 index 000000000..c42034879 --- /dev/null +++ b/tests/ui/pattern/issue-94866.rs @@ -0,0 +1,14 @@ +macro_rules! m { + () => { + {} + }; +} + +enum Enum { A, B } + +fn main() { + match Enum::A { + //~^ ERROR non-exhaustive patterns + Enum::A => m!() + } +} diff --git a/tests/ui/pattern/issue-94866.stderr b/tests/ui/pattern/issue-94866.stderr new file mode 100644 index 000000000..b3c17ce89 --- /dev/null +++ b/tests/ui/pattern/issue-94866.stderr @@ -0,0 +1,21 @@ +error[E0004]: non-exhaustive patterns: `Enum::B` not covered + --> $DIR/issue-94866.rs:10:11 + | +LL | match Enum::A { + | ^^^^^^^ pattern `Enum::B` not covered + | +note: `Enum` defined here + --> $DIR/issue-94866.rs:7:16 + | +LL | enum Enum { A, B } + | ---- ^ not covered + = note: the matched value is of type `Enum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Enum::A => m!(), +LL + Enum::B => todo!() + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr index 49b6dfca6..5b81a8c3d 100644 --- a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr @@ -176,6 +176,7 @@ LL | match_guarded_arm!(0u8); | ^^^ pattern `_` not covered | = note: the matched value is of type `u8` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -183,7 +184,7 @@ LL + _ => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered - --> $DIR/empty-match.rs:133:24 + --> $DIR/empty-match.rs:134:24 | LL | match_guarded_arm!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered @@ -194,6 +195,7 @@ note: `NonEmptyStruct1` defined here LL | struct NonEmptyStruct1; | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct1` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -201,7 +203,7 @@ LL + NonEmptyStruct1 => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered - --> $DIR/empty-match.rs:137:24 + --> $DIR/empty-match.rs:139:24 | LL | match_guarded_arm!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered @@ -212,6 +214,7 @@ note: `NonEmptyStruct2` defined here LL | struct NonEmptyStruct2(bool); | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct2` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -219,7 +222,7 @@ LL + NonEmptyStruct2(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/empty-match.rs:141:24 + --> $DIR/empty-match.rs:144:24 | LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered @@ -230,6 +233,7 @@ note: `NonEmptyUnion1` defined here LL | union NonEmptyUnion1 { | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion1` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -237,7 +241,7 @@ LL + NonEmptyUnion1 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/empty-match.rs:145:24 + --> $DIR/empty-match.rs:149:24 | LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered @@ -248,6 +252,7 @@ note: `NonEmptyUnion2` defined here LL | union NonEmptyUnion2 { | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion2` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -255,7 +260,7 @@ LL + NonEmptyUnion2 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered - --> $DIR/empty-match.rs:149:24 + --> $DIR/empty-match.rs:154:24 | LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered @@ -268,6 +273,7 @@ LL | enum NonEmptyEnum1 { LL | Foo(bool), | ^^^ not covered = note: the matched value is of type `NonEmptyEnum1` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -275,7 +281,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered - --> $DIR/empty-match.rs:153:24 + --> $DIR/empty-match.rs:159:24 | LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered @@ -291,6 +297,7 @@ LL | Foo(bool), LL | Bar, | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ _ if false => {}, @@ -298,7 +305,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered - --> $DIR/empty-match.rs:157:24 + --> $DIR/empty-match.rs:164:24 | LL | match_guarded_arm!(NonEmptyEnum5::V1); | ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered @@ -309,6 +316,7 @@ note: `NonEmptyEnum5` defined here LL | enum NonEmptyEnum5 { | ^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyEnum5` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | LL ~ _ if false => {}, diff --git a/tests/ui/pattern/usefulness/empty-match.normal.stderr b/tests/ui/pattern/usefulness/empty-match.normal.stderr index f54a3f336..6d1745508 100644 --- a/tests/ui/pattern/usefulness/empty-match.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-match.normal.stderr @@ -175,6 +175,7 @@ LL | match_guarded_arm!(0u8); | ^^^ pattern `_` not covered | = note: the matched value is of type `u8` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -182,7 +183,7 @@ LL + _ => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct1` not covered - --> $DIR/empty-match.rs:133:24 + --> $DIR/empty-match.rs:134:24 | LL | match_guarded_arm!(NonEmptyStruct1); | ^^^^^^^^^^^^^^^ pattern `NonEmptyStruct1` not covered @@ -193,6 +194,7 @@ note: `NonEmptyStruct1` defined here LL | struct NonEmptyStruct1; | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct1` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -200,7 +202,7 @@ LL + NonEmptyStruct1 => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyStruct2(_)` not covered - --> $DIR/empty-match.rs:137:24 + --> $DIR/empty-match.rs:139:24 | LL | match_guarded_arm!(NonEmptyStruct2(true)); | ^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyStruct2(_)` not covered @@ -211,6 +213,7 @@ note: `NonEmptyStruct2` defined here LL | struct NonEmptyStruct2(bool); | ^^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyStruct2` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -218,7 +221,7 @@ LL + NonEmptyStruct2(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion1 { .. }` not covered - --> $DIR/empty-match.rs:141:24 + --> $DIR/empty-match.rs:144:24 | LL | match_guarded_arm!((NonEmptyUnion1 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion1 { .. }` not covered @@ -229,6 +232,7 @@ note: `NonEmptyUnion1` defined here LL | union NonEmptyUnion1 { | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion1` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -236,7 +240,7 @@ LL + NonEmptyUnion1 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyUnion2 { .. }` not covered - --> $DIR/empty-match.rs:145:24 + --> $DIR/empty-match.rs:149:24 | LL | match_guarded_arm!((NonEmptyUnion2 { foo: () })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyUnion2 { .. }` not covered @@ -247,6 +251,7 @@ note: `NonEmptyUnion2` defined here LL | union NonEmptyUnion2 { | ^^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyUnion2` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -254,7 +259,7 @@ LL + NonEmptyUnion2 { .. } => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum1::Foo(_)` not covered - --> $DIR/empty-match.rs:149:24 + --> $DIR/empty-match.rs:154:24 | LL | match_guarded_arm!(NonEmptyEnum1::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ pattern `NonEmptyEnum1::Foo(_)` not covered @@ -267,6 +272,7 @@ LL | enum NonEmptyEnum1 { LL | Foo(bool), | ^^^ not covered = note: the matched value is of type `NonEmptyEnum1` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ _ if false => {}, @@ -274,7 +280,7 @@ LL + NonEmptyEnum1::Foo(_) => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered - --> $DIR/empty-match.rs:153:24 + --> $DIR/empty-match.rs:159:24 | LL | match_guarded_arm!(NonEmptyEnum2::Foo(true)); | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered @@ -290,6 +296,7 @@ LL | Foo(bool), LL | Bar, | ^^^ not covered = note: the matched value is of type `NonEmptyEnum2` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ _ if false => {}, @@ -297,7 +304,7 @@ LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!() | error[E0004]: non-exhaustive patterns: `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered - --> $DIR/empty-match.rs:157:24 + --> $DIR/empty-match.rs:164:24 | LL | match_guarded_arm!(NonEmptyEnum5::V1); | ^^^^^^^^^^^^^^^^^ patterns `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered @@ -308,6 +315,7 @@ note: `NonEmptyEnum5` defined here LL | enum NonEmptyEnum5 { | ^^^^^^^^^^^^^ = note: the matched value is of type `NonEmptyEnum5` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | LL ~ _ if false => {}, diff --git a/tests/ui/pattern/usefulness/empty-match.rs b/tests/ui/pattern/usefulness/empty-match.rs index 062241faa..d56d2e3c8 100644 --- a/tests/ui/pattern/usefulness/empty-match.rs +++ b/tests/ui/pattern/usefulness/empty-match.rs @@ -128,34 +128,42 @@ fn main() { match_guarded_arm!(0u8); //~ ERROR `_` not covered //~| NOTE the matched value is of type + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE pattern `_` not covered //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyStruct1); //~ ERROR `NonEmptyStruct1` not covered //~| NOTE pattern `NonEmptyStruct1` not covered //~| NOTE the matched value is of type + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyStruct2(true)); //~ ERROR `NonEmptyStruct2(_)` not covered //~| NOTE the matched value is of type //~| NOTE pattern `NonEmptyStruct2(_)` not covered + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!((NonEmptyUnion1 { foo: () })); //~ ERROR `NonEmptyUnion1 { .. }` not covered //~| NOTE the matched value is of type //~| NOTE pattern `NonEmptyUnion1 { .. }` not covered + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!((NonEmptyUnion2 { foo: () })); //~ ERROR `NonEmptyUnion2 { .. }` not covered //~| NOTE the matched value is of type //~| NOTE pattern `NonEmptyUnion2 { .. }` not covered + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyEnum1::Foo(true)); //~ ERROR `NonEmptyEnum1::Foo(_)` not covered //~| NOTE the matched value is of type //~| NOTE pattern `NonEmptyEnum1::Foo(_)` not covered + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyEnum2::Foo(true)); //~ ERROR `NonEmptyEnum2::Foo(_)` and `NonEmptyEnum2::Bar` not covered //~| NOTE the matched value is of type //~| NOTE patterns `NonEmptyEnum2::Foo(_)` and + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! match_guarded_arm!(NonEmptyEnum5::V1); //~ ERROR `NonEmptyEnum5::V1`, `NonEmptyEnum5::V2`, `NonEmptyEnum5::V3` and 2 more not covered //~| NOTE the matched value is of type //~| NOTE patterns `NonEmptyEnum5::V1`, + //~| NOTE match arms with guards don't count towards exhaustivity //~| NOTE in this expansion of match_guarded_arm! } diff --git a/tests/ui/pattern/usefulness/issue-3601.rs b/tests/ui/pattern/usefulness/issue-3601.rs index 6215a2398..a6d2b11f4 100644 --- a/tests/ui/pattern/usefulness/issue-3601.rs +++ b/tests/ui/pattern/usefulness/issue-3601.rs @@ -1,19 +1,19 @@ #![feature(box_patterns)] struct HTMLImageData { - image: Option + image: Option, } struct ElementData { - kind: Box + kind: Box, } enum ElementKind { - HTMLImageElement(HTMLImageData) + HTMLImageElement(HTMLImageData), } enum NodeKind { - Element(ElementData) + Element(ElementData), } struct NodeData { @@ -27,8 +27,13 @@ fn main() { // n.b. span could be better match n.kind { - box NodeKind::Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns - box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true } + box NodeKind::Element(ed) => match ed.kind { + //~^ ERROR non-exhaustive patterns + //~| NOTE the matched value is of type + //~| NOTE match arms with guards don't count towards exhaustivity + //~| NOTE pattern `box _` not covered + //~| NOTE `Box` defined here + box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => true, }, }; } diff --git a/tests/ui/pattern/usefulness/issue-3601.stderr b/tests/ui/pattern/usefulness/issue-3601.stderr index 2f6b167d4..b8c987431 100644 --- a/tests/ui/pattern/usefulness/issue-3601.stderr +++ b/tests/ui/pattern/usefulness/issue-3601.stderr @@ -7,10 +7,11 @@ LL | box NodeKind::Element(ed) => match ed.kind { note: `Box` defined here --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: the matched value is of type `Box` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true }, -LL + box _ => todo!() +LL ~ box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => true, +LL ~ box _ => todo!(), | error: aborting due to previous error diff --git a/tests/ui/pattern/usefulness/match-non-exhaustive.rs b/tests/ui/pattern/usefulness/match-non-exhaustive.rs index 3b210a115..62c185d04 100644 --- a/tests/ui/pattern/usefulness/match-non-exhaustive.rs +++ b/tests/ui/pattern/usefulness/match-non-exhaustive.rs @@ -1,4 +1,5 @@ fn main() { match 0 { 1 => () } //~ ERROR non-exhaustive patterns match 0 { 0 if false => () } //~ ERROR non-exhaustive patterns + //-| NOTE match arms with guards don't count towards exhaustivity } diff --git a/tests/ui/pattern/usefulness/match-non-exhaustive.stderr b/tests/ui/pattern/usefulness/match-non-exhaustive.stderr index 08dde523a..4fa3a7292 100644 --- a/tests/ui/pattern/usefulness/match-non-exhaustive.stderr +++ b/tests/ui/pattern/usefulness/match-non-exhaustive.stderr @@ -17,6 +17,7 @@ LL | match 0 { 0 if false => () } | ^ pattern `_` not covered | = note: the matched value is of type `i32` + = note: match arms with guards don't count towards exhaustivity help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL | match 0 { 0 if false => (), _ => todo!() } diff --git a/tests/ui/polymorphization/drop_shims/simple.rs b/tests/ui/polymorphization/drop_shims/simple.rs index 2695dc6d4..5f10d5e83 100644 --- a/tests/ui/polymorphization/drop_shims/simple.rs +++ b/tests/ui/polymorphization/drop_shims/simple.rs @@ -14,7 +14,7 @@ fn foo( let bar = || { let _ = OnDrop(|| ()); }; - let _ = bar(); + bar(); } fn main() { diff --git a/tests/ui/polymorphization/drop_shims/transitive.rs b/tests/ui/polymorphization/drop_shims/transitive.rs index c22891171..283b8da13 100644 --- a/tests/ui/polymorphization/drop_shims/transitive.rs +++ b/tests/ui/polymorphization/drop_shims/transitive.rs @@ -19,7 +19,7 @@ fn foo( let bar = || { bar(|| {}) }; - let _ = bar(); + bar(); } fn main() { diff --git a/tests/ui/privacy/effective_visibilities_full_priv.rs b/tests/ui/privacy/effective_visibilities_full_priv.rs new file mode 100644 index 000000000..a26ae3bd1 --- /dev/null +++ b/tests/ui/privacy/effective_visibilities_full_priv.rs @@ -0,0 +1,21 @@ +#![feature(rustc_attrs)] +#![allow(private_in_public)] + +struct SemiPriv; + +mod m { + #[rustc_effective_visibility] + struct Priv; + //~^ ERROR not in the table + //~| ERROR not in the table + + #[rustc_effective_visibility] + pub fn foo() {} //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + + #[rustc_effective_visibility] + impl crate::SemiPriv { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + pub fn f(_: Priv) {} + } +} + +fn main() {} diff --git a/tests/ui/privacy/effective_visibilities_full_priv.stderr b/tests/ui/privacy/effective_visibilities_full_priv.stderr new file mode 100644 index 000000000..29d82e2ee --- /dev/null +++ b/tests/ui/privacy/effective_visibilities_full_priv.stderr @@ -0,0 +1,26 @@ +error: not in the table + --> $DIR/effective_visibilities_full_priv.rs:8:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + +error: not in the table + --> $DIR/effective_visibilities_full_priv.rs:8:5 + | +LL | struct Priv; + | ^^^^^^^^^^^ + +error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + --> $DIR/effective_visibilities_full_priv.rs:13:5 + | +LL | pub fn foo() {} + | ^^^^^^^^^^^^ + +error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) + --> $DIR/effective_visibilities_full_priv.rs:16:5 + | +LL | impl crate::SemiPriv { + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/privacy/export-tag-variant.stderr b/tests/ui/privacy/export-tag-variant.stderr index f73bd454d..e8906985e 100644 --- a/tests/ui/privacy/export-tag-variant.stderr +++ b/tests/ui/privacy/export-tag-variant.stderr @@ -2,7 +2,9 @@ error[E0603]: enum `Y` is private --> $DIR/export-tag-variant.rs:7:26 | LL | fn main() { let z = foo::Y::Y1; } - | ^ private enum + | ^ -- unit variant `Y1` is not publicly re-exported + | | + | private enum | note: the enum `Y` is defined here --> $DIR/export-tag-variant.rs:4:5 diff --git a/tests/ui/privacy/privacy-in-paths.stderr b/tests/ui/privacy/privacy-in-paths.stderr index 2eb3ebb51..9c3d5e97c 100644 --- a/tests/ui/privacy/privacy-in-paths.stderr +++ b/tests/ui/privacy/privacy-in-paths.stderr @@ -2,7 +2,9 @@ error[E0603]: module `bar` is private --> $DIR/privacy-in-paths.rs:24:16 | LL | ::foo::bar::baz::f(); - | ^^^ private module + | ^^^ - function `f` is not publicly re-exported + | | + | private module | note: the module `bar` is defined here --> $DIR/privacy-in-paths.rs:3:5 @@ -21,12 +23,18 @@ note: the module `bar` is defined here | LL | mod bar { | ^^^^^^^ +help: consider importing this struct through its public re-export instead + | +LL | foo::S::f(); + | ~~~~~~ error[E0603]: trait `T` is private --> $DIR/privacy-in-paths.rs:26:23 | LL | <() as ::foo::T>::Assoc::f(); - | ^ private trait + | ^ ----- associated type `Assoc` is not publicly re-exported + | | + | private trait | note: the trait `T` is defined here --> $DIR/privacy-in-paths.rs:8:5 diff --git a/tests/ui/privacy/privacy-ufcs.stderr b/tests/ui/privacy/privacy-ufcs.stderr index e93a458ce..f45f3d8ec 100644 --- a/tests/ui/privacy/privacy-ufcs.stderr +++ b/tests/ui/privacy/privacy-ufcs.stderr @@ -2,7 +2,9 @@ error[E0603]: trait `Bar` is private --> $DIR/privacy-ufcs.rs:12:20 | LL | ::baz(); - | ^^^ private trait + | ^^^ --- associated function `baz` is not publicly re-exported + | | + | private trait | note: the trait `Bar` is defined here --> $DIR/privacy-ufcs.rs:4:5 diff --git a/tests/ui/privacy/privacy1.stderr b/tests/ui/privacy/privacy1.stderr index 6ebed8ee0..ca8f242e0 100644 --- a/tests/ui/privacy/privacy1.stderr +++ b/tests/ui/privacy/privacy1.stderr @@ -50,7 +50,9 @@ error[E0603]: module `baz` is private --> $DIR/privacy1.rs:104:16 | LL | ::bar::baz::A::foo(); - | ^^^ private module + | ^^^ - struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -62,7 +64,9 @@ error[E0603]: module `baz` is private --> $DIR/privacy1.rs:105:16 | LL | ::bar::baz::A::bar(); - | ^^^ private module + | ^^^ - struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -74,7 +78,9 @@ error[E0603]: module `baz` is private --> $DIR/privacy1.rs:107:16 | LL | ::bar::baz::A.foo2(); - | ^^^ private module + | ^^^ - unit struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -86,7 +92,9 @@ error[E0603]: module `baz` is private --> $DIR/privacy1.rs:108:16 | LL | ::bar::baz::A.bar2(); - | ^^^ private module + | ^^^ - unit struct `A` is not publicly re-exported + | | + | private module | note: the module `baz` is defined here --> $DIR/privacy1.rs:50:5 @@ -98,7 +106,9 @@ error[E0603]: trait `B` is private --> $DIR/privacy1.rs:112:16 | LL | ::bar::B::foo(); - | ^ private trait + | ^ --- associated function `foo` is not publicly re-exported + | | + | private trait | note: the trait `B` is defined here --> $DIR/privacy1.rs:40:5 @@ -129,6 +139,10 @@ note: the module `baz` is defined here | LL | mod baz { | ^^^^^^^ +help: consider importing this function through its public re-export instead + | +LL | bar::foo(); + | ~~~~~~~~ error[E0603]: module `baz` is private --> $DIR/privacy1.rs:128:16 @@ -141,6 +155,10 @@ note: the module `baz` is defined here | LL | mod baz { | ^^^^^^^ +help: consider importing this function through its public re-export instead + | +LL | bar::bar(); + | ~~~~~~~~ error[E0603]: trait `B` is private --> $DIR/privacy1.rs:157:17 diff --git a/tests/ui/privacy/private-in-public-non-principal.rs b/tests/ui/privacy/private-in-public-non-principal.rs index ac1d5a9e6..a2284c930 100644 --- a/tests/ui/privacy/private-in-public-non-principal.rs +++ b/tests/ui/privacy/private-in-public-non-principal.rs @@ -1,5 +1,11 @@ #![feature(auto_traits)] #![feature(negative_impls)] +#![feature(type_privacy_lints)] +#![deny(private_interfaces)] + +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. pub trait PubPrincipal {} auto trait PrivNonPrincipal {} @@ -7,6 +13,7 @@ auto trait PrivNonPrincipal {} pub fn leak_dyn_nonprincipal() -> Box { loop {} } //~^ WARN private trait `PrivNonPrincipal` in public interface //~| WARN this was previously accepted +//~| ERROR trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal` #[deny(missing_docs)] fn container() { diff --git a/tests/ui/privacy/private-in-public-non-principal.stderr b/tests/ui/privacy/private-in-public-non-principal.stderr index de20cada4..1387f59cb 100644 --- a/tests/ui/privacy/private-in-public-non-principal.stderr +++ b/tests/ui/privacy/private-in-public-non-principal.stderr @@ -1,5 +1,5 @@ warning: private trait `PrivNonPrincipal` in public interface (error E0445) - --> $DIR/private-in-public-non-principal.rs:7:1 + --> $DIR/private-in-public-non-principal.rs:13:1 | LL | pub fn leak_dyn_nonprincipal() -> Box { loop {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,17 +8,34 @@ LL | pub fn leak_dyn_nonprincipal() -> Box = note: for more information, see issue #34537 = note: `#[warn(private_in_public)]` on by default +error: trait `PrivNonPrincipal` is more private than the item `leak_dyn_nonprincipal` + --> $DIR/private-in-public-non-principal.rs:13:1 + | +LL | pub fn leak_dyn_nonprincipal() -> Box { loop {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `leak_dyn_nonprincipal` is reachable at visibility `pub` + | +note: but trait `PrivNonPrincipal` is only usable at visibility `pub(crate)` + --> $DIR/private-in-public-non-principal.rs:11:1 + | +LL | auto trait PrivNonPrincipal {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/private-in-public-non-principal.rs:4:9 + | +LL | #![deny(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^ + error: missing documentation for an associated function - --> $DIR/private-in-public-non-principal.rs:14:9 + --> $DIR/private-in-public-non-principal.rs:21:9 | LL | pub fn check_doc_lint() {} | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/private-in-public-non-principal.rs:11:8 + --> $DIR/private-in-public-non-principal.rs:18:8 | LL | #[deny(missing_docs)] | ^^^^^^^^^^^^ -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/privacy/private-inferred-type-1.rs b/tests/ui/privacy/private-inferred-type-1.rs index d633189e3..b3eba53dd 100644 --- a/tests/ui/privacy/private-inferred-type-1.rs +++ b/tests/ui/privacy/private-inferred-type-1.rs @@ -5,14 +5,24 @@ trait TyParam { fn ty_param_secret(&self); } +trait Ref { + fn ref_secret(self); +} + mod m { struct Priv; impl ::Arr0 for [Priv; 0] { fn arr0_secret(&self) {} } impl ::TyParam for Option { fn ty_param_secret(&self) {} } + impl<'a> ::Ref for &'a Priv { fn ref_secret(self) {} } } +fn anyref<'a, T>() -> &'a T { panic!() } + fn main() { [].arr0_secret(); //~ ERROR type `Priv` is private None.ty_param_secret(); //~ ERROR type `Priv` is private + Ref::ref_secret(anyref()); + //~^ ERROR type `Priv` is private + //~| ERROR type `Priv` is private } diff --git a/tests/ui/privacy/private-inferred-type-1.stderr b/tests/ui/privacy/private-inferred-type-1.stderr index 245789f43..47c11d6ec 100644 --- a/tests/ui/privacy/private-inferred-type-1.stderr +++ b/tests/ui/privacy/private-inferred-type-1.stderr @@ -1,14 +1,26 @@ error: type `Priv` is private - --> $DIR/private-inferred-type-1.rs:16:5 + --> $DIR/private-inferred-type-1.rs:23:5 | LL | [].arr0_secret(); | ^^^^^^^^^^^^^^^^ private type error: type `Priv` is private - --> $DIR/private-inferred-type-1.rs:17:5 + --> $DIR/private-inferred-type-1.rs:24:5 | LL | None.ty_param_secret(); | ^^^^^^^^^^^^^^^^^^^^^^ private type -error: aborting due to 2 previous errors +error: type `Priv` is private + --> $DIR/private-inferred-type-1.rs:25:5 + | +LL | Ref::ref_secret(anyref()); + | ^^^^^^^^^^^^^^^ private type + +error: type `Priv` is private + --> $DIR/private-inferred-type-1.rs:25:21 + | +LL | Ref::ref_secret(anyref()); + | ^^^^^^^^ private type + +error: aborting due to 4 previous errors diff --git a/tests/ui/privacy/sealed-traits/private-trait-non-local.rs b/tests/ui/privacy/sealed-traits/private-trait-non-local.rs new file mode 100644 index 000000000..426f21cc7 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/private-trait-non-local.rs @@ -0,0 +1,4 @@ +extern crate core; +use core::slice::index::private_slice_index::Sealed; //~ ERROR module `index` is private +fn main() { +} diff --git a/tests/ui/privacy/sealed-traits/private-trait-non-local.stderr b/tests/ui/privacy/sealed-traits/private-trait-non-local.stderr new file mode 100644 index 000000000..294999798 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/private-trait-non-local.stderr @@ -0,0 +1,12 @@ +error[E0603]: module `index` is private + --> $DIR/private-trait-non-local.rs:2:18 + | +LL | use core::slice::index::private_slice_index::Sealed; + | ^^^^^ private module ------ trait `Sealed` is not publicly re-exported + | +note: the module `index` is defined here + --> $SRC_DIR/core/src/slice/mod.rs:LL:COL + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/privacy/sealed-traits/private-trait.rs b/tests/ui/privacy/sealed-traits/private-trait.rs new file mode 100644 index 000000000..bbcbaabfa --- /dev/null +++ b/tests/ui/privacy/sealed-traits/private-trait.rs @@ -0,0 +1,10 @@ +pub mod a { + mod b { + pub trait Hidden {} + } +} + +struct S; +impl a::b::Hidden for S {} //~ ERROR module `b` is private + +fn main() {} diff --git a/tests/ui/privacy/sealed-traits/private-trait.stderr b/tests/ui/privacy/sealed-traits/private-trait.stderr new file mode 100644 index 000000000..c7ec72ff1 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/private-trait.stderr @@ -0,0 +1,17 @@ +error[E0603]: module `b` is private + --> $DIR/private-trait.rs:8:9 + | +LL | impl a::b::Hidden for S {} + | ^ ------ trait `Hidden` is not publicly re-exported + | | + | private module + | +note: the module `b` is defined here + --> $DIR/private-trait.rs:2:5 + | +LL | mod b { + | ^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/privacy/sealed-traits/re-exported-trait.fixed b/tests/ui/privacy/sealed-traits/re-exported-trait.fixed new file mode 100644 index 000000000..79b6a6516 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/re-exported-trait.fixed @@ -0,0 +1,13 @@ +// run-rustfix + +pub mod a { + pub use self::b::Trait; + mod b { + pub trait Trait {} + } +} + +struct S; +impl a::Trait for S {} //~ ERROR module `b` is private + +fn main() {} diff --git a/tests/ui/privacy/sealed-traits/re-exported-trait.rs b/tests/ui/privacy/sealed-traits/re-exported-trait.rs new file mode 100644 index 000000000..5f96dfdcb --- /dev/null +++ b/tests/ui/privacy/sealed-traits/re-exported-trait.rs @@ -0,0 +1,13 @@ +// run-rustfix + +pub mod a { + pub use self::b::Trait; + mod b { + pub trait Trait {} + } +} + +struct S; +impl a::b::Trait for S {} //~ ERROR module `b` is private + +fn main() {} diff --git a/tests/ui/privacy/sealed-traits/re-exported-trait.stderr b/tests/ui/privacy/sealed-traits/re-exported-trait.stderr new file mode 100644 index 000000000..b630565d0 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/re-exported-trait.stderr @@ -0,0 +1,19 @@ +error[E0603]: module `b` is private + --> $DIR/re-exported-trait.rs:11:9 + | +LL | impl a::b::Trait for S {} + | ^ private module + | +note: the module `b` is defined here + --> $DIR/re-exported-trait.rs:5:5 + | +LL | mod b { + | ^^^^^ +help: consider importing this trait through its public re-export instead + | +LL | impl a::Trait for S {} + | ~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/privacy/sealed-traits/sealed-trait-local.rs b/tests/ui/privacy/sealed-traits/sealed-trait-local.rs new file mode 100644 index 000000000..778ddf0f8 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/sealed-trait-local.rs @@ -0,0 +1,19 @@ +// provide custom privacy error for sealed traits +pub mod a { + pub trait Sealed: self::b::Hidden { + fn foo() {} + } + + struct X; + impl Sealed for X {} + impl self::b::Hidden for X {} + + mod b { + pub trait Hidden {} + } +} + +struct S; +impl a::Sealed for S {} //~ ERROR the trait bound `S: Hidden` is not satisfied + +fn main() {} diff --git a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr new file mode 100644 index 000000000..d1052ce35 --- /dev/null +++ b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `S: Hidden` is not satisfied + --> $DIR/sealed-trait-local.rs:17:20 + | +LL | impl a::Sealed for S {} + | ^ the trait `Hidden` is not implemented for `S` + | +note: required by a bound in `Sealed` + --> $DIR/sealed-trait-local.rs:3:23 + | +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 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/privacy/unnameable_types.rs b/tests/ui/privacy/unnameable_types.rs new file mode 100644 index 000000000..eae20dd9d --- /dev/null +++ b/tests/ui/privacy/unnameable_types.rs @@ -0,0 +1,30 @@ +#![feature(type_privacy_lints)] +#![allow(private_in_public)] +#![deny(unnameable_types)] + +mod m { + pub struct PubStruct(pub i32); //~ ERROR struct `PubStruct` is reachable but cannot be named + + pub enum PubE { //~ ERROR enum `PubE` is reachable but cannot be named + V(i32), + } + + 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 + fn f() {} + } + + impl PubTr for PubStruct { + type Alias = i32; //~ ERROR associated type `::Alias` is reachable but cannot be named + fn f() {} + } +} + +pub trait Voldemort {} + +impl Voldemort for i32 {} +impl Voldemort for i32 {} +impl Voldemort for u32 where T: m::PubTr {} + +fn main() {} diff --git a/tests/ui/privacy/unnameable_types.stderr b/tests/ui/privacy/unnameable_types.stderr new file mode 100644 index 000000000..25eb5c943 --- /dev/null +++ b/tests/ui/privacy/unnameable_types.stderr @@ -0,0 +1,38 @@ +error: struct `PubStruct` is reachable but cannot be named + --> $DIR/unnameable_types.rs:6:5 + | +LL | pub struct PubStruct(pub i32); + | ^^^^^^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` + | +note: the lint level is defined here + --> $DIR/unnameable_types.rs:3:9 + | +LL | #![deny(unnameable_types)] + | ^^^^^^^^^^^^^^^^ + +error: enum `PubE` is reachable but cannot be named + --> $DIR/unnameable_types.rs:8:5 + | +LL | pub enum PubE { + | ^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` + +error: trait `PubTr` is reachable but cannot be named + --> $DIR/unnameable_types.rs:12:5 + | +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 + diff --git a/tests/ui/privacy/where-priv-type.rs b/tests/ui/privacy/where-priv-type.rs index 66ee9c4bb..2e0a6b3e7 100644 --- a/tests/ui/privacy/where-priv-type.rs +++ b/tests/ui/privacy/where-priv-type.rs @@ -3,8 +3,14 @@ #![crate_type = "lib"] #![feature(generic_const_exprs)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] +#![warn(private_bounds)] +#![warn(private_interfaces)] +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. struct PrivTy; trait PrivTr {} @@ -19,6 +25,7 @@ impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; } pub struct S //~^ WARNING private type `PrivTy` in public interface //~| WARNING hard error +//~| WARNING type `PrivTy` is more private than the item `S` where PrivTy: {} @@ -27,6 +34,7 @@ where pub enum E //~^ WARNING private type `PrivTy` in public interface //~| WARNING hard error +//~| WARNING type `PrivTy` is more private than the item `E` where PrivTy: {} @@ -35,6 +43,7 @@ where pub fn f() //~^ WARNING private type `PrivTy` in public interface //~| WARNING hard error +//~| WARNING type `PrivTy` is more private than the item `f` where PrivTy: {} @@ -42,12 +51,14 @@ where impl S //~^ ERROR private type `PrivTy` in public interface +//~| WARNING type `PrivTy` is more private than the item `S` where PrivTy: { pub fn f() //~^ WARNING private type `PrivTy` in public interface //~| WARNING hard error + //~| WARNING type `PrivTy` is more private than the item `S::f` where PrivTy: {} @@ -79,6 +90,7 @@ where { type AssocTy = Const<{ my_const_fn(U) }>; //~^ ERROR private type + //~| WARNING type `fn(u8) -> u8 {my_const_fn}` is more private than the item ` as Trait>::AssocTy` fn assoc_fn() -> Self::AssocTy { Const } diff --git a/tests/ui/privacy/where-priv-type.stderr b/tests/ui/privacy/where-priv-type.stderr index c5fb2cdb0..d6baf22b3 100644 --- a/tests/ui/privacy/where-priv-type.stderr +++ b/tests/ui/privacy/where-priv-type.stderr @@ -1,5 +1,5 @@ warning: private type `PrivTy` in public interface (error E0446) - --> $DIR/where-priv-type.rs:19:1 + --> $DIR/where-priv-type.rs:25:1 | LL | pub struct S | ^^^^^^^^^^^^ @@ -8,8 +8,25 @@ LL | pub struct S = note: for more information, see issue #34537 = note: `#[warn(private_in_public)]` on by default +warning: type `PrivTy` is more private than the item `S` + --> $DIR/where-priv-type.rs:25:1 + | +LL | pub struct S + | ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/where-priv-type.rs:15:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/where-priv-type.rs:8:9 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^ + warning: private type `PrivTy` in public interface (error E0446) - --> $DIR/where-priv-type.rs:27:1 + --> $DIR/where-priv-type.rs:34:1 | LL | pub enum E | ^^^^^^^^^^ @@ -17,12 +34,25 @@ LL | pub enum E = 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 #34537 +warning: type `PrivTy` is more private than the item `E` + --> $DIR/where-priv-type.rs:34:1 + | +LL | pub enum E + | ^^^^^^^^^^ enum `E` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/where-priv-type.rs:15:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ + warning: private type `PrivTy` in public interface (error E0446) - --> $DIR/where-priv-type.rs:35:1 + --> $DIR/where-priv-type.rs:43:1 | LL | / pub fn f() LL | | LL | | +LL | | LL | | where LL | | PrivTy: | |___________^ @@ -30,21 +60,51 @@ LL | | PrivTy: = 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 #34537 -error[E0446]: private type `PrivTy` in public interface +warning: type `PrivTy` is more private than the item `f` --> $DIR/where-priv-type.rs:43:1 | +LL | / pub fn f() +LL | | +LL | | +LL | | +LL | | where +LL | | PrivTy: + | |___________^ function `f` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/where-priv-type.rs:15:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ + +error[E0446]: private type `PrivTy` in public interface + --> $DIR/where-priv-type.rs:52:1 + | LL | struct PrivTy; | ------------- `PrivTy` declared as private ... LL | impl S | ^^^^^^ can't leak private type +warning: type `PrivTy` is more private than the item `S` + --> $DIR/where-priv-type.rs:52:1 + | +LL | impl S + | ^^^^^^ implementation `S` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/where-priv-type.rs:15:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ + warning: private type `PrivTy` in public interface (error E0446) - --> $DIR/where-priv-type.rs:48:5 + --> $DIR/where-priv-type.rs:58:5 | LL | / pub fn f() LL | | LL | | +LL | | LL | | where LL | | PrivTy: | |_______________^ @@ -52,8 +112,25 @@ LL | | PrivTy: = 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 #34537 +warning: type `PrivTy` is more private than the item `S::f` + --> $DIR/where-priv-type.rs:58:5 + | +LL | / pub fn f() +LL | | +LL | | +LL | | +LL | | where +LL | | PrivTy: + | |_______________^ associated function `S::f` is reachable at visibility `pub` + | +note: but type `PrivTy` is only usable at visibility `pub(crate)` + --> $DIR/where-priv-type.rs:15:1 + | +LL | struct PrivTy; + | ^^^^^^^^^^^^^ + error[E0446]: private type `fn(u8) -> u8 {my_const_fn}` in public interface - --> $DIR/where-priv-type.rs:80:5 + --> $DIR/where-priv-type.rs:91:5 | LL | type AssocTy = Const<{ my_const_fn(U) }>; | ^^^^^^^^^^^^ can't leak private type @@ -61,6 +138,23 @@ LL | type AssocTy = Const<{ my_const_fn(U) }>; LL | const fn my_const_fn(val: u8) -> u8 { | ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private -error: aborting due to 2 previous errors; 4 warnings emitted +warning: type `fn(u8) -> u8 {my_const_fn}` is more private than the item ` as Trait>::AssocTy` + --> $DIR/where-priv-type.rs:91:5 + | +LL | type AssocTy = Const<{ my_const_fn(U) }>; + | ^^^^^^^^^^^^ associated type ` as Trait>::AssocTy` is reachable at visibility `pub` + | +note: but type `fn(u8) -> u8 {my_const_fn}` is only usable at visibility `pub(crate)` + --> $DIR/where-priv-type.rs:99:1 + | +LL | const fn my_const_fn(val: u8) -> u8 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/where-priv-type.rs:9:9 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors; 10 warnings emitted For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/privacy/where-pub-type-impls-priv-trait.rs b/tests/ui/privacy/where-pub-type-impls-priv-trait.rs index 87c211df1..c59fdb7c7 100644 --- a/tests/ui/privacy/where-pub-type-impls-priv-trait.rs +++ b/tests/ui/privacy/where-pub-type-impls-priv-trait.rs @@ -2,8 +2,13 @@ #![crate_type = "lib"] #![feature(generic_const_exprs)] +#![feature(type_privacy_lints)] #![allow(incomplete_features)] +#![warn(private_bounds)] +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. struct PrivTy; trait PrivTr {} @@ -18,6 +23,7 @@ impl PubTrWithAssocTy for PrivTy { type AssocTy = PrivTy; } pub struct S //~^ ERROR private trait `PrivTr` in public interface +//~| WARNING trait `PrivTr` is more private than the item `S` where PubTy: PrivTr {} @@ -25,6 +31,7 @@ where pub enum E //~^ ERROR private trait `PrivTr` in public interface +//~| WARNING trait `PrivTr` is more private than the item `E` where PubTy: PrivTr {} @@ -32,6 +39,7 @@ where pub fn f() //~^ ERROR private trait `PrivTr` in public interface +//~| WARNING trait `PrivTr` is more private than the item `f` where PubTy: PrivTr {} @@ -39,11 +47,13 @@ where impl S //~^ ERROR private trait `PrivTr` in public interface +//~| WARNING trait `PrivTr` is more private than the item `S` where PubTy: PrivTr { pub fn f() //~^ ERROR private trait `PrivTr` in public interface + //~| WARNING trait `PrivTr` is more private than the item `S::f` where PubTy: PrivTr {} diff --git a/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr b/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr index a433cebbb..e2d7ce446 100644 --- a/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr +++ b/tests/ui/privacy/where-pub-type-impls-priv-trait.stderr @@ -1,5 +1,5 @@ error[E0445]: private trait `PrivTr` in public interface - --> $DIR/where-pub-type-impls-priv-trait.rs:19:1 + --> $DIR/where-pub-type-impls-priv-trait.rs:24:1 | LL | trait PrivTr {} | ------------ `PrivTr` declared as private @@ -7,8 +7,25 @@ LL | trait PrivTr {} LL | pub struct S | ^^^^^^^^^^^^ can't leak private trait +warning: trait `PrivTr` is more private than the item `S` + --> $DIR/where-pub-type-impls-priv-trait.rs:24:1 + | +LL | pub struct S + | ^^^^^^^^^^^^ struct `S` is reachable at visibility `pub` + | +note: but trait `PrivTr` is only usable at visibility `pub(crate)` + --> $DIR/where-pub-type-impls-priv-trait.rs:14:1 + | +LL | trait PrivTr {} + | ^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/where-pub-type-impls-priv-trait.rs:7:9 + | +LL | #![warn(private_bounds)] + | ^^^^^^^^^^^^^^ + error[E0445]: private trait `PrivTr` in public interface - --> $DIR/where-pub-type-impls-priv-trait.rs:26:1 + --> $DIR/where-pub-type-impls-priv-trait.rs:32:1 | LL | trait PrivTr {} | ------------ `PrivTr` declared as private @@ -16,39 +33,97 @@ LL | trait PrivTr {} LL | pub enum E | ^^^^^^^^^^ can't leak private trait +warning: trait `PrivTr` is more private than the item `E` + --> $DIR/where-pub-type-impls-priv-trait.rs:32:1 + | +LL | pub enum E + | ^^^^^^^^^^ enum `E` is reachable at visibility `pub` + | +note: but trait `PrivTr` is only usable at visibility `pub(crate)` + --> $DIR/where-pub-type-impls-priv-trait.rs:14:1 + | +LL | trait PrivTr {} + | ^^^^^^^^^^^^ + error[E0445]: private trait `PrivTr` in public interface - --> $DIR/where-pub-type-impls-priv-trait.rs:33:1 + --> $DIR/where-pub-type-impls-priv-trait.rs:40:1 | LL | trait PrivTr {} | ------------ `PrivTr` declared as private ... LL | / pub fn f() LL | | +LL | | LL | | where LL | | PubTy: PrivTr | |_________________^ can't leak private trait -error[E0445]: private trait `PrivTr` in public interface +warning: trait `PrivTr` is more private than the item `f` --> $DIR/where-pub-type-impls-priv-trait.rs:40:1 | +LL | / pub fn f() +LL | | +LL | | +LL | | where +LL | | PubTy: PrivTr + | |_________________^ function `f` is reachable at visibility `pub` + | +note: but trait `PrivTr` is only usable at visibility `pub(crate)` + --> $DIR/where-pub-type-impls-priv-trait.rs:14:1 + | +LL | trait PrivTr {} + | ^^^^^^^^^^^^ + +error[E0445]: private trait `PrivTr` in public interface + --> $DIR/where-pub-type-impls-priv-trait.rs:48:1 + | LL | trait PrivTr {} | ------------ `PrivTr` declared as private ... LL | impl S | ^^^^^^ can't leak private trait +warning: trait `PrivTr` is more private than the item `S` + --> $DIR/where-pub-type-impls-priv-trait.rs:48:1 + | +LL | impl S + | ^^^^^^ implementation `S` is reachable at visibility `pub` + | +note: but trait `PrivTr` is only usable at visibility `pub(crate)` + --> $DIR/where-pub-type-impls-priv-trait.rs:14:1 + | +LL | trait PrivTr {} + | ^^^^^^^^^^^^ + error[E0445]: private trait `PrivTr` in public interface - --> $DIR/where-pub-type-impls-priv-trait.rs:45:5 + --> $DIR/where-pub-type-impls-priv-trait.rs:54:5 | LL | trait PrivTr {} | ------------ `PrivTr` declared as private ... LL | / pub fn f() LL | | +LL | | LL | | where LL | | PubTy: PrivTr | |_____________________^ can't leak private trait -error: aborting due to 5 previous errors +warning: trait `PrivTr` is more private than the item `S::f` + --> $DIR/where-pub-type-impls-priv-trait.rs:54:5 + | +LL | / pub fn f() +LL | | +LL | | +LL | | where +LL | | PubTy: PrivTr + | |_____________________^ associated function `S::f` is reachable at visibility `pub` + | +note: but trait `PrivTr` is only usable at visibility `pub(crate)` + --> $DIR/where-pub-type-impls-priv-trait.rs:14:1 + | +LL | trait PrivTr {} + | ^^^^^^^^^^^^ + +error: aborting due to 5 previous errors; 5 warnings emitted For more information about this error, try `rustc --explain E0445`. diff --git a/tests/ui/proc-macro/auxiliary/api/cmp.rs b/tests/ui/proc-macro/auxiliary/api/cmp.rs index 5784a6e5d..ec3e637ac 100644 --- a/tests/ui/proc-macro/auxiliary/api/cmp.rs +++ b/tests/ui/proc-macro/auxiliary/api/cmp.rs @@ -1,18 +1,9 @@ -use proc_macro::{LineColumn, Punct, Spacing}; +use proc_macro::{Punct, Spacing}; pub fn test() { - test_line_column_ord(); test_punct_eq(); } -fn test_line_column_ord() { - let line0_column0 = LineColumn { line: 0, column: 0 }; - let line0_column1 = LineColumn { line: 0, column: 1 }; - let line1_column0 = LineColumn { line: 1, column: 0 }; - assert!(line0_column0 < line0_column1); - assert!(line0_column1 < line1_column0); -} - fn test_punct_eq() { let colon_alone = Punct::new(':', Spacing::Alone); assert_eq!(colon_alone, ':'); diff --git a/tests/ui/proc-macro/auxiliary/assert-span-pos.rs b/tests/ui/proc-macro/auxiliary/assert-span-pos.rs index 455c5c7c3..8126470ec 100644 --- a/tests/ui/proc-macro/auxiliary/assert-span-pos.rs +++ b/tests/ui/proc-macro/auxiliary/assert-span-pos.rs @@ -26,10 +26,9 @@ pub fn assert_span_pos(input: TokenStream) -> TokenStream { let line: usize = str1.parse().unwrap(); let col: usize = str2.parse().unwrap(); - let sp1s = sp1.start(); - if (line, col) != (sp1s.line, sp1s.column) { + if (line, col) != (sp1.line(), sp1.column()) { let msg = format!("line/column mismatch: ({}, {}) != ({}, {})", line, col, - sp1s.line, sp1s.column); + sp1.line(), sp1.column()); sp1.error(msg).emit(); } diff --git a/tests/ui/proc-macro/auxiliary/exports_no_mangle.rs b/tests/ui/proc-macro/auxiliary/exports_no_mangle.rs new file mode 100644 index 000000000..a8a478ffc --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/exports_no_mangle.rs @@ -0,0 +1,11 @@ +// force-host +// no-prefer-dynamic +#![crate_type="lib"] + +// Issue 111888: this crate (1.) is imported by a proc-macro crate and (2.) +// exports a no_mangle function; that combination of acts was broken for some +// period of time. See further discussion in the test file that imports this +// crate. + +#[no_mangle] +pub fn some_no_mangle_function() { } diff --git a/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs b/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs index c72306c3d..4ca3a0faa 100644 --- a/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs +++ b/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs @@ -81,7 +81,7 @@ fn expect_brace(tokens: &mut token_stream::IntoIter) -> token_stream::IntoIter { fn check_useful_span(token: TokenTree, expected_filename: &str) { let span = token.span(); - assert!(span.start().column < span.end().column); + assert!(span.column() < span.end().column()); let source_path = span.source_file().path(); let filename = source_path.components().last().unwrap(); diff --git a/tests/ui/proc-macro/crt-static.rs b/tests/ui/proc-macro/crt-static.rs index 020128fa2..78592f827 100644 --- a/tests/ui/proc-macro/crt-static.rs +++ b/tests/ui/proc-macro/crt-static.rs @@ -7,6 +7,7 @@ // build-pass // force-host // no-prefer-dynamic +// needs-dynamic-linking #![crate_type = "proc-macro"] diff --git a/tests/ui/proc-macro/derive-helper-shadowing.rs b/tests/ui/proc-macro/derive-helper-shadowing.rs index 80d982d25..4f25b4b0d 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.rs +++ b/tests/ui/proc-macro/derive-helper-shadowing.rs @@ -23,7 +23,7 @@ macro_rules! gen_helper_use { struct S { #[empty_helper] // OK, no ambiguity, derive helpers have highest priority field: [u8; { - use empty_helper; //~ ERROR `empty_helper` is ambiguous + use empty_helper; // OK, no ambiguity, derive helpers have highest priority #[empty_helper] // OK, no ambiguity, derive helpers have highest priority struct U; diff --git a/tests/ui/proc-macro/derive-helper-shadowing.stderr b/tests/ui/proc-macro/derive-helper-shadowing.stderr index de2c27a87..f284b1c54 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.stderr +++ b/tests/ui/proc-macro/derive-helper-shadowing.stderr @@ -16,9 +16,11 @@ error: cannot find attribute `empty_helper` in this scope LL | #[derive(GenHelperUse)] | ^^^^^^^^^^^^ | - = help: consider importing this attribute macro: - empty_helper = note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing this attribute macro through its public re-export + | +LL + use empty_helper; + | error: cannot find attribute `empty_helper` in this scope --> $DIR/derive-helper-shadowing.rs:14:11 @@ -29,28 +31,11 @@ LL | #[empty_helper] LL | gen_helper_use!(); | ----------------- in this macro invocation | - = help: consider importing this attribute macro: - crate::empty_helper = note: this error originates in the macro `gen_helper_use` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0659]: `empty_helper` is ambiguous - --> $DIR/derive-helper-shadowing.rs:26:13 +help: consider importing this attribute macro through its public re-export | -LL | use empty_helper; - | ^^^^^^^^^^^^ ambiguous name +LL + use crate::empty_helper; | - = note: ambiguous because of multiple potential import sources -note: `empty_helper` could refer to the derive helper attribute defined here - --> $DIR/derive-helper-shadowing.rs:22:10 - | -LL | #[derive(Empty)] - | ^^^^^ -note: `empty_helper` could also refer to the attribute macro imported here - --> $DIR/derive-helper-shadowing.rs:10:5 - | -LL | use test_macros::empty_attr as empty_helper; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `crate::empty_helper` to refer to this attribute macro unambiguously error[E0659]: `empty_helper` is ambiguous --> $DIR/derive-helper-shadowing.rs:19:3 @@ -84,6 +69,6 @@ LL | #[derive(Empty)] = note: for more information, see issue #79202 = note: `#[warn(legacy_derive_helpers)]` on by default -error: aborting due to 5 previous errors; 1 warning emitted +error: aborting due to 4 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs b/tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs new file mode 100644 index 000000000..4e5208e50 --- /dev/null +++ b/tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs @@ -0,0 +1,22 @@ +// build-pass +// force-host +// no-prefer-dynamic +// aux-build:exports_no_mangle.rs +#![crate_type = "proc-macro"] + +// Issue #111888: this proc-macro crate imports another crate that itself +// exports a no_mangle function. +// +// That combination was broken for a period of time, because: +// +// In PR #99944 we *stopped* exporting no_mangle symbols from +// proc-macro crates. The constructed linker version script still referred +// to them, but resolving that discrepancy was left as a FIXME in the code. +// +// In PR #108017 we started telling the linker to check (via the +// `--no-undefined-version` linker invocation flag) that every symbol referenced +// in the "linker version script" is actually present in the linker input. So +// the unresolved discrepancy from #99944 started surfacing as a compile-time +// error. + +extern crate exports_no_mangle; diff --git a/tests/ui/proc-macro/span-preservation.stderr b/tests/ui/proc-macro/span-preservation.stderr index 66c68be2f..8c15cb9de 100644 --- a/tests/ui/proc-macro/span-preservation.stderr +++ b/tests/ui/proc-macro/span-preservation.stderr @@ -32,7 +32,7 @@ error[E0560]: struct `Foo` has no field named `b` LL | let y = Foo { a: 10, b: 10isize }; | ^ `Foo` does not have this field | - = note: available fields are: `a` + = note: all struct fields are already assigned error[E0308]: mismatched types --> $DIR/span-preservation.rs:39:5 diff --git a/tests/ui/process/process-panic-after-fork.rs b/tests/ui/process/process-panic-after-fork.rs index da2683121..7c2fc296b 100644 --- a/tests/ui/process/process-panic-after-fork.rs +++ b/tests/ui/process/process-panic-after-fork.rs @@ -11,6 +11,8 @@ #![feature(never_type)] #![feature(panic_always_abort)] +#![allow(invalid_from_utf8)] + extern crate libc; use std::alloc::{GlobalAlloc, Layout}; diff --git a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs index 67f888c5e..cdeea6224 100644 --- a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs +++ b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.rs @@ -1,15 +1,25 @@ +#![feature(type_privacy_lints)] #![allow(non_camel_case_types)] // genus is always capitalized +#![warn(private_interfaces)] +//~^ NOTE the lint level is defined here + +// In this test both old and new private-in-public diagnostic were emitted. +// Old diagnostic will be deleted soon. +// See https://rust-lang.github.io/rfcs/2145-type-privacy.html. pub(crate) struct Snail; //~^ NOTE `Snail` declared as private +//~| NOTE but type `Snail` is only usable at visibility `pub(crate)` mod sea { pub(super) struct Turtle; //~^ NOTE `Turtle` declared as crate-private + //~| NOTE but type `Turtle` is only usable at visibility `pub(crate)` } struct Tortoise; //~^ NOTE `Tortoise` declared as private +//~| NOTE but type `Tortoise` is only usable at visibility `pub(crate)` pub struct Shell { pub(crate) creature: T, @@ -17,12 +27,18 @@ pub struct Shell { pub type Helix_pomatia = Shell; //~^ ERROR private type `Snail` in public interface +//~| WARNING type `Snail` is more private than the item `Helix_pomatia` //~| NOTE can't leak private type +//~| NOTE type alias `Helix_pomatia` is reachable at visibility `pub` pub type Dermochelys_coriacea = Shell; //~^ ERROR crate-private type `Turtle` in public interface +//~| WARNING type `Turtle` is more private than the item `Dermochelys_coriacea` //~| NOTE can't leak crate-private type +//~| NOTE type alias `Dermochelys_coriacea` is reachable at visibility `pub` pub type Testudo_graeca = Shell; //~^ ERROR private type `Tortoise` in public interface +//~| WARNING type `Tortoise` is more private than the item `Testudo_graeca` //~| NOTE can't leak private type +//~| NOTE type alias `Testudo_graeca` is reachable at visibility `pub` fn main() {} diff --git a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr index 39d4f5ac8..20e51e190 100644 --- a/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr +++ b/tests/ui/pub/issue-33174-restricted-type-in-public-interface.stderr @@ -1,5 +1,5 @@ error[E0446]: private type `Snail` in public interface - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:18:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1 | LL | pub(crate) struct Snail; | ----------------------- `Snail` declared as private @@ -7,8 +7,25 @@ LL | pub(crate) struct Snail; LL | pub type Helix_pomatia = Shell; | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type +warning: type `Snail` is more private than the item `Helix_pomatia` + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:28:1 + | +LL | pub type Helix_pomatia = Shell; + | ^^^^^^^^^^^^^^^^^^^^^^ type alias `Helix_pomatia` is reachable at visibility `pub` + | +note: but type `Snail` is only usable at visibility `pub(crate)` + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:10:1 + | +LL | pub(crate) struct Snail; + | ^^^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:3:9 + | +LL | #![warn(private_interfaces)] + | ^^^^^^^^^^^^^^^^^^ + error[E0446]: crate-private type `Turtle` in public interface - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:21:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1 | LL | pub(super) struct Turtle; | ------------------------ `Turtle` declared as crate-private @@ -16,8 +33,20 @@ LL | pub(super) struct Turtle; LL | pub type Dermochelys_coriacea = Shell; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak crate-private type +warning: type `Turtle` is more private than the item `Dermochelys_coriacea` + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:33:1 + | +LL | pub type Dermochelys_coriacea = Shell; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type alias `Dermochelys_coriacea` is reachable at visibility `pub` + | +note: but type `Turtle` is only usable at visibility `pub(crate)` + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:15:5 + | +LL | pub(super) struct Turtle; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0446]: private type `Tortoise` in public interface - --> $DIR/issue-33174-restricted-type-in-public-interface.rs:24:1 + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1 | LL | struct Tortoise; | --------------- `Tortoise` declared as private @@ -25,6 +54,18 @@ LL | struct Tortoise; LL | pub type Testudo_graeca = Shell; | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type -error: aborting due to 3 previous errors +warning: type `Tortoise` is more private than the item `Testudo_graeca` + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:38:1 + | +LL | pub type Testudo_graeca = Shell; + | ^^^^^^^^^^^^^^^^^^^^^^^ type alias `Testudo_graeca` is reachable at visibility `pub` + | +note: but type `Tortoise` is only usable at visibility `pub(crate)` + --> $DIR/issue-33174-restricted-type-in-public-interface.rs:20:1 + | +LL | struct Tortoise; + | ^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors; 3 warnings emitted For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/range/range-1.stderr b/tests/ui/range/range-1.stderr index 395639036..277d9b268 100644 --- a/tests/ui/range/range-1.stderr +++ b/tests/ui/range/range-1.stderr @@ -12,13 +12,13 @@ LL | for i in false..true {} | = help: the following other types implement trait `Step`: char - i128 + isize + i8 i16 i32 i64 - i8 - isize - u128 + i128 + usize and 5 others = note: required for `std::ops::Range` to implement `Iterator` = note: required for `std::ops::Range` to implement `IntoIterator` diff --git a/tests/ui/reachable/expr_return.rs b/tests/ui/reachable/expr_return.rs index 0fc43f450..0dbeb660e 100644 --- a/tests/ui/reachable/expr_return.rs +++ b/tests/ui/reachable/expr_return.rs @@ -7,7 +7,7 @@ fn a() { // Here we issue that the "2nd-innermost" return is unreachable, // but we stop there. - let x = {return {return {return;}}}; //~ ERROR unreachable + let x: () = {return {return {return;}}}; //~ ERROR unreachable } fn main() { } diff --git a/tests/ui/reachable/expr_return.stderr b/tests/ui/reachable/expr_return.stderr index e1bef80ae..3791559f4 100644 --- a/tests/ui/reachable/expr_return.stderr +++ b/tests/ui/reachable/expr_return.stderr @@ -1,11 +1,11 @@ error: unreachable expression - --> $DIR/expr_return.rs:10:22 + --> $DIR/expr_return.rs:10:26 | -LL | let x = {return {return {return;}}}; - | ^^^^^^^^------^^ - | | | - | | any code following this expression is unreachable - | unreachable expression +LL | let x: () = {return {return {return;}}}; + | ^^^^^^^^------^^ + | | | + | | any code following this expression is unreachable + | unreachable expression | note: the lint level is defined here --> $DIR/expr_return.rs:4:9 diff --git a/tests/ui/reachable/unreachable-variant.stderr b/tests/ui/reachable/unreachable-variant.stderr index 6c27a2756..ca1d2be65 100644 --- a/tests/ui/reachable/unreachable-variant.stderr +++ b/tests/ui/reachable/unreachable-variant.stderr @@ -2,7 +2,7 @@ error[E0603]: module `super_sekrit` is private --> $DIR/unreachable-variant.rs:6:21 | LL | let _x = other::super_sekrit::sooper_sekrit::baz; - | ^^^^^^^^^^^^ private module + | ^^^^^^^^^^^^ private module --- unit variant `baz` is not publicly re-exported | note: the module `super_sekrit` is defined here --> $DIR/auxiliary/unreachable_variant.rs:1:1 diff --git a/tests/ui/recursion/issue-83150.rs b/tests/ui/recursion/issue-83150.rs index 38353d161..75dcdc59f 100644 --- a/tests/ui/recursion/issue-83150.rs +++ b/tests/ui/recursion/issue-83150.rs @@ -2,6 +2,7 @@ // compile-flags: -Copt-level=0 // normalize-stderr-test: "long-type-\d+" -> "long-type-hash" //~^^^ ERROR overflow evaluating the requirement +// ignore-compare-mode-next-solver (hangs) fn main() { let mut iter = 0u8..1; diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index 64683ae3a..eae58771a 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-83150.rs:11:1 + --> $DIR/issue-83150.rs:12:1 | LL | fn func>(iter: &mut T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing @@ -9,10 +9,10 @@ LL | func(&mut iter.map(|x| x + 1)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>: Iterator` +error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:13:24: 13:27]>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `&mut Map<&mut std::ops::Range, [closure@$DIR/issue-83150.rs:12:24: 12:27]>` to implement `Iterator` + = 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' diff --git a/tests/ui/recursion/issue-95134.rs b/tests/ui/recursion/issue-95134.rs index 2f1cffa2f..7ee31d85c 100644 --- a/tests/ui/recursion/issue-95134.rs +++ b/tests/ui/recursion/issue-95134.rs @@ -3,6 +3,7 @@ // compile-flags: -Copt-level=0 // dont-check-failure-status // dont-check-compiler-stderr +// ignore-compare-mode-next-solver (hangs) pub fn encode_num(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { if n > 15 { diff --git a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs index 110635203..429548f11 100644 --- a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs +++ b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs @@ -20,7 +20,6 @@ trait Trait2<'a, 'b> { // do not infer that. fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) //~^ ERROR the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied - //~| ERROR the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied { } diff --git a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index 3fd39810d..6844e8665 100644 --- a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -9,21 +9,6 @@ help: consider restricting type parameter `T` LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< >::Foo >) | ++++++++++++++++++++++++ -error[E0277]: the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:1 - | -LL | / fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) -LL | | -LL | | -LL | | { -LL | | } - | |_^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< >::Foo >) - | ++++++++++++++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/resolve/auxiliary/issue-112831-aux.rs b/tests/ui/resolve/auxiliary/issue-112831-aux.rs new file mode 100644 index 000000000..df436fb99 --- /dev/null +++ b/tests/ui/resolve/auxiliary/issue-112831-aux.rs @@ -0,0 +1,13 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +struct Zeroable; + +#[proc_macro_derive(Zeroable)] +pub fn derive_zeroable(_: proc_macro::TokenStream) -> proc_macro::TokenStream { + proc_macro::TokenStream::default() +} diff --git a/tests/ui/resolve/export-fully-qualified-2018.rs b/tests/ui/resolve/export-fully-qualified-2018.rs new file mode 100644 index 000000000..afd48acb6 --- /dev/null +++ b/tests/ui/resolve/export-fully-qualified-2018.rs @@ -0,0 +1,13 @@ +// edition:2018 + +// In this test baz isn't resolved when called as foo.baz even though +// it's called from inside foo. This is somewhat surprising and may +// want to change eventually. + +mod foo { + pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `foo` + + fn baz() { } +} + +fn main() { } diff --git a/tests/ui/resolve/export-fully-qualified-2018.stderr b/tests/ui/resolve/export-fully-qualified-2018.stderr new file mode 100644 index 000000000..366ffd9bb --- /dev/null +++ b/tests/ui/resolve/export-fully-qualified-2018.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `foo` + --> $DIR/export-fully-qualified-2018.rs:8:20 + | +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 + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/resolve/export-fully-qualified.rs b/tests/ui/resolve/export-fully-qualified.rs index 4e73a2c54..9d4daf4cd 100644 --- a/tests/ui/resolve/export-fully-qualified.rs +++ b/tests/ui/resolve/export-fully-qualified.rs @@ -1,3 +1,5 @@ +// edition:2015 + // In this test baz isn't resolved when called as foo.baz even though // it's called from inside foo. This is somewhat surprising and may // want to change eventually. diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr index 7ee352e12..0cd516ee1 100644 --- a/tests/ui/resolve/export-fully-qualified.stderr +++ b/tests/ui/resolve/export-fully-qualified.stderr @@ -1,8 +1,13 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` - --> $DIR/export-fully-qualified.rs:6:20 + --> $DIR/export-fully-qualified.rs:8:20 | 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/extern-prelude.rs b/tests/ui/resolve/extern-prelude.rs index 50fed6034..b5f1d5d35 100644 --- a/tests/ui/resolve/extern-prelude.rs +++ b/tests/ui/resolve/extern-prelude.rs @@ -25,7 +25,7 @@ fn shadow_mod() { fn shadow_prelude() { // Extern prelude shadows standard library prelude - let x = Vec::new(0f32, ()); // OK + let x: () = Vec::new(0f32, ()); // OK } fn main() {} diff --git a/tests/ui/resolve/hidden_glob_reexports.rs b/tests/ui/resolve/hidden_glob_reexports.rs new file mode 100644 index 000000000..102b56562 --- /dev/null +++ b/tests/ui/resolve/hidden_glob_reexports.rs @@ -0,0 +1,52 @@ +// check-pass + +pub mod upstream_a { + mod inner { + pub struct Foo {} + pub struct Bar {} + } + + struct Foo; + //~^ WARN private item shadows public glob re-export + + pub use self::inner::*; +} + +pub mod upstream_b { + mod inner { + pub struct Foo {} + pub struct Qux {} + } + + mod other { + pub struct Foo; + } + + pub use self::inner::*; + + use self::other::Foo; + //~^ WARN private item shadows public glob re-export +} + +pub mod upstream_c { + mod no_def_id { + #![allow(non_camel_case_types)] + pub struct u8; + pub struct World; + } + + pub use self::no_def_id::*; + + use std::primitive::u8; + //~^ WARN private item shadows public glob re-export +} + +// Downstream crate +// mod downstream { +// fn proof() { +// let _ = crate::upstream_a::Foo; +// let _ = crate::upstream_b::Foo; +// } +// } + +pub fn main() {} diff --git a/tests/ui/resolve/hidden_glob_reexports.stderr b/tests/ui/resolve/hidden_glob_reexports.stderr new file mode 100644 index 000000000..11fa94d6f --- /dev/null +++ b/tests/ui/resolve/hidden_glob_reexports.stderr @@ -0,0 +1,54 @@ +warning: private item shadows public glob re-export + --> $DIR/hidden_glob_reexports.rs:9:5 + | +LL | struct Foo; + | ^^^^^^^^^^^ + | +note: the name `Foo` in the type namespace is supposed to be publicly re-exported here + --> $DIR/hidden_glob_reexports.rs:12:13 + | +LL | pub use self::inner::*; + | ^^^^^^^^^^^^^^ +note: but the private item here shadows it + --> $DIR/hidden_glob_reexports.rs:9:5 + | +LL | struct Foo; + | ^^^^^^^^^^^ + = note: `#[warn(hidden_glob_reexports)]` on by default + +warning: private item shadows public glob re-export + --> $DIR/hidden_glob_reexports.rs:27:9 + | +LL | use self::other::Foo; + | ^^^^^^^^^^^^^^^^ + | +note: the name `Foo` in the type namespace is supposed to be publicly re-exported here + --> $DIR/hidden_glob_reexports.rs:25:13 + | +LL | pub use self::inner::*; + | ^^^^^^^^^^^^^^ +note: but the private item here shadows it + --> $DIR/hidden_glob_reexports.rs:27:9 + | +LL | use self::other::Foo; + | ^^^^^^^^^^^^^^^^ + +warning: private item shadows public glob re-export + --> $DIR/hidden_glob_reexports.rs:40:9 + | +LL | use std::primitive::u8; + | ^^^^^^^^^^^^^^^^^^ + | +note: the name `u8` in the type namespace is supposed to be publicly re-exported here + --> $DIR/hidden_glob_reexports.rs:38:13 + | +LL | pub use self::no_def_id::*; + | ^^^^^^^^^^^^^^^^^^ +note: but the private item here shadows it + --> $DIR/hidden_glob_reexports.rs:40:9 + | +LL | use std::primitive::u8; + | ^^^^^^^^^^^^^^^^^^ + +warning: 3 warnings emitted + diff --git a/tests/ui/resolve/issue-105069.stderr b/tests/ui/resolve/issue-105069.stderr index 1e6c9c6e2..a049cac83 100644 --- a/tests/ui/resolve/issue-105069.stderr +++ b/tests/ui/resolve/issue-105069.stderr @@ -4,17 +4,19 @@ error[E0659]: `V` is ambiguous LL | use V; | ^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of multiple glob imports of a name in the same module note: `V` could refer to the variant imported here --> $DIR/issue-105069.rs:1:5 | LL | use self::A::*; | ^^^^^^^^^^ + = help: consider adding an explicit import of `V` to disambiguate note: `V` could also refer to the variant imported here --> $DIR/issue-105069.rs:3:5 | LL | use self::B::*; | ^^^^^^^^^^ + = help: consider adding an explicit import of `V` to disambiguate error: aborting due to previous error diff --git a/tests/ui/resolve/issue-109153.rs b/tests/ui/resolve/issue-109153.rs new file mode 100644 index 000000000..bff6c9112 --- /dev/null +++ b/tests/ui/resolve/issue-109153.rs @@ -0,0 +1,14 @@ +use foo::*; + +mod foo { + pub mod bar { + pub mod bar { + pub mod bar {} + } + } +} + +use bar::bar; //~ ERROR `bar` is ambiguous +use bar::*; + +fn main() { } diff --git a/tests/ui/resolve/issue-109153.stderr b/tests/ui/resolve/issue-109153.stderr new file mode 100644 index 000000000..1a345d2a3 --- /dev/null +++ b/tests/ui/resolve/issue-109153.stderr @@ -0,0 +1,23 @@ +error[E0659]: `bar` is ambiguous + --> $DIR/issue-109153.rs:11:5 + | +LL | use bar::bar; + | ^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `bar` could refer to the module imported here + --> $DIR/issue-109153.rs:1:5 + | +LL | use foo::*; + | ^^^^^^ + = help: consider adding an explicit import of `bar` to disambiguate +note: `bar` could also refer to the module imported here + --> $DIR/issue-109153.rs:12:5 + | +LL | use bar::*; + | ^^^^^^ + = help: consider adding an explicit import of `bar` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/resolve/issue-112472-multi-generics-suggestion.fixed b/tests/ui/resolve/issue-112472-multi-generics-suggestion.fixed new file mode 100644 index 000000000..892697493 --- /dev/null +++ b/tests/ui/resolve/issue-112472-multi-generics-suggestion.fixed @@ -0,0 +1,31 @@ +// run-rustfix + +use std::fmt::Debug; +use std::marker::PhantomData; +use std::convert::{self, TryFrom}; + +#[allow(unused)] +struct Codec { + phantom_decode: PhantomData, + phantom_encode: PhantomData, +} + +pub enum ParseError {} + +impl Codec where + DecodeLine: Debug + convert::TryFrom, + DecodeLine: convert::TryFrom, + //~^ ERROR expected trait, found enum `ParseError` + //~| HELP constrain the associated type to `ParseError` +{ +} + +impl Codec where + DecodeLine: Debug + TryFrom, + DecodeLine: TryFrom, + //~^ ERROR expected trait, found enum `ParseError` + //~| HELP constrain the associated type to `ParseError` +{ +} + +fn main() {} diff --git a/tests/ui/resolve/issue-112472-multi-generics-suggestion.rs b/tests/ui/resolve/issue-112472-multi-generics-suggestion.rs new file mode 100644 index 000000000..2b2f5f1ad --- /dev/null +++ b/tests/ui/resolve/issue-112472-multi-generics-suggestion.rs @@ -0,0 +1,31 @@ +// run-rustfix + +use std::fmt::Debug; +use std::marker::PhantomData; +use std::convert::{self, TryFrom}; + +#[allow(unused)] +struct Codec { + phantom_decode: PhantomData, + phantom_encode: PhantomData, +} + +pub enum ParseError {} + +impl Codec where + DecodeLine: Debug + convert::TryFrom, + >::Error: ParseError, + //~^ ERROR expected trait, found enum `ParseError` + //~| HELP constrain the associated type to `ParseError` +{ +} + +impl Codec where + DecodeLine: Debug + TryFrom, + >::Error: ParseError, + //~^ ERROR expected trait, found enum `ParseError` + //~| HELP constrain the associated type to `ParseError` +{ +} + +fn main() {} diff --git a/tests/ui/resolve/issue-112472-multi-generics-suggestion.stderr b/tests/ui/resolve/issue-112472-multi-generics-suggestion.stderr new file mode 100644 index 000000000..f463e2dad --- /dev/null +++ b/tests/ui/resolve/issue-112472-multi-generics-suggestion.stderr @@ -0,0 +1,25 @@ +error[E0404]: expected trait, found enum `ParseError` + --> $DIR/issue-112472-multi-generics-suggestion.rs:17:54 + | +LL | >::Error: ParseError, + | ^^^^^^^^^^ not a trait + | +help: constrain the associated type to `ParseError` + | +LL | DecodeLine: convert::TryFrom, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error[E0404]: expected trait, found enum `ParseError` + --> $DIR/issue-112472-multi-generics-suggestion.rs:25:45 + | +LL | >::Error: ParseError, + | ^^^^^^^^^^ not a trait + | +help: constrain the associated type to `ParseError` + | +LL | DecodeLine: TryFrom, + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0404`. diff --git a/tests/ui/resolve/issue-112831.rs b/tests/ui/resolve/issue-112831.rs new file mode 100644 index 000000000..ffd83ea8b --- /dev/null +++ b/tests/ui/resolve/issue-112831.rs @@ -0,0 +1,20 @@ +// 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/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr index 0bb090905..b10eded01 100644 --- a/tests/ui/resolve/privacy-enum-ctor.stderr +++ b/tests/ui/resolve/privacy-enum-ctor.stderr @@ -228,7 +228,9 @@ error[E0603]: enum `Z` is private --> $DIR/privacy-enum-ctor.rs:61:22 | LL | let _: Z = m::n::Z::Fn; - | ^ private enum + | ^ -- tuple variant `Fn` is not publicly re-exported + | | + | private enum | note: the enum `Z` is defined here --> $DIR/privacy-enum-ctor.rs:11:9 @@ -252,7 +254,9 @@ error[E0603]: enum `Z` is private --> $DIR/privacy-enum-ctor.rs:68:22 | LL | let _: Z = m::n::Z::Unit {}; - | ^ private enum + | ^ ---- variant `Unit` is not publicly re-exported + | | + | private enum | note: the enum `Z` is defined here --> $DIR/privacy-enum-ctor.rs:11:9 diff --git a/tests/ui/resolve/resolve-pseudo-shadowing.rs b/tests/ui/resolve/resolve-pseudo-shadowing.rs index 85c684ca0..0ee0d0efa 100644 --- a/tests/ui/resolve/resolve-pseudo-shadowing.rs +++ b/tests/ui/resolve/resolve-pseudo-shadowing.rs @@ -3,7 +3,7 @@ fn check(_c: Clone) { fn check2() { - let _ = <() as std::clone::Clone>::clone(&()); + let () = <() as std::clone::Clone>::clone(&()); } check2(); } diff --git a/tests/ui/resolve/resolve-self-in-impl.stderr b/tests/ui/resolve/resolve-self-in-impl.stderr index b3042d413..9f9ed6889 100644 --- a/tests/ui/resolve/resolve-self-in-impl.stderr +++ b/tests/ui/resolve/resolve-self-in-impl.stderr @@ -1,40 +1,40 @@ error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:16:6 + --> $DIR/resolve-self-in-impl.rs:14:13 | -LL | impl Self {} - | ^^^^ +LL | impl Tr for Self {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:17:8 + --> $DIR/resolve-self-in-impl.rs:15:15 | -LL | impl S {} - | ^^^^ +LL | impl Tr for S {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:18:7 + --> $DIR/resolve-self-in-impl.rs:16:6 | -LL | impl (Self, Self) {} - | ^^^^ ^^^^ +LL | impl Self {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:14:13 + --> $DIR/resolve-self-in-impl.rs:17:8 | -LL | impl Tr for Self {} - | ^^^^ +LL | impl S {} + | ^^^^ | = note: replace `Self` with a different type error: `Self` is not valid in the self type of an impl block - --> $DIR/resolve-self-in-impl.rs:15:15 + --> $DIR/resolve-self-in-impl.rs:18:7 | -LL | impl Tr for S {} - | ^^^^ +LL | impl (Self, Self) {} + | ^^^^ ^^^^ | = note: replace `Self` with a different type diff --git a/tests/ui/return-nil.rs b/tests/ui/return-nil.rs index fd5203ff0..4fc937f96 100644 --- a/tests/ui/return-nil.rs +++ b/tests/ui/return-nil.rs @@ -1,6 +1,6 @@ // run-pass // pretty-expanded FIXME #23616 -fn f() { let x: () = (); return x; } +fn f() { let x = (); return x; } -pub fn main() { let _x = f(); } +pub fn main() { f(); } diff --git a/tests/ui/return/issue-64620.rs b/tests/ui/return/issue-64620.rs index a62e5bf8d..ab2931651 100644 --- a/tests/ui/return/issue-64620.rs +++ b/tests/ui/return/issue-64620.rs @@ -1,5 +1,5 @@ enum Bug { - V1 = return [0][0] //~ERROR return statement outside of function body + V1 = return [0][0], //~ERROR return statement outside of function body } fn main() {} diff --git a/tests/ui/return/issue-64620.stderr b/tests/ui/return/issue-64620.stderr index f40ac4de3..3210a67d4 100644 --- a/tests/ui/return/issue-64620.stderr +++ b/tests/ui/return/issue-64620.stderr @@ -1,7 +1,7 @@ error[E0572]: return statement outside of function body --> $DIR/issue-64620.rs:2:10 | -LL | V1 = return [0][0] +LL | V1 = return [0][0], | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/return/issue-86188-return-not-in-fn-body.rs b/tests/ui/return/issue-86188-return-not-in-fn-body.rs index 4f076fa06..3117cf3fd 100644 --- a/tests/ui/return/issue-86188-return-not-in-fn-body.rs +++ b/tests/ui/return/issue-86188-return-not-in-fn-body.rs @@ -7,7 +7,7 @@ const C: [(); 42] = { [(); return || { - //~^ ERROR: return statement outside of function body [E0572] + //~^ ERROR: return statement outside of function body [E0572] let tx; }] }; @@ -16,7 +16,7 @@ struct S {} trait Tr { fn foo(); fn bar() { - //~^ NOTE: ...not the enclosing function body + //~^ NOTE: ...not the enclosing function body [(); return]; //~^ ERROR: return statement outside of function body [E0572] //~| NOTE: the return is part of this body... @@ -24,7 +24,7 @@ trait Tr { } impl Tr for S { fn foo() { - //~^ NOTE: ...not the enclosing function body + //~^ NOTE: ...not the enclosing function body [(); return]; //~^ ERROR: return statement outside of function body [E0572] //~| NOTE: the return is part of this body... @@ -32,10 +32,10 @@ impl Tr for S { } fn main() { -//~^ NOTE: ...not the enclosing function body + //~^ NOTE: ...not the enclosing function body [(); return || { - //~^ ERROR: return statement outside of function body [E0572] - //~| NOTE: the return is part of this body... + //~^ ERROR: return statement outside of function body [E0572] + //~| NOTE: the return is part of this body... let tx; }]; } diff --git a/tests/ui/return/tail-expr-as-potential-return.rs b/tests/ui/return/tail-expr-as-potential-return.rs index f46e088b8..2046d6680 100644 --- a/tests/ui/return/tail-expr-as-potential-return.rs +++ b/tests/ui/return/tail-expr-as-potential-return.rs @@ -1,8 +1,8 @@ -// > Suggest `return`ing tail expressions that match return type +// > Suggest returning tail expressions that match return type // > // > Some newcomers are confused by the behavior of tail expressions, // > interpreting that "leaving out the `;` makes it the return value". -// > To help them go in the right direction, suggest using `return` instead +// > To help them go in the right direction, suggest using return instead // > when applicable. // (original commit description for this test) // diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs b/tests/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs deleted file mode 100644 index 1e086160f..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Adaptation of existing ui test (from way back in -// rust-lang/rust#2329), that starts passing with this feature in -// place. - -// run-pass - -use std::sync::mpsc::channel; - -fn main() { - let (tx, rx) = channel(); - let x = Some(rx); - tx.send(false).unwrap(); - tx.send(false).unwrap(); - match x { - Some(z) if z.recv().unwrap() => { panic!() }, - Some(z) => { assert!(!z.recv().unwrap()); }, - None => panic!() - } -} diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs b/tests/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs deleted file mode 100644 index 3161d6fbb..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs +++ /dev/null @@ -1,11 +0,0 @@ -// This test used to emit E0008 but now passed since `bind_by_move_pattern_guards` -// have been stabilized. - -// check-pass - -fn main() { - match Some("hi".to_string()) { - Some(s) if s.len() == 0 => {}, - _ => {}, - } -} diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs b/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs deleted file mode 100644 index b716fc870..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs +++ /dev/null @@ -1,43 +0,0 @@ -// run-pass - -struct A { a: Box } - -impl A { - fn get(&self) -> i32 { *self.a } -} - -fn foo(n: i32) -> i32 { - let x = A { a: Box::new(n) }; - let y = match x { - A { a: v } if *v == 42 => v, - _ => Box::new(0), - }; - *y -} - -fn bar(n: i32) -> i32 { - let x = A { a: Box::new(n) }; - let y = match x { - A { a: v } if x.get() == 42 => v, - _ => Box::new(0), - }; - *y -} - -fn baz(n: i32) -> i32 { - let x = A { a: Box::new(n) }; - let y = match x { - A { a: v } if *v.clone() == 42 => v, - _ => Box::new(0), - }; - *y -} - -fn main() { - assert_eq!(foo(107), 0); - assert_eq!(foo(42), 42); - assert_eq!(bar(107), 0); - assert_eq!(bar(42), 42); - assert_eq!(baz(107), 0); - assert_eq!(baz(42), 42); -} diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs b/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs deleted file mode 100644 index 6f0d2b045..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![feature(if_let_guard)] - -enum VecWrapper { A(Vec) } - -fn if_guard(x: VecWrapper) -> usize { - match x { - VecWrapper::A(v) if { drop(v); false } => 1, - //~^ ERROR cannot move out of `v` in pattern guard - VecWrapper::A(v) => v.len() - } -} - -fn if_let_guard(x: VecWrapper) -> usize { - match x { - VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, - //~^ ERROR cannot move out of `v` in pattern guard - VecWrapper::A(v) => v.len() - } -} - -fn main() { - if_guard(VecWrapper::A(vec![107])); - if_let_guard(VecWrapper::A(vec![107])); -} diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr b/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr deleted file mode 100644 index a749361bf..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-across-arms.rs:7:36 - | -LL | VecWrapper::A(v) if { drop(v); false } => 1, - | ^ move occurs because `v` has type `Vec`, which does not implement the `Copy` trait - | - = note: variables bound in patterns cannot be moved from until after the end of the pattern guard - -error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-across-arms.rs:15:51 - | -LL | VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, - | ^ move occurs because `v` has type `Vec`, which does not implement the `Copy` trait - | - = note: variables bound in patterns cannot be moved from until after the end of the pattern guard - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs b/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs deleted file mode 100644 index 827335f6a..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![feature(if_let_guard)] - -struct A { a: Box } - -fn if_guard(n: i32) { - let x = A { a: Box::new(n) }; - let _y = match x { - A { a: v } if { drop(v); true } => v, - //~^ ERROR cannot move out of `v` in pattern guard - _ => Box::new(0), - }; -} - -fn if_let_guard(n: i32) { - let x = A { a: Box::new(n) }; - let _y = match x { - A { a: v } if let Some(()) = { drop(v); Some(()) } => v, - //~^ ERROR cannot move out of `v` in pattern guard - _ => Box::new(0), - }; -} - -fn main() { - if_guard(107); - if_let_guard(107); -} diff --git a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr b/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr deleted file mode 100644 index 9285492b2..000000000 --- a/tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-in-first-arm.rs:8:30 - | -LL | A { a: v } if { drop(v); true } => v, - | ^ move occurs because `v` has type `Box`, which does not implement the `Copy` trait - | - = note: variables bound in patterns cannot be moved from until after the end of the pattern guard - -error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-in-first-arm.rs:17:45 - | -LL | A { a: v } if let Some(()) = { drop(v); Some(()) } => v, - | ^ move occurs because `v` has type `Box`, which does not implement the `Copy` trait - | - = note: variables bound in patterns cannot be moved from until after the end of the pattern guard - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs deleted file mode 100644 index 1914e1554..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Test explores how `#[structral_match]` behaves in tandem with -// `*const` and `*mut` pointers. - -// run-pass - -#![warn(pointer_structural_match)] - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive -// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapEmbedded(*const NoDerive); - -const WRAP_UNSAFE_EMBEDDED: WrapEmbedded = WrapEmbedded(std::ptr::null()); - -fn main() { - match WRAP_UNSAFE_EMBEDDED { - WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); } - _ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs deleted file mode 100644 index e713b003b..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Test explores how `#[structral_match]` behaves in tandem with -// `*const` and `*mut` pointers. - -// run-pass - -#![warn(pointer_structural_match)] - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive -// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapParam(*const X); - -const WRAP_UNSAFE_PARAM: WrapParam = WrapParam(std::ptr::null()); - -fn main() { - match WRAP_UNSAFE_PARAM { - WRAP_UNSAFE_PARAM => { println!("WRAP_UNSAFE_PARAM correctly matched itself"); } - _ => { panic!("WRAP_UNSAFE_PARAM did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs deleted file mode 100644 index 04da14c54..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Test explores how `#[structral_match]` behaves in tandem with -// `*const` and `*mut` pointers. - -// run-pass - -#![warn(pointer_structural_match)] - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive -// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapEmbedded(*const NoDerive); - -const WRAP_UNSAFE_EMBEDDED: & &WrapEmbedded = & &WrapEmbedded(std::ptr::null()); - -fn main() { - match WRAP_UNSAFE_EMBEDDED { - WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); } - _ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs deleted file mode 100644 index 8313c25e7..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Test explores how `#[structral_match]` behaves in tandem with -// `*const` and `*mut` pointers. - -// run-pass - -#![warn(pointer_structural_match)] - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive -// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapParam(*const X); - -const WRAP_UNSAFE_PARAM: & &WrapParam = & &WrapParam(std::ptr::null()); - -fn main() { - match WRAP_UNSAFE_PARAM { - WRAP_UNSAFE_PARAM => { println!("WRAP_UNSAFE_PARAM correctly matched itself"); } - _ => { panic!("WRAP_UNSAFE_PARAM did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs deleted file mode 100644 index dca8aaef1..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs +++ /dev/null @@ -1,59 +0,0 @@ -// rust-lang/rust#62614: we want to allow matching on constants of types that -// have non-structural-match variants, *if* the constant itself does not use -// any such variant. - -// NOTE: for now, deliberately leaving the lint `indirect_structural_match` set -// to its default, so that we will not issue a diangostic even if -// rust-lang/rust#62614 remains an open issue. - -// run-pass - -struct Sum(u32, u32); - -impl PartialEq for Sum { - fn eq(&self, other: &Self) -> bool { self.0 + self.1 == other.0 + other.1 } -} - -impl Eq for Sum { } - -#[derive(PartialEq, Eq)] -enum Eek { - TheConst, - UnusedByTheConst(Sum) -} - -const THE_CONST: Eek = Eek::TheConst; -const SUM_THREE: Eek = Eek::UnusedByTheConst(Sum(3,0)); - -const EEK_ZERO: &[Eek] = &[]; -const EEK_ONE: &[Eek] = &[THE_CONST]; - -pub fn main() { - match Eek::UnusedByTheConst(Sum(1,2)) { - ref sum if sum == &SUM_THREE => { println!("Hello 0"); } - _ => { println!("Gbye"); } - } - - match Eek::TheConst { - THE_CONST => { println!("Hello 1"); } - _ => { println!("Gbye"); } - } - - - match & &Eek::TheConst { - & & THE_CONST => { println!("Hello 2"); } - _ => { println!("Gbye"); } - } - - match & & &[][..] { - & & EEK_ZERO => { println!("Hello 3"); } - & & EEK_ONE => { println!("Gbye"); } - _ => { println!("Gbye"); } - } - - match & & &[Eek::TheConst][..] { - & & EEK_ZERO => { println!("Gby"); } - & & EEK_ONE => { println!("Hello 4"); } - _ => { println!("Gbye"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs deleted file mode 100644 index 7623839fd..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs +++ /dev/null @@ -1,26 +0,0 @@ -// This is part of a set of tests exploring the different ways a -// structural-match ADT might try to hold a -// non-structural-match in hidden manner that lets matches -// through that we had intended to reject. -// -// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive. -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapInline(NoDerive); - -const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0)); - -fn main() { - match WRAP_DIRECT_INLINE { - WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => { println!("WRAP_DIRECT_INLINE did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr deleted file mode 100644 index f08ba522a..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9 - | -LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } - | ^^^^^^^^^^^^^^^^^^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs deleted file mode 100644 index 93022a23d..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs +++ /dev/null @@ -1,26 +0,0 @@ -// This is part of a set of tests exploring the different ways a -// structural-match ADT might try to hold a -// non-structural-match in hidden manner that lets matches -// through that we had intended to reject. -// -// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 -#![warn(indirect_structural_match)] -struct NoDerive(i32); - -// This impl makes NoDerive irreflexive. -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapParam(T); - -const WRAP_DIRECT_PARAM: WrapParam = WrapParam(NoDerive(0)); - -fn main() { - match WRAP_DIRECT_PARAM { - WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => { println!("WRAP_DIRECT_PARAM did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr deleted file mode 100644 index 012ccab17..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/cant-hide-behind-direct-struct-param.rs:22:9 - | -LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } - | ^^^^^^^^^^^^^^^^^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs deleted file mode 100644 index 894739ff7..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This is part of a set of tests exploring the different ways a -// structural-match ADT might try to hold a -// non-structural-match in hidden manner that lets matches -// through that we had intended to reject. -// -// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 -#![warn(indirect_structural_match)] -// run-pass - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive. -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapInline<'a>(&'a &'a NoDerive); - -const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)); - -fn main() { - match WRAP_DOUBLY_INDIRECT_INLINE { - WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } - //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` - //~| WARN this was previously accepted - _ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr deleted file mode 100644 index 94ee2216e..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:24:9 - | -LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #62411 - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -note: the lint level is defined here - --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:7:9 - | -LL | #![warn(indirect_structural_match)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs deleted file mode 100644 index 1699dae46..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This is part of a set of tests exploring the different ways a -// structural-match ADT might try to hold a -// non-structural-match in hidden manner that lets matches -// through that we had intended to reject. -// -// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 -#![warn(indirect_structural_match)] -// run-pass - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive. -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapParam<'a, T>(&'a &'a T); - -const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam = & &WrapParam(& & NoDerive(0)); - -fn main() { - match WRAP_DOUBLY_INDIRECT_PARAM { - WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } - //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` - //~| WARN this was previously accepted - _ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr deleted file mode 100644 index 666b7b95e..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/cant-hide-behind-doubly-indirect-param.rs:24:9 - | -LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #62411 - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -note: the lint level is defined here - --> $DIR/cant-hide-behind-doubly-indirect-param.rs:7:9 - | -LL | #![warn(indirect_structural_match)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs deleted file mode 100644 index 2672bdd9e..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This is part of a set of tests exploring the different ways a -// structural-match ADT might try to hold a -// non-structural-match in hidden manner that lets matches -// through that we had intended to reject. -// -// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 -#![warn(indirect_structural_match)] -// run-pass - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive. -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapInline(NoDerive); - -const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0)); - -fn main() { - match WRAP_INDIRECT_INLINE { - WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } - //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` - //~| WARN this was previously accepted - _ => { println!("WRAP_INDIRECT_INLINE did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr deleted file mode 100644 index ecbe83f3d..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:24:9 - | -LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } - | ^^^^^^^^^^^^^^^^^^^^ - | - = 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 #62411 - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -note: the lint level is defined here - --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:7:9 - | -LL | #![warn(indirect_structural_match)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs deleted file mode 100644 index 3489995ae..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This is part of a set of tests exploring the different ways a -// structural-match ADT might try to hold a -// non-structural-match in hidden manner that lets matches -// through that we had intended to reject. -// -// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 -#![warn(indirect_structural_match)] -// run-pass - -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); - -// This impl makes NoDerive irreflexive. -impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } - -impl Eq for NoDerive { } - -#[derive(PartialEq, Eq)] -struct WrapParam(T); - -const WRAP_INDIRECT_PARAM: & &WrapParam = & &WrapParam(NoDerive(0)); - -fn main() { - match WRAP_INDIRECT_PARAM { - WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } - //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` - //~| WARN this was previously accepted - _ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr deleted file mode 100644 index 211990801..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/cant-hide-behind-indirect-struct-param.rs:24:9 - | -LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } - | ^^^^^^^^^^^^^^^^^^^ - | - = 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 #62411 - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -note: the lint level is defined here - --> $DIR/cant-hide-behind-indirect-struct-param.rs:7:9 - | -LL | #![warn(indirect_structural_match)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr deleted file mode 100644 index bd2940479..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: use of unstable library feature 'structural_match' - --> $DIR/feature-gate.rs:29:6 - | -LL | impl std::marker::StructuralPartialEq for Foo { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #31434 for more information - = help: add `#![feature(structural_match)]` to the crate attributes to enable - -error[E0658]: use of unstable library feature 'structural_match' - --> $DIR/feature-gate.rs:31:6 - | -LL | impl std::marker::StructuralEq for Foo { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #31434 for more information - = help: add `#![feature(structural_match)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs deleted file mode 100644 index ee6674097..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Test that use of structural-match traits is only permitted with a feature gate, -// and that if a feature gate is supplied, it permits the type to be -// used in a match. - -// revisions: with_gate no_gate - -// gate-test-structural_match - -#![allow(unused)] -#![feature(rustc_attrs)] -#![cfg_attr(with_gate, feature(structural_match))] - - -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -#[rustc_error] -fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error] - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} - -impl std::marker::StructuralPartialEq for Foo { } -//[no_gate]~^ ERROR use of unstable library feature 'structural_match' -impl std::marker::StructuralEq for Foo { } -//[no_gate]~^ ERROR use of unstable library feature 'structural_match' - -impl PartialEq for Foo { - fn eq(&self, other: &Self) -> bool { - self.x == other.x - } -} -impl Eq for Foo { } diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr deleted file mode 100644 index 623fd585a..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate.rs:21:1 - | -LL | fn main() { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs deleted file mode 100644 index 2b3fbd2a4..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs +++ /dev/null @@ -1,135 +0,0 @@ -// run-pass - -// This file checks that fn ptrs are considered structurally matchable. -// See also rust-lang/rust#63479. - -fn main() { - let mut count = 0; - - // A type which is not structurally matchable: - struct NotSM; - - // And one that is: - #[derive(PartialEq, Eq)] - struct SM; - - fn trivial() {} - - fn sm_to(_: SM) {} - fn not_sm_to(_: NotSM) {} - fn to_sm() -> SM { SM } - fn to_not_sm() -> NotSM { NotSM } - - // To recreate the scenario of interest in #63479, we need to add - // a ref-level-of-indirection so that we descend into the type. - - fn r_sm_to(_: &SM) {} - fn r_not_sm_to(_: &NotSM) {} - fn r_to_r_sm(_: &()) -> &SM { &SM } - fn r_to_r_not_sm(_: &()) -> &NotSM { &NotSM } - - #[derive(PartialEq, Eq)] - struct Wrap(T); - - // In the code below, we put the match input into a local so that - // we can assign it an explicit type that is an fn ptr instead of - // a singleton type of the fn itself that the type inference would - // otherwise assign. - - // Check that fn() is structural-match - const CFN1: Wrap = Wrap(trivial); - let input: Wrap = Wrap(trivial); - match Wrap(input) { - Wrap(CFN1) => count += 1, - Wrap(_) => {} - }; - - // Check that fn(T) is structural-match when T is too. - const CFN2: Wrap = Wrap(sm_to); - let input: Wrap = Wrap(sm_to); - match Wrap(input) { - Wrap(CFN2) => count += 1, - Wrap(_) => {} - }; - - // Check that fn() -> T is structural-match when T is too. - const CFN3: Wrap SM> = Wrap(to_sm); - let input: Wrap SM> = Wrap(to_sm); - match Wrap(input) { - Wrap(CFN3) => count += 1, - Wrap(_) => {} - }; - - // Check that fn(T) is structural-match even if T is not. - const CFN4: Wrap = Wrap(not_sm_to); - let input: Wrap = Wrap(not_sm_to); - match Wrap(input) { - Wrap(CFN4) => count += 1, - Wrap(_) => {} - }; - - // Check that fn() -> T is structural-match even if T is not. - const CFN5: Wrap NotSM> = Wrap(to_not_sm); - let input: Wrap NotSM> = Wrap(to_not_sm); - match Wrap(input) { - Wrap(CFN5) => count += 1, - Wrap(_) => {} - }; - - // Check that fn(&T) is structural-match when T is too. - const CFN6: Wrap = Wrap(r_sm_to); - let input: Wrap = Wrap(r_sm_to); - match Wrap(input) { - Wrap(CFN6) => count += 1, - Wrap(_) => {} - }; - - // Check that fn() -> &T is structural-match when T is too. - const CFN7: Wrap &SM> = Wrap(r_to_r_sm); - let input: Wrap &SM> = Wrap(r_to_r_sm); - match Wrap(input) { - Wrap(CFN7) => count += 1, - Wrap(_) => {} - }; - - // Check that fn(T) is structural-match even if T is not. - const CFN8: Wrap = Wrap(r_not_sm_to); - let input: Wrap = Wrap(r_not_sm_to); - match Wrap(input) { - Wrap(CFN8) => count += 1, - Wrap(_) => {} - }; - - // Check that fn() -> T is structural-match even if T is not. - const CFN9: Wrap &NotSM> = Wrap(r_to_r_not_sm); - let input: Wrap &NotSM> = Wrap(r_to_r_not_sm); - match Wrap(input) { - Wrap(CFN9) => count += 1, - Wrap(_) => {} - }; - - // Check that a type which has fn ptrs is structural-match. - #[derive(PartialEq, Eq)] - struct Foo { - alpha: fn(NotSM), - beta: fn() -> NotSM, - gamma: fn(SM), - delta: fn() -> SM, - } - - const CFOO: Foo = Foo { - alpha: not_sm_to, - beta: to_not_sm, - gamma: sm_to, - delta: to_sm, - }; - - let input = Foo { alpha: not_sm_to, beta: to_not_sm, gamma: sm_to, delta: to_sm }; - match input { - CFOO => count += 1, - Foo { .. } => {} - }; - - // Final count must be 10 now if all - assert_eq!(count, 10); -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs deleted file mode 100644 index 2a915d61e..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Issue 61188 pointed out a case where we hit an ICE during code gen: -// the compiler assumed that `PartialEq` was always implemented on any -// use of a `const` item in a pattern context, but the pre-existing -// structural-match checking was too shallow -// (see rust-lang/rust#62307), and so we hit cases where we were -// trying to dispatch to `PartialEq` on types that did not implement -// that trait. - -struct B(i32); - -const A: &[B] = &[]; - -pub fn main() { - match &[][..] { - A => (), - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => (), - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr deleted file mode 100644 index 46600e7b2..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 - | -LL | A => (), - | ^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs deleted file mode 100644 index 46d8ee3b6..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs +++ /dev/null @@ -1,43 +0,0 @@ -// RFC 1445 introduced `#[structural_match]`; this attribute must -// appear on the `struct`/`enum` definition for any `const` used in a -// pattern. -// -// This is our (forever-unstable) way to mark a datatype as having a -// `PartialEq` implementation that is equivalent to recursion over its -// substructure. This avoids (at least in the short term) any need to -// resolve the question of what semantics is used for such matching. -// (See RFC 1445 for more details and discussion.) - -// Issue 62307 pointed out a case where the structural-match checking -// was too shallow. -#![warn(indirect_structural_match, nontrivial_structural_match)] -// run-pass - -#[derive(Debug)] -struct B(i32); - -// Overriding `PartialEq` to use this strange notion of "equality" exposes -// whether `match` is using structural-equality or method-dispatch -// under the hood, which is the antithesis of rust-lang/rfcs#1445 -impl PartialEq for B { - fn eq(&self, other: &B) -> bool { std::cmp::min(self.0, other.0) == 0 } -} - -fn main() { - const RR_B0: & & B = & & B(0); - const RR_B1: & & B = & & B(1); - - match RR_B0 { - RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } - //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` - //~| WARN this was previously accepted - _ => { } - } - - match RR_B1 { - RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } - //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` - //~| WARN this was previously accepted - _ => { } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr deleted file mode 100644 index 435812306..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:31:9 - | -LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } - | ^^^^^ - | - = 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 #62411 - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details -note: the lint level is defined here - --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9 - | -LL | #![warn(indirect_structural_match, nontrivial_structural_match)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:38:9 - | -LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } - | ^^^^^ - | - = 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 #62411 - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -warning: 2 warnings emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs deleted file mode 100644 index 567685950..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs +++ /dev/null @@ -1,40 +0,0 @@ -// run-pass - -// The actual regression test from #63479. (Including this because my -// first draft at fn-ptr-is-structurally-matchable.rs failed to actually -// cover the case this hit; I've since expanded it accordingly, but the -// experience left me wary of leaving this regression test out.) - -#![warn(pointer_structural_match)] - -#[derive(Eq)] -struct A { - a: i64 -} - -impl PartialEq for A { - #[inline] - fn eq(&self, other: &Self) -> bool { - self.a.eq(&other.a) - } -} - -type Fn = fn(&[A]); - -fn my_fn(_args: &[A]) { - println!("hello world"); -} - -const TEST: Fn = my_fn; - -struct B(Fn); - -fn main() { - let s = B(my_fn); - match s { - B(TEST) => println!("matched"), - //~^ WARN pointers in patterns behave unpredictably - //~| WARN this was previously accepted by the compiler but is being phased out - _ => panic!("didn't match") - }; -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr deleted file mode 100644 index d6afc0255..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. - --> $DIR/issue-63479-match-fnptr.rs:35:7 - | -LL | B(TEST) => println!("matched"), - | ^^^^ - | - = 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 #62411 -note: the lint level is defined here - --> $DIR/issue-63479-match-fnptr.rs:8:9 - | -LL | #![warn(pointer_structural_match)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.rs deleted file mode 100644 index 0260caa82..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Matching against NaN should result in a warning - -#![allow(unused)] -#![deny(illegal_floating_point_literal_pattern)] - -const NAN: f64 = f64::NAN; - -fn main() { - let x = NAN; - match x { - NAN => {}, //~ ERROR floating-point types cannot be used - //~| WARN this was previously accepted by the compiler but is being phased out - _ => {}, - }; - - match [x, 1.0] { - [NAN, _] => {}, //~ ERROR floating-point types cannot be used - //~| WARN this was previously accepted by the compiler but is being phased out - _ => {}, - }; -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr deleted file mode 100644 index f37255d08..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: floating-point types cannot be used in patterns - --> $DIR/issue-6804.rs:11:9 - | -LL | NAN => {}, - | ^^^ - | - = 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 #41620 -note: the lint level is defined here - --> $DIR/issue-6804.rs:4:9 - | -LL | #![deny(illegal_floating_point_literal_pattern)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: floating-point types cannot be used in patterns - --> $DIR/issue-6804.rs:17:10 - | -LL | [NAN, _] => {}, - | ^^^ - | - = 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 #41620 - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs deleted file mode 100644 index 7ba0f3a9e..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Pre-existing behavior has been to reject patterns with consts -// denoting non-empty arrays of non-`Eq` types, but *accept* empty -// arrays of such types. -// -// See rust-lang/rust#62336. - -// run-pass - -#[derive(PartialEq, Debug)] -struct B(i32); - -fn main() { - const FOO: [B; 0] = []; - match [] { - FOO => { } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs deleted file mode 100644 index 59a22c337..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs +++ /dev/null @@ -1,23 +0,0 @@ -#[derive(PartialEq)] -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => { } - } - - let x = 0.0; - match x { - f32::INFINITY => { } - //~^ WARNING floating-point types cannot be used in patterns - //~| WARNING this was previously accepted by the compiler but is being phased out - _ => { } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr deleted file mode 100644 index 1c4fb9146..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/match-forbidden-without-eq.rs:11:9 - | -LL | FOO => { } - | ^^^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -warning: floating-point types cannot be used in patterns - --> $DIR/match-forbidden-without-eq.rs:18:9 - | -LL | f32::INFINITY => { } - | ^^^^^^^^^^^^^ - | - = 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 #41620 - = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs deleted file mode 100644 index 151a475c9..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Issue 62307 pointed out a case where the structural-match checking -// was too shallow. -// -// Here we check similar behavior for non-empty arrays of types that -// do not derive `Eq`. -// -// (Current behavior for empty arrays differs and thus is not tested -// here; see rust-lang/rust#62336.) - -#[derive(PartialEq, Debug)] -struct B(i32); - -fn main() { - const FOO: [B; 1] = [B(0)]; - match [B(1)] { - FOO => { } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr deleted file mode 100644 index 6adebada0..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/match-nonempty-array-forbidden-without-eq.rs:16:9 - | -LL | FOO => { } - | ^^^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs deleted file mode 100644 index a8deb8a75..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[derive(Eq)] -struct Foo { - x: u32 -} - -impl PartialEq for Foo { - fn eq(&self, _: &Foo) -> bool { - false // ha ha! - } -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => { } - } -} diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr deleted file mode 100644 index f5b10f062..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/match-requires-both-partialeq-and-eq.rs:17:9 - | -LL | FOO => { } - | ^^^ - | - = note: the traits must be derived, manual `impl`s are not sufficient - = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs b/tests/ui/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs deleted file mode 100644 index 50f91420c..000000000 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs +++ /dev/null @@ -1,53 +0,0 @@ -// run-pass - -// This file checks that `PhantomData` is considered structurally matchable. - -use std::marker::PhantomData; - -fn main() { - let mut count = 0; - - // A type which is not structurally matchable: - struct NotSM; - - // And one that is: - #[derive(PartialEq, Eq)] - struct SM; - - // Check that SM is structural-match: - const CSM: SM = SM; - match SM { - CSM => count += 1, - }; - - // Check that PhantomData is structural-match even if T is not. - const CPD1: PhantomData = PhantomData; - match PhantomData { - CPD1 => count += 1, - }; - - // Check that PhantomData is structural-match when T is. - const CPD2: PhantomData = PhantomData; - match PhantomData { - CPD2 => count += 1, - }; - - // Check that a type which has a PhantomData is structural-match. - #[derive(PartialEq, Eq, Default)] - struct Foo { - alpha: PhantomData, - beta: PhantomData, - } - - const CFOO: Foo = Foo { - alpha: PhantomData, - beta: PhantomData, - }; - - match Foo::default() { - CFOO => count += 1, - }; - - // Final count must be 4 now if all - assert_eq!(count, 4); -} diff --git a/tests/ui/rfc-1717-dllimport/missing-link-attr.rs b/tests/ui/rfc-1717-dllimport/missing-link-attr.rs deleted file mode 100644 index b46d85160..000000000 --- a/tests/ui/rfc-1717-dllimport/missing-link-attr.rs +++ /dev/null @@ -1,4 +0,0 @@ -// compile-flags: -l foo:bar -// error-pattern: renaming of the library `foo` was specified - -#![crate_type = "lib"] diff --git a/tests/ui/rfc-1717-dllimport/missing-link-attr.stderr b/tests/ui/rfc-1717-dllimport/missing-link-attr.stderr deleted file mode 100644 index d4410e147..000000000 --- a/tests/ui/rfc-1717-dllimport/missing-link-attr.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: renaming of the library `foo` was specified, however this crate contains no `#[link(...)]` attributes referencing this library - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1717-dllimport/multiple-renames.rs b/tests/ui/rfc-1717-dllimport/multiple-renames.rs deleted file mode 100644 index 106f196b4..000000000 --- a/tests/ui/rfc-1717-dllimport/multiple-renames.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-flags: -l foo:bar -l foo:baz -// error-pattern: multiple renamings were specified for library - -#![crate_type = "lib"] - -#[link(name = "foo")] -extern "C" {} diff --git a/tests/ui/rfc-1717-dllimport/multiple-renames.stderr b/tests/ui/rfc-1717-dllimport/multiple-renames.stderr deleted file mode 100644 index a6fec9c4e..000000000 --- a/tests/ui/rfc-1717-dllimport/multiple-renames.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: multiple renamings were specified for library `foo` - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1717-dllimport/rename-modifiers.rs b/tests/ui/rfc-1717-dllimport/rename-modifiers.rs deleted file mode 100644 index 30f4db718..000000000 --- a/tests/ui/rfc-1717-dllimport/rename-modifiers.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: -l dylib=foo:bar -// error-pattern: overriding linking modifiers from command line is not supported - -#![feature(native_link_modifiers_as_needed)] - -#![crate_type = "lib"] - -#[link(name = "foo", kind = "dylib", modifiers = "-as-needed")] -extern "C" {} diff --git a/tests/ui/rfc-1717-dllimport/rename-modifiers.stderr b/tests/ui/rfc-1717-dllimport/rename-modifiers.stderr deleted file mode 100644 index bee639bf2..000000000 --- a/tests/ui/rfc-1717-dllimport/rename-modifiers.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: overriding linking modifiers from command line is not supported - --> $DIR/rename-modifiers.rs:9:1 - | -LL | extern "C" {} - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1717-dllimport/rename-to-empty.rs b/tests/ui/rfc-1717-dllimport/rename-to-empty.rs deleted file mode 100644 index 9356c4129..000000000 --- a/tests/ui/rfc-1717-dllimport/rename-to-empty.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-flags: -l foo: -// error-pattern: an empty renaming target was specified for library - -#![crate_type = "lib"] - -#[link(name = "foo")] -extern "C" {} diff --git a/tests/ui/rfc-1717-dllimport/rename-to-empty.stderr b/tests/ui/rfc-1717-dllimport/rename-to-empty.stderr deleted file mode 100644 index aca839d80..000000000 --- a/tests/ui/rfc-1717-dllimport/rename-to-empty.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: an empty renaming target was specified for library `foo` - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-1.rs b/tests/ui/rfc-1937-termination-trait/issue-103052-1.rs deleted file mode 100644 index a75c91cc9..000000000 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-1.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Check that we don't blindly emit a diagnostic claiming that "`main` has an invalid return type" -// if we encounter a type that doesn't implement `std::process::Termination` and is not actually -// the return type of the program entry `main`. - -fn receive(_: impl std::process::Termination) {} - -struct Something; - -fn main() { - receive(Something); //~ ERROR the trait bound `Something: Termination` is not satisfied -} diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-1.stderr b/tests/ui/rfc-1937-termination-trait/issue-103052-1.stderr deleted file mode 100644 index 409dede1a..000000000 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-1.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0277]: the trait bound `Something: Termination` is not satisfied - --> $DIR/issue-103052-1.rs:10:13 - | -LL | receive(Something); - | ------- ^^^^^^^^^ the trait `Termination` is not implemented for `Something` - | | - | required by a bound introduced by this call - | -note: required by a bound in `receive` - --> $DIR/issue-103052-1.rs:5:20 - | -LL | fn receive(_: impl std::process::Termination) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `receive` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.current.stderr b/tests/ui/rfc-1937-termination-trait/issue-103052-2.current.stderr deleted file mode 100644 index f72b3ab02..000000000 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.current.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `Something: Termination` is not satisfied - --> $DIR/issue-103052-2.rs:15:22 - | -LL | fn main() -> Something { - | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` - | -note: required by a bound in `Main::main::{opaque#0}` - --> $DIR/issue-103052-2.rs:9:27 - | -LL | fn main() -> impl std::process::Termination; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{opaque#0}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr b/tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr deleted file mode 100644 index 8b01941b4..000000000 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `Something: Termination` is not satisfied - --> $DIR/issue-103052-2.rs:15: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:9: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/rfc-1937-termination-trait/issue-103052-2.rs b/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs deleted file mode 100644 index ca5fa6df2..000000000 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty -// revisions: current next - -#![feature(return_position_impl_trait_in_trait)] -#![allow(incomplete_features)] - -mod child { - trait Main { - fn main() -> impl std::process::Termination; - } - - struct Something; - - impl Main for () { - fn main() -> Something { - //~^ ERROR the trait bound `Something: Termination` is not satisfied - Something - } - } -} - -fn main() {} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs deleted file mode 100644 index 10dc6115d..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-fail -// error-pattern:returned Box from main() -// failure-status: 1 -// ignore-emscripten no processes - -use std::error::Error; -use std::io; - -fn main() -> Result<(), Box> { - Err(Box::new(io::Error::new(io::ErrorKind::Other, "returned Box from main()"))) -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-for-never.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-for-never.rs deleted file mode 100644 index faf2526c8..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-for-never.rs +++ /dev/null @@ -1,7 +0,0 @@ -// run-fail -// error-pattern:oh, dear -// ignore-emscripten no processes - -fn main() -> ! { - panic!("oh, dear"); -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs deleted file mode 100644 index 6a625fb05..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs +++ /dev/null @@ -1,10 +0,0 @@ -// run-fail -// error-pattern:returned Box from main() -// failure-status: 1 -// ignore-emscripten no processes - -use std::io::{Error, ErrorKind}; - -fn main() -> Result<(), Box> { - Err(Box::new(Error::new(ErrorKind::Other, "returned Box from main()"))) -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-for-str.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-for-str.rs deleted file mode 100644 index 94f16c6fd..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-for-str.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-fail -// error-pattern: An error message for you -// failure-status: 1 -// ignore-emscripten no processes - -fn main() -> Result<(), &'static str> { - Err("An error message for you") -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs deleted file mode 100644 index 3b60cbc57..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.rs +++ /dev/null @@ -1,3 +0,0 @@ -// Tests that an `impl Trait` that is not `impl Termination` will not work. -fn main() -> impl Copy { } -//~^ ERROR `main` has invalid return type `impl Copy` diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr b/tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr deleted file mode 100644 index 5ee6d127e..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-impl-trait.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `main` has invalid return type `impl Copy` - --> $DIR/termination-trait-impl-trait.rs:2:14 - | -LL | fn main() -> impl Copy { } - | ^^^^^^^^^ `main` can only return types that implement `Termination` - | - = help: consider using `()`, or a `Result` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs deleted file mode 100644 index 96808a3ed..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: --test - -#![feature(test)] - -extern crate test; -use std::num::ParseIntError; -use test::Bencher; - -#[test] -#[should_panic] -fn not_a_num() -> Result<(), ParseIntError> { - //~^ ERROR functions using `#[should_panic]` must return `()` - let _: u32 = "abc".parse()?; - Ok(()) -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr b/tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr deleted file mode 100644 index 7f6749fc9..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: functions using `#[should_panic]` must return `()` - --> $DIR/termination-trait-in-test-should-panic.rs:11:1 - | -LL | / fn not_a_num() -> Result<(), ParseIntError> { -LL | | -LL | | let _: u32 = "abc".parse()?; -LL | | Ok(()) -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-in-test.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-in-test.rs deleted file mode 100644 index 43888cece..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-in-test.rs +++ /dev/null @@ -1,28 +0,0 @@ -// compile-flags: --test -// run-pass -// needs-unwind - - -#![feature(test)] - -extern crate test; -use std::num::ParseIntError; -use test::Bencher; - -#[test] -fn is_a_num() -> Result<(), ParseIntError> { - let _: u32 = "22".parse()?; - Ok(()) -} - -#[bench] -fn test_a_positive_bench(_: &mut Bencher) -> Result<(), ParseIntError> { - Ok(()) -} - -#[bench] -#[should_panic] -fn test_a_neg_bench(_: &mut Bencher) -> Result<(), ParseIntError> { - let _: u32 = "abc".parse()?; - Ok(()) -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.rs deleted file mode 100644 index 10f7d2215..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() -> i32 { -//~^ ERROR `main` has invalid return type `i32` -//~| NOTE `main` can only return types that implement `Termination` -//~| HELP consider using `()`, or a `Result` - 0 -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.stderr b/tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.stderr deleted file mode 100644 index 53779d365..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-main-i32.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `main` has invalid return type `i32` - --> $DIR/termination-trait-main-i32.rs:1:14 - | -LL | fn main() -> i32 { - | ^^^ `main` can only return types that implement `Termination` - | - = help: consider using `()`, or a `Result` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs deleted file mode 100644 index 687d5f144..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() -> char { //~ ERROR - ' ' -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr b/tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr deleted file mode 100644 index bc8fd92ce..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `main` has invalid return type `char` - --> $DIR/termination-trait-main-wrong-type.rs:1:14 - | -LL | fn main() -> char { - | ^^^^ `main` can only return types that implement `Termination` - | - = help: consider using `()`, or a `Result` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.rs deleted file mode 100644 index 4c6168abb..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.rs +++ /dev/null @@ -1,5 +0,0 @@ -struct ReturnType {} - -fn main() -> ReturnType { //~ ERROR `main` has invalid return type `ReturnType` - ReturnType {} -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr b/tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr deleted file mode 100644 index cb329548d..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `main` has invalid return type `ReturnType` - --> $DIR/termination-trait-not-satisfied.rs:3:14 - | -LL | fn main() -> ReturnType { - | ^^^^^^^^^^ `main` can only return types that implement `Termination` - | - = help: consider using `()`, or a `Result` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs deleted file mode 100644 index 193a523ae..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs +++ /dev/null @@ -1,8 +0,0 @@ -// compile-flags: --test - -use std::num::ParseFloatError; - -#[test] -fn can_parse_zero_as_f32() -> Result { //~ ERROR - "0".parse() -} diff --git a/tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr deleted file mode 100644 index a19750cc7..000000000 --- a/tests/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: the trait bound `f32: Termination` is not satisfied - --> $DIR/termination-trait-test-wrong-type.rs:6:31 - | -LL | #[test] - | ------- in this procedural macro expansion -LL | fn can_parse_zero_as_f32() -> Result { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Termination` is not implemented for `f32` - | - = note: required for `Result` to implement `Termination` -note: required by a bound in `assert_test_result` - --> $SRC_DIR/test/src/lib.rs:LL:COL - = note: this error originates in the attribute macro `test` (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 E0277`. diff --git a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs b/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs deleted file mode 100644 index 54ab9f0ad..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.rs +++ /dev/null @@ -1,24 +0,0 @@ -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Foo { -} - -impl Foo { - fn get(&self) -> Option<&Result> { - None - } - - fn mutate(&mut self) { } -} - -fn main() { - let mut foo = Foo { }; - - // foo.get() returns type Option<&Result>, so - // using `string` keeps borrow of `foo` alive. Hence calling - // `foo.mutate()` should be an error. - while let Some(Ok(string)) = foo.get() { - foo.mutate(); - //~^ ERROR cannot borrow `foo` as mutable - println!("foo={:?}", *string); - } -} diff --git a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr b/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr deleted file mode 100644 index b7c0b0bb6..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-issue-49631.rs:20:9 - | -LL | while let Some(Ok(string)) = foo.get() { - | --------- immutable borrow occurs here -LL | foo.mutate(); - | ^^^^^^^^^^^^ mutable borrow occurs here -LL | -LL | println!("foo={:?}", *string); - | ------- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/rfc-2005-default-binding-mode/const.rs b/tests/ui/rfc-2005-default-binding-mode/const.rs deleted file mode 100644 index 93df88040..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/const.rs +++ /dev/null @@ -1,17 +0,0 @@ -// FIXME(tschottdorf): this test should pass. - -#[derive(PartialEq, Eq)] -struct Foo { - bar: i32, -} - -const FOO: Foo = Foo{bar: 5}; - -fn main() { - let f = Foo{bar:6}; - - match &f { - FOO => {}, //~ ERROR mismatched types - _ => panic!(), - } -} diff --git a/tests/ui/rfc-2005-default-binding-mode/const.stderr b/tests/ui/rfc-2005-default-binding-mode/const.stderr deleted file mode 100644 index fc06de90a..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/const.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/const.rs:14:9 - | -LL | const FOO: Foo = Foo{bar: 5}; - | -------------- constant defined here -... -LL | match &f { - | -- this expression has type `&Foo` -LL | FOO => {}, - | ^^^ - | | - | expected `&Foo`, found `Foo` - | `FOO` is interpreted as a constant, not a new binding - | help: introduce a new binding instead: `other_foo` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-2005-default-binding-mode/enum.rs b/tests/ui/rfc-2005-default-binding-mode/enum.rs deleted file mode 100644 index 4e57769d6..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/enum.rs +++ /dev/null @@ -1,22 +0,0 @@ -enum Wrapper { - Wrap(i32), -} - -use Wrapper::Wrap; - -pub fn main() { - let Wrap(x) = &Wrap(3); - *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference - - - if let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference - } else { - panic!(); - } - - while let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference - break; - } -} diff --git a/tests/ui/rfc-2005-default-binding-mode/enum.stderr b/tests/ui/rfc-2005-default-binding-mode/enum.stderr deleted file mode 100644 index 21e3d3d27..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/enum.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/enum.rs:9:5 - | -LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/enum.rs:13:9 - | -LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/enum.rs:19:9 - | -LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs deleted file mode 100644 index b8fde2208..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Verify the binding mode shifts - only when no `&` are auto-dereferenced is the -// final default binding mode mutable. - -fn main() { - match &&Some(5i32) { - Some(n) => { - *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference - let _ = n; - } - None => {}, - }; - - match &mut &Some(5i32) { - Some(n) => { - *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference - let _ = n; - } - None => {}, - }; - - match &&mut Some(5i32) { - Some(n) => { - *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference - let _ = n; - } - None => {}, - }; -} diff --git a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr b/tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr deleted file mode 100644 index c3f64f65a..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/explicit-mut.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0594]: cannot assign to `*n`, which is behind a `&` reference - --> $DIR/explicit-mut.rs:7:13 - | -LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*n`, which is behind a `&` reference - --> $DIR/explicit-mut.rs:15:13 - | -LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*n`, which is behind a `&` reference - --> $DIR/explicit-mut.rs:23:13 - | -LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/rfc-2005-default-binding-mode/for.rs b/tests/ui/rfc-2005-default-binding-mode/for.rs deleted file mode 100644 index d6c5a13b1..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/for.rs +++ /dev/null @@ -1,9 +0,0 @@ -struct Foo {} - -pub fn main() { - let mut tups = vec![(Foo {}, Foo {})]; - // The below desugars to &(ref n, mut m). - for (n, mut m) in &tups { - //~^ ERROR cannot move out of a shared reference - } -} diff --git a/tests/ui/rfc-2005-default-binding-mode/for.stderr b/tests/ui/rfc-2005-default-binding-mode/for.stderr deleted file mode 100644 index 07991af6e..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/for.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0507]: cannot move out of a shared reference - --> $DIR/for.rs:6:23 - | -LL | for (n, mut m) in &tups { - | ----- ^^^^^ - | | - | data moved here - | move occurs because `m` has type `Foo`, which does not implement the `Copy` trait - | -help: consider borrowing the pattern binding - | -LL | for (n, ref mut m) in &tups { - | +++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs b/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs deleted file mode 100644 index b4a0d8145..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.rs +++ /dev/null @@ -1,10 +0,0 @@ -// FIXME(tschottdorf): This should compile. See #44912. - -pub fn main() { - let x = &Some((3, 3)); - let _: &i32 = match x { - Some((x, 3)) | &Some((ref x, 5)) => x, - //~^ ERROR is bound inconsistently - _ => &5i32, - }; -} diff --git a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr b/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr deleted file mode 100644 index e1e1bf7f6..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/issue-44912-or.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0409]: variable `x` is bound inconsistently across alternatives separated by `|` - --> $DIR/issue-44912-or.rs:6:35 - | -LL | Some((x, 3)) | &Some((ref x, 5)) => x, - | - first binding ^ bound in different ways - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0409`. diff --git a/tests/ui/rfc-2005-default-binding-mode/lit.rs b/tests/ui/rfc-2005-default-binding-mode/lit.rs deleted file mode 100644 index ce79cfbdc..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/lit.rs +++ /dev/null @@ -1,24 +0,0 @@ -// FIXME(tschottdorf): we want these to compile, but they don't. - -fn with_str() { - let s: &'static str = "abc"; - - match &s { - "abc" => true, //~ ERROR mismatched types - _ => panic!(), - }; -} - -fn with_bytes() { - let s: &'static [u8] = b"abc"; - - match &s { - b"abc" => true, //~ ERROR mismatched types - _ => panic!(), - }; -} - -pub fn main() { - with_str(); - with_bytes(); -} diff --git a/tests/ui/rfc-2005-default-binding-mode/lit.stderr b/tests/ui/rfc-2005-default-binding-mode/lit.stderr deleted file mode 100644 index 181f57899..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/lit.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/lit.rs:7:13 - | -LL | match &s { - | -- this expression has type `&&str` -LL | "abc" => true, - | ^^^^^ expected `&&str`, found `&str` - | - = note: expected reference `&&str` - found reference `&'static str` - -error[E0308]: mismatched types - --> $DIR/lit.rs:16:9 - | -LL | match &s { - | -- this expression has type `&&[u8]` -LL | b"abc" => true, - | ^^^^^^ expected `&&[u8]`, found `&[u8; 3]` - | - = note: expected reference `&&[u8]` - found reference `&'static [u8; 3]` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-2005-default-binding-mode/no-double-error.rs b/tests/ui/rfc-2005-default-binding-mode/no-double-error.rs deleted file mode 100644 index 46fdfd678..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/no-double-error.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Without caching type lookups in FnCtxt.resolve_ty_and_def_ufcs -// the error below would be reported twice (once when checking -// for a non-ref pattern, once when processing the pattern). - -fn main() { - let foo = 22; - match foo { - u32::XXX => { } //~ ERROR no associated item named - _ => { } - } -} diff --git a/tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr b/tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr deleted file mode 100644 index c672acee0..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/no-double-error.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0599]: no associated item named `XXX` found for type `u32` in the current scope - --> $DIR/no-double-error.rs:8:14 - | -LL | u32::XXX => { } - | ^^^ associated item not found in `u32` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/rfc-2005-default-binding-mode/slice.rs b/tests/ui/rfc-2005-default-binding-mode/slice.rs deleted file mode 100644 index 363a0e3e6..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/slice.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub fn main() { - let sl: &[u8] = b"foo"; - - match sl { //~ ERROR non-exhaustive patterns - [first, remainder @ ..] => {}, - }; -} diff --git a/tests/ui/rfc-2005-default-binding-mode/slice.stderr b/tests/ui/rfc-2005-default-binding-mode/slice.stderr deleted file mode 100644 index 5b51dc5ac..000000000 --- a/tests/ui/rfc-2005-default-binding-mode/slice.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/slice.rs:4:11 - | -LL | match sl { - | ^^ pattern `&[]` not covered - | - = note: the matched value is of type `&[u8]` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown - | -LL ~ [first, remainder @ ..] => {}, -LL ~ &[] => todo!(), - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs b/tests/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs deleted file mode 100644 index cb2b585ab..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/auxiliary/enums.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![crate_type = "rlib"] - -#[non_exhaustive] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 }, -} - -#[non_exhaustive] -pub enum NestedNonExhaustive { - A(NonExhaustiveEnum), - B, - C, -} - -#[non_exhaustive] -pub enum EmptyNonExhaustiveEnum {} - -pub enum VariantNonExhaustive { - #[non_exhaustive] - Bar { - x: u32, - y: u64, - }, - Baz(u32, u16), -} - -#[non_exhaustive] -pub enum NonExhaustiveSingleVariant { - A(bool), -} - -#[repr(u8)] -pub enum FieldLessWithNonExhaustiveVariant { - A, - B, - #[non_exhaustive] - C, -} - -impl Default for FieldLessWithNonExhaustiveVariant { - fn default() -> Self { Self::A } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/auxiliary/monovariants.rs b/tests/ui/rfc-2008-non-exhaustive/auxiliary/monovariants.rs deleted file mode 100644 index 5f86db86d..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/auxiliary/monovariants.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[non_exhaustive] -pub enum NonExhaustiveMonovariant { - Variant(u32), -} - -pub enum ExhaustiveMonovariant { - Variant(u32), -} diff --git a/tests/ui/rfc-2008-non-exhaustive/auxiliary/structs.rs b/tests/ui/rfc-2008-non-exhaustive/auxiliary/structs.rs deleted file mode 100644 index 78db6b170..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/auxiliary/structs.rs +++ /dev/null @@ -1,41 +0,0 @@ -#[derive(Default)] -#[non_exhaustive] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -pub struct UnitStruct; - -#[non_exhaustive] -pub struct TupleStruct(pub u16, pub u16); - -#[derive(Debug)] -#[non_exhaustive] -pub struct FunctionalRecord { - pub first_field: u16, - pub second_field: u16, - pub third_field: bool, -} - -impl Default for FunctionalRecord { - fn default() -> FunctionalRecord { - FunctionalRecord { first_field: 640, second_field: 480, third_field: false } - } -} - -#[derive(Default)] -#[non_exhaustive] -pub struct NestedStruct { - pub foo: u16, - pub bar: NormalStruct, -} - -#[derive(Default)] -#[non_exhaustive] -pub struct MixedVisFields { - pub a: u16, - pub b: bool, - pub(crate) foo: bool, -} diff --git a/tests/ui/rfc-2008-non-exhaustive/auxiliary/unstable.rs b/tests/ui/rfc-2008-non-exhaustive/auxiliary/unstable.rs deleted file mode 100644 index 11df44461..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/auxiliary/unstable.rs +++ /dev/null @@ -1,60 +0,0 @@ -#![feature(staged_api)] -#![stable(feature = "stable_test_feature", since = "1.0.0")] - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[non_exhaustive] -pub enum UnstableEnum { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - Stable, - #[stable(feature = "stable_test_feature", since = "1.0.0")] - Stable2, - #[unstable(feature = "unstable_test_feature", issue = "none")] - Unstable, -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[non_exhaustive] -pub enum OnlyUnstableEnum { - #[unstable(feature = "unstable_test_feature", issue = "none")] - Unstable, - #[unstable(feature = "unstable_test_feature", issue = "none")] - Unstable2, -} - -impl OnlyUnstableEnum { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - pub fn new() -> Self { - Self::Unstable - } -} - -#[derive(Default)] -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[non_exhaustive] -pub struct UnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - pub stable: bool, - #[stable(feature = "stable_test_feature", since = "1.0.0")] - pub stable2: usize, - #[unstable(feature = "unstable_test_feature", issue = "none")] - pub unstable: u8, -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[non_exhaustive] -pub struct OnlyUnstableStruct { - #[unstable(feature = "unstable_test_feature", issue = "none")] - pub unstable: u8, - #[unstable(feature = "unstable_test_feature", issue = "none")] - pub unstable2: bool, -} - -impl OnlyUnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - pub fn new() -> Self { - Self { - unstable: 0, - unstable2: false, - } - } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/auxiliary/variants.rs b/tests/ui/rfc-2008-non-exhaustive/auxiliary/variants.rs deleted file mode 100644 index 02672d545..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/auxiliary/variants.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_type = "rlib"] - -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - #[non_exhaustive] Tuple(u32), - #[non_exhaustive] Struct { field: u32 } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs b/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs deleted file mode 100644 index b9ff24c76..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/borrowck-exhaustive.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Test that the borrow checker doesn't consider checking an exhaustive pattern -// as an access. - -// check-pass - -#![allow(dropping_references)] - -// aux-build:monovariants.rs -extern crate monovariants; - -use monovariants::ExhaustiveMonovariant; - -enum Local { - Variant(u32), -} - -#[non_exhaustive] -enum LocalNonExhaustive { - Variant(u32), -} - -fn main() { - let mut x = ExhaustiveMonovariant::Variant(1); - let y = &mut x; - match x { - ExhaustiveMonovariant::Variant(_) => {}, - _ => {}, - } - drop(y); - let mut x = Local::Variant(1); - let y = &mut x; - match x { - Local::Variant(_) => {}, - _ => {}, - } - drop(y); - let mut x = LocalNonExhaustive::Variant(1); - let y = &mut x; - match x { - LocalNonExhaustive::Variant(_) => {}, - _ => {}, - } - drop(y); -} diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs b/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs deleted file mode 100644 index 2ad92b794..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Test that the borrow checker considers `#[non_exhaustive]` when checking -// whether a match contains a discriminant read. - -// aux-build:monovariants.rs -extern crate monovariants; - -use monovariants::NonExhaustiveMonovariant; - -fn main() { - let mut x = NonExhaustiveMonovariant::Variant(1); - let y = &mut x; - match x { - //~^ ERROR cannot use `x` because it was mutably borrowed - NonExhaustiveMonovariant::Variant(_) => {}, - _ => {}, - } - drop(y); -} diff --git a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr b/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr deleted file mode 100644 index ad84ebe3a..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-non-exhaustive.rs:12:11 - | -LL | let y = &mut x; - | ------ `x` is borrowed here -LL | match x { - | ^ use of borrowed `x` -... -LL | drop(y); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/tests/ui/rfc-2008-non-exhaustive/enum-as-cast.rs b/tests/ui/rfc-2008-non-exhaustive/enum-as-cast.rs deleted file mode 100644 index 5dce8180f..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum-as-cast.rs +++ /dev/null @@ -1,11 +0,0 @@ -// aux-build:enums.rs - -extern crate enums; - -use enums::FieldLessWithNonExhaustiveVariant; - -fn main() { - let e = FieldLessWithNonExhaustiveVariant::default(); - let d = e as u8; //~ ERROR casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid [E0606] - assert_eq!(d, 0); -} diff --git a/tests/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr b/tests/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr deleted file mode 100644 index a61dcf839..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum-as-cast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0606]: casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid - --> $DIR/enum-as-cast.rs:9:13 - | -LL | let d = e as u8; - | ^^^^^^^ - | - = note: cannot cast an enum with a non-exhaustive variant when it's defined in another crate - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0606`. diff --git a/tests/ui/rfc-2008-non-exhaustive/enum.rs b/tests/ui/rfc-2008-non-exhaustive/enum.rs deleted file mode 100644 index 9d2855f5c..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum.rs +++ /dev/null @@ -1,69 +0,0 @@ -// aux-build:enums.rs -extern crate enums; - -use enums::{EmptyNonExhaustiveEnum, NonExhaustiveEnum}; - -fn empty(x: EmptyNonExhaustiveEnum) { - match x {} //~ ERROR type `EmptyNonExhaustiveEnum` is non-empty - match x { - _ => {}, // ok - } -} - -fn main() { - let enum_unit = NonExhaustiveEnum::Unit; - - match enum_unit { - //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] - NonExhaustiveEnum::Unit => "first", - NonExhaustiveEnum::Tuple(_) => "second", - NonExhaustiveEnum::Struct { .. } => "third" - }; - - match enum_unit {}; - //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] - - // Everything below this is expected to compile successfully. - - let enum_unit = NonExhaustiveEnum::Unit; - - match enum_unit { - NonExhaustiveEnum::Unit => 1, - NonExhaustiveEnum::Tuple(_) => 2, - // This particular arm tests that an enum marked as non-exhaustive - // will not error if its variants are matched exhaustively. - NonExhaustiveEnum::Struct { field } => field, - _ => 0 // no error with wildcard - }; - - match enum_unit { - _ => "no error with only wildcard" - }; - - // #53549: Check that variant constructors can still be called normally. - match NonExhaustiveEnum::Unit { - NonExhaustiveEnum::Unit => {}, - _ => {} - }; - - match NonExhaustiveEnum::Tuple(2) { - NonExhaustiveEnum::Tuple(2) => {}, - _ => {} - }; - - match (NonExhaustiveEnum::Unit {}) { - NonExhaustiveEnum::Unit {} => {}, - _ => {} - }; - - match (NonExhaustiveEnum::Tuple { 0: 2 }) { - NonExhaustiveEnum::Tuple { 0: 2 } => {}, - _ => {} - }; - - match (NonExhaustiveEnum::Struct { field: 2 }) { - NonExhaustiveEnum::Struct { field: 2 } => {}, - _ => {} - }; - -} diff --git a/tests/ui/rfc-2008-non-exhaustive/enum.stderr b/tests/ui/rfc-2008-non-exhaustive/enum.stderr deleted file mode 100644 index 872cb9b8b..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum.stderr +++ /dev/null @@ -1,59 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `EmptyNonExhaustiveEnum` is non-empty - --> $DIR/enum.rs:7:11 - | -LL | match x {} - | ^ - | -note: `EmptyNonExhaustiveEnum` defined here - --> $DIR/auxiliary/enums.rs:18:1 - | -LL | pub enum EmptyNonExhaustiveEnum {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `EmptyNonExhaustiveEnum`, which is marked as non-exhaustive -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/enum.rs:16:11 - | -LL | match enum_unit { - | ^^^^^^^^^ pattern `_` not covered - | -note: `NonExhaustiveEnum` defined here - --> $DIR/auxiliary/enums.rs:4:1 - | -LL | pub enum NonExhaustiveEnum { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown - | -LL ~ NonExhaustiveEnum::Struct { .. } => "third", -LL + _ => todo!() - | - -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/enum.rs:23:11 - | -LL | match enum_unit {}; - | ^^^^^^^^^ pattern `_` not covered - | -note: `NonExhaustiveEnum` defined here - --> $DIR/auxiliary/enums.rs:4:1 - | -LL | pub enum NonExhaustiveEnum { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown - | -LL ~ match enum_unit { -LL + _ => todo!(), -LL ~ }; - | - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/enum_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/enum_same_crate.rs deleted file mode 100644 index 54e42917f..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum_same_crate.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - -#[non_exhaustive] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 } -} - -fn main() { - let enum_unit = NonExhaustiveEnum::Unit; - - match enum_unit { - NonExhaustiveEnum::Unit => "first", - NonExhaustiveEnum::Tuple(_) => "second", - NonExhaustiveEnum::Struct { .. } => "third", - }; -} diff --git a/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs b/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs deleted file mode 100644 index 69a283c31..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![deny(unreachable_patterns)] - -#[non_exhaustive] -pub enum NonExhaustiveEnum { - Unit, - //~^ not covered - Tuple(u32), - //~^ not covered - Struct { field: u32 } - //~^ not covered -} - -pub enum NormalEnum { - Unit, - //~^ not covered - Tuple(u32), - //~^ not covered - Struct { field: u32 } - //~^ not covered -} - -#[non_exhaustive] -pub enum EmptyNonExhaustiveEnum {} - -fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) { - match x {} - match x { - _ => {} //~ ERROR unreachable pattern - } -} - -fn main() { - match NonExhaustiveEnum::Unit {} - //~^ ERROR `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered [E0004] - match NormalEnum::Unit {} - //~^ ERROR `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered [E0004] -} diff --git a/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr deleted file mode 100644 index de1bf8be8..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error: unreachable pattern - --> $DIR/enum_same_crate_empty_match.rs:28:9 - | -LL | _ => {} - | ^ - | -note: the lint level is defined here - --> $DIR/enum_same_crate_empty_match.rs:1:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error[E0004]: non-exhaustive patterns: `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered - --> $DIR/enum_same_crate_empty_match.rs:33:11 - | -LL | match NonExhaustiveEnum::Unit {} - | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered - | -note: `NonExhaustiveEnum` defined here - --> $DIR/enum_same_crate_empty_match.rs:5:5 - | -LL | pub enum NonExhaustiveEnum { - | ----------------- -LL | Unit, - | ^^^^ not covered -LL | -LL | Tuple(u32), - | ^^^^^ not covered -LL | -LL | Struct { field: u32 } - | ^^^^^^ not covered - = note: the matched value is of type `NonExhaustiveEnum` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms - | -LL ~ match NonExhaustiveEnum::Unit { -LL + NonExhaustiveEnum::Unit | NonExhaustiveEnum::Tuple(_) | NonExhaustiveEnum::Struct { .. } => todo!(), -LL + } - | - -error[E0004]: non-exhaustive patterns: `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered - --> $DIR/enum_same_crate_empty_match.rs:35:11 - | -LL | match NormalEnum::Unit {} - | ^^^^^^^^^^^^^^^^ patterns `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered - | -note: `NormalEnum` defined here - --> $DIR/enum_same_crate_empty_match.rs:14:5 - | -LL | pub enum NormalEnum { - | ---------- -LL | Unit, - | ^^^^ not covered -LL | -LL | Tuple(u32), - | ^^^^^ not covered -LL | -LL | Struct { field: u32 } - | ^^^^^^ not covered - = note: the matched value is of type `NormalEnum` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms - | -LL ~ match NormalEnum::Unit { -LL + NormalEnum::Unit | NormalEnum::Tuple(_) | NormalEnum::Struct { .. } => todo!(), -LL + } - | - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs b/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs deleted file mode 100644 index d6251fcb7..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs +++ /dev/null @@ -1,29 +0,0 @@ -#[non_exhaustive] -#[repr(C)] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 } -} - -#[non_exhaustive] -#[repr(C)] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -#[repr(C)] -pub struct UnitStruct; - -#[non_exhaustive] -#[repr(C)] -pub struct TupleStruct (pub u16, pub u16); - -#[repr(C)] -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - #[non_exhaustive] Tuple(u32), - #[non_exhaustive] Struct { field: u32 } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs b/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs deleted file mode 100644 index 15c0c695f..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs +++ /dev/null @@ -1,24 +0,0 @@ -// aux-build:types.rs -#![deny(improper_ctypes)] - -extern crate types; - -// This test checks that non-exhaustive types with `#[repr(C)]` from an extern crate are considered -// improper. - -use types::{NonExhaustiveEnum, NonExhaustiveVariants, NormalStruct, TupleStruct, UnitStruct}; - -extern "C" { - pub fn non_exhaustive_enum(_: NonExhaustiveEnum); - //~^ ERROR `extern` block uses type `NonExhaustiveEnum`, which is not FFI-safe - pub fn non_exhaustive_normal_struct(_: NormalStruct); - //~^ ERROR `extern` block uses type `NormalStruct`, which is not FFI-safe - pub fn non_exhaustive_unit_struct(_: UnitStruct); - //~^ ERROR `extern` block uses type `UnitStruct`, which is not FFI-safe - pub fn non_exhaustive_tuple_struct(_: TupleStruct); - //~^ ERROR `extern` block uses type `TupleStruct`, which is not FFI-safe - pub fn non_exhaustive_variant(_: NonExhaustiveVariants); - //~^ ERROR `extern` block uses type `NonExhaustiveVariants`, which is not FFI-safe -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr b/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr deleted file mode 100644 index 43c8e1015..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error: `extern` block uses type `NonExhaustiveEnum`, which is not FFI-safe - --> $DIR/extern_crate_improper.rs:12:35 - | -LL | pub fn non_exhaustive_enum(_: NonExhaustiveEnum); - | ^^^^^^^^^^^^^^^^^ not FFI-safe - | - = note: this enum is non-exhaustive -note: the lint level is defined here - --> $DIR/extern_crate_improper.rs:2:9 - | -LL | #![deny(improper_ctypes)] - | ^^^^^^^^^^^^^^^ - -error: `extern` block uses type `NormalStruct`, which is not FFI-safe - --> $DIR/extern_crate_improper.rs:14:44 - | -LL | pub fn non_exhaustive_normal_struct(_: NormalStruct); - | ^^^^^^^^^^^^ not FFI-safe - | - = note: this struct is non-exhaustive - -error: `extern` block uses type `UnitStruct`, which is not FFI-safe - --> $DIR/extern_crate_improper.rs:16:42 - | -LL | pub fn non_exhaustive_unit_struct(_: UnitStruct); - | ^^^^^^^^^^ not FFI-safe - | - = note: this struct is non-exhaustive - -error: `extern` block uses type `TupleStruct`, which is not FFI-safe - --> $DIR/extern_crate_improper.rs:18:43 - | -LL | pub fn non_exhaustive_tuple_struct(_: TupleStruct); - | ^^^^^^^^^^^ not FFI-safe - | - = note: this struct is non-exhaustive - -error: `extern` block uses type `NonExhaustiveVariants`, which is not FFI-safe - --> $DIR/extern_crate_improper.rs:20:38 - | -LL | pub fn non_exhaustive_variant(_: NonExhaustiveVariants); - | ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe - | - = note: this enum has non-exhaustive variants - -error: aborting due to 5 previous errors - diff --git a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs b/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs deleted file mode 100644 index fe4ae345d..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs +++ /dev/null @@ -1,48 +0,0 @@ -// check-pass -#![deny(improper_ctypes)] - -// This test checks that non-exhaustive types with `#[repr(C)]` are considered proper within -// the defining crate. - -#[non_exhaustive] -#[repr(C)] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 }, -} - -#[non_exhaustive] -#[repr(C)] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -#[repr(C)] -pub struct UnitStruct; - -#[non_exhaustive] -#[repr(C)] -pub struct TupleStruct(pub u16, pub u16); - -#[repr(C)] -pub enum NonExhaustiveVariants { - #[non_exhaustive] - Unit, - #[non_exhaustive] - Tuple(u32), - #[non_exhaustive] - Struct { field: u32 }, -} - -extern "C" { - // Unit structs aren't tested here because they will trigger `improper_ctypes` anyway. - pub fn non_exhaustive_enum(_: NonExhaustiveEnum); - pub fn non_exhaustive_normal_struct(_: NormalStruct); - pub fn non_exhaustive_tuple_struct(_: TupleStruct); - pub fn non_exhaustive_variant(_: NonExhaustiveVariants); -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/invalid-attribute.rs b/tests/ui/rfc-2008-non-exhaustive/invalid-attribute.rs deleted file mode 100644 index 143f9a300..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/invalid-attribute.rs +++ /dev/null @@ -1,16 +0,0 @@ -#[non_exhaustive(anything)] -//~^ ERROR malformed `non_exhaustive` attribute -struct Foo; - -#[non_exhaustive] -//~^ ERROR attribute should be applied to a struct or enum [E0701] -trait Bar { } - -#[non_exhaustive] -//~^ ERROR attribute should be applied to a struct or enum [E0701] -union Baz { - f1: u16, - f2: u16 -} - -fn main() { } diff --git a/tests/ui/rfc-2008-non-exhaustive/invalid-attribute.stderr b/tests/ui/rfc-2008-non-exhaustive/invalid-attribute.stderr deleted file mode 100644 index 136cd763b..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/invalid-attribute.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: malformed `non_exhaustive` attribute input - --> $DIR/invalid-attribute.rs:1:1 - | -LL | #[non_exhaustive(anything)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[non_exhaustive]` - -error[E0701]: attribute should be applied to a struct or enum - --> $DIR/invalid-attribute.rs:5:1 - | -LL | #[non_exhaustive] - | ^^^^^^^^^^^^^^^^^ -LL | -LL | trait Bar { } - | ------------- not a struct or enum - -error[E0701]: attribute should be applied to a struct or enum - --> $DIR/invalid-attribute.rs:9:1 - | -LL | #[non_exhaustive] - | ^^^^^^^^^^^^^^^^^ -LL | -LL | / union Baz { -LL | | f1: u16, -LL | | f2: u16 -LL | | } - | |_- not a struct or enum - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0701`. diff --git a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs deleted file mode 100644 index 3482af747..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs +++ /dev/null @@ -1,211 +0,0 @@ -// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly. - -#![feature(non_exhaustive_omitted_patterns_lint, unstable_test_feature)] - -// aux-build:enums.rs -extern crate enums; -// aux-build:unstable.rs -extern crate unstable; -// aux-build:structs.rs -extern crate structs; - -use enums::{ - EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant, - VariantNonExhaustive, -}; -use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct}; -use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct}; - -#[non_exhaustive] -#[derive(Default)] -pub struct Foo { - a: u8, - b: usize, - c: String, -} - -#[non_exhaustive] -pub enum Bar { - A, - B, - C, -} - -fn main() { - let enumeration = Bar::A; - - // Ok: this is a crate local non_exhaustive enum - match enumeration { - Bar::A => {} - Bar::B => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - - let non_enum = NonExhaustiveEnum::Unit; - - // Ok: without the attribute - match non_enum { - NonExhaustiveEnum::Unit => {} - NonExhaustiveEnum::Tuple(_) => {} - _ => {} - } - - match non_enum { - NonExhaustiveEnum::Unit => {} - NonExhaustiveEnum::Tuple(_) => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - //~^^ some variants are not matched explicitly - - match non_enum { - NonExhaustiveEnum::Unit | NonExhaustiveEnum::Struct { .. } => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - //~^^ some variants are not matched explicitly - - let x = 5; - match non_enum { - NonExhaustiveEnum::Unit if x > 10 => {} - NonExhaustiveEnum::Tuple(_) => {} - NonExhaustiveEnum::Struct { .. } => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - //~^^ some variants are not matched explicitly - - // Ok: all covered and not `unreachable-patterns` - #[deny(unreachable_patterns)] - match non_enum { - NonExhaustiveEnum::Unit => {} - NonExhaustiveEnum::Tuple(_) => {} - NonExhaustiveEnum::Struct { .. } => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - - #[deny(non_exhaustive_omitted_patterns)] - match NestedNonExhaustive::B { - NestedNonExhaustive::A(NonExhaustiveEnum::Unit) => {} - NestedNonExhaustive::A(_) => {} - NestedNonExhaustive::B => {} - _ => {} - } - //~^^ some variants are not matched explicitly - //~^^^^^ some variants are not matched explicitly - - #[warn(non_exhaustive_omitted_patterns)] - match VariantNonExhaustive::Baz(1, 2) { - VariantNonExhaustive::Baz(_, _) => {} - VariantNonExhaustive::Bar { x, .. } => {} - } - //~^^ some fields are not explicitly listed - - #[warn(non_exhaustive_omitted_patterns)] - let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default(); - //~^ some fields are not explicitly listed - - // Ok: this is local - #[warn(non_exhaustive_omitted_patterns)] - let Foo { a, b, .. } = Foo::default(); - - #[warn(non_exhaustive_omitted_patterns)] - let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); - //~^ some fields are not explicitly listed - //~^^ some fields are not explicitly listed - - // Ok: this tests https://github.com/rust-lang/rust/issues/89382 - #[warn(non_exhaustive_omitted_patterns)] - let MixedVisFields { a, b, .. } = MixedVisFields::default(); - - // Ok: because this only has 1 variant - #[deny(non_exhaustive_omitted_patterns)] - match NonExhaustiveSingleVariant::A(true) { - NonExhaustiveSingleVariant::A(true) => {} - _ => {} - } - - #[deny(non_exhaustive_omitted_patterns)] - match NonExhaustiveSingleVariant::A(true) { - _ => {} - } - //~^^ some variants are not matched explicitly - - // Ok: we don't lint on `if let` expressions - #[deny(non_exhaustive_omitted_patterns)] - if let NonExhaustiveEnum::Tuple(_) = non_enum {} - - match UnstableEnum::Stable { - UnstableEnum::Stable => {} - UnstableEnum::Stable2 => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - //~^^ some variants are not matched explicitly - - // Ok: the feature is on and all variants are matched - #[deny(non_exhaustive_omitted_patterns)] - match UnstableEnum::Stable { - UnstableEnum::Stable => {} - UnstableEnum::Stable2 => {} - UnstableEnum::Unstable => {} - _ => {} - } - - // Ok: the feature is on and both variants are matched - #[deny(non_exhaustive_omitted_patterns)] - match OnlyUnstableEnum::Unstable { - OnlyUnstableEnum::Unstable => {} - OnlyUnstableEnum::Unstable2 => {} - _ => {} - } - - #[deny(non_exhaustive_omitted_patterns)] - match OnlyUnstableEnum::Unstable { - OnlyUnstableEnum::Unstable => {} - _ => {} - } - //~^^ some variants are not matched explicitly - - #[warn(non_exhaustive_omitted_patterns)] - let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new(); - //~^ some fields are not explicitly listed - - // OK: both unstable fields are matched with feature on - #[warn(non_exhaustive_omitted_patterns)] - let OnlyUnstableStruct { unstable, unstable2, .. } = OnlyUnstableStruct::new(); - - #[warn(non_exhaustive_omitted_patterns)] - let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); - //~^ some fields are not explicitly listed - - // OK: both unstable and stable fields are matched with feature on - #[warn(non_exhaustive_omitted_patterns)] - let UnstableStruct { stable, stable2, unstable, .. } = UnstableStruct::default(); - - // Ok: local bindings are allowed - #[deny(non_exhaustive_omitted_patterns)] - let local = NonExhaustiveEnum::Unit; - - // Ok: missing patterns will be blocked by the pattern being refutable - #[deny(non_exhaustive_omitted_patterns)] - let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; - //~^ refutable pattern in local binding - - // Check that matching on a reference results in a correctly spanned diagnostic - #[deny(non_exhaustive_omitted_patterns)] - match &non_enum { - NonExhaustiveEnum::Unit => {} - NonExhaustiveEnum::Tuple(_) => {} - _ => {} - } - //~^^ some variants are not matched explicitly -} - -#[deny(non_exhaustive_omitted_patterns)] -// Ok: Pattern in a param is always wildcard -pub fn takes_non_exhaustive(_: NonExhaustiveEnum) { - let _closure = |_: NonExhaustiveEnum| {}; -} diff --git a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr b/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr deleted file mode 100644 index 923394474..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr +++ /dev/null @@ -1,217 +0,0 @@ -warning: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:102:9 - | -LL | VariantNonExhaustive::Bar { x, .. } => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:99:12 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:107:9 - | -LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:106:12 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:115:29 - | -LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:114:12 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:115:9 - | -LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found - -warning: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:173:9 - | -LL | let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable2` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `OnlyUnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:172:12 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: some fields are not explicitly listed - --> $DIR/omitted-patterns.rs:181:9 - | -LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `UnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:180:12 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:58:9 - | -LL | _ => {} - | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:57:16 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:65:9 - | -LL | _ => {} - | ^ pattern `NonExhaustiveEnum::Tuple(_)` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:64:16 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:75:9 - | -LL | _ => {} - | ^ pattern `NonExhaustiveEnum::Unit` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:74:16 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:92:32 - | -LL | NestedNonExhaustive::A(_) => {} - | ^ patterns `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:89:12 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:94:9 - | -LL | _ => {} - | ^ pattern `NestedNonExhaustive::C` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:132:9 - | -LL | _ => {} - | ^ pattern `NonExhaustiveSingleVariant::A(_)` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NonExhaustiveSingleVariant` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:130:12 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:144:9 - | -LL | _ => {} - | ^ pattern `UnstableEnum::Unstable` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:143:16 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:168:9 - | -LL | _ => {} - | ^ pattern `OnlyUnstableEnum::Unstable2` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `OnlyUnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:165:12 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0005]: refutable pattern in local binding - --> $DIR/omitted-patterns.rs:194:9 - | -LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; - | ^^^^^^^^^^^^^^^ pattern `_` not covered - | - = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant - = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html - = note: the matched value is of type `NonExhaustiveEnum` -help: you might want to use `let else` to handle the variant that isn't matched - | -LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit else { todo!() }; - | ++++++++++++++++ - -error: some variants are not matched explicitly - --> $DIR/omitted-patterns.rs:202:9 - | -LL | _ => {} - | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/omitted-patterns.rs:198:12 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 10 previous errors; 6 warnings emitted - -For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.rs b/tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.rs deleted file mode 100644 index 82ee68687..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly with variants -// marked stable and unstable. - -#![feature(non_exhaustive_omitted_patterns_lint)] - -// aux-build:unstable.rs -extern crate unstable; - -use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct}; - -fn main() { - // OK: this matches all the stable variants - match UnstableEnum::Stable { - UnstableEnum::Stable => {} - UnstableEnum::Stable2 => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - - match UnstableEnum::Stable { - UnstableEnum::Stable => {} - #[deny(non_exhaustive_omitted_patterns)] - _ => {} - } - //~^^ some variants are not matched explicitly - - // Ok: although this is a bit odd, we don't have anything to report - // since there is no stable variants and the feature is off - #[deny(non_exhaustive_omitted_patterns)] - match OnlyUnstableEnum::new() { - _ => {} - } - - // Ok: Same as the above enum (no fields can be matched on) - #[warn(non_exhaustive_omitted_patterns)] - let OnlyUnstableStruct { .. } = OnlyUnstableStruct::new(); - - #[warn(non_exhaustive_omitted_patterns)] - let UnstableStruct { stable, .. } = UnstableStruct::default(); - //~^ some fields are not explicitly listed - - // OK: stable field is matched - #[warn(non_exhaustive_omitted_patterns)] - let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); -} diff --git a/tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr b/tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr deleted file mode 100644 index f38368590..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr +++ /dev/null @@ -1,30 +0,0 @@ -warning: some fields are not explicitly listed - --> $DIR/stable-omitted-patterns.rs:39:9 - | -LL | let UnstableStruct { stable, .. } = UnstableStruct::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `stable2` not listed - | - = help: ensure that all fields are mentioned explicitly by adding the suggested fields - = note: the pattern is of type `UnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/stable-omitted-patterns.rs:38:12 - | -LL | #[warn(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: some variants are not matched explicitly - --> $DIR/stable-omitted-patterns.rs:23:9 - | -LL | _ => {} - | ^ pattern `UnstableEnum::Stable2` not covered - | - = help: ensure that all variants are matched explicitly by adding the suggested match arms - = note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found -note: the lint level is defined here - --> $DIR/stable-omitted-patterns.rs:22:16 - | -LL | #[deny(non_exhaustive_omitted_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui/rfc-2008-non-exhaustive/struct.rs b/tests/ui/rfc-2008-non-exhaustive/struct.rs deleted file mode 100644 index 07e093c15..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/struct.rs +++ /dev/null @@ -1,49 +0,0 @@ -// aux-build:structs.rs -extern crate structs; - -use structs::{NormalStruct, UnitStruct, TupleStruct, FunctionalRecord}; - -fn main() { - let fr = FunctionalRecord { - //~^ ERROR cannot create non-exhaustive struct - first_field: 1920, - second_field: 1080, - ..FunctionalRecord::default() - }; - - let ns = NormalStruct { first_field: 640, second_field: 480 }; - //~^ ERROR cannot create non-exhaustive struct - - let NormalStruct { first_field, second_field } = ns; - //~^ ERROR `..` required with struct marked as non-exhaustive - - let ts = TupleStruct(640, 480); - //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] - - let ts_explicit = structs::TupleStruct(640, 480); - //~^ ERROR tuple struct constructor `TupleStruct` is private [E0603] - - let TupleStruct { 0: first_field, 1: second_field } = ts; - //~^ ERROR `..` required with struct marked as non-exhaustive - - let us = UnitStruct; - //~^ ERROR expected value, found struct `UnitStruct` [E0423] - - let us_explicit = structs::UnitStruct; - //~^ ERROR unit struct `UnitStruct` is private [E0603] - - let UnitStruct { } = us; - //~^ ERROR `..` required with struct marked as non-exhaustive -} - -// Everything below this is expected to compile successfully. - -// We only test matching here as we cannot create non-exhaustive -// structs from another crate. ie. they'll never pass in run-pass tests. -fn match_structs(ns: NormalStruct, ts: TupleStruct, us: UnitStruct) { - let NormalStruct { first_field, second_field, .. } = ns; - - let TupleStruct { 0: first, 1: second, .. } = ts; - - let UnitStruct { .. } = us; -} diff --git a/tests/ui/rfc-2008-non-exhaustive/struct.stderr b/tests/ui/rfc-2008-non-exhaustive/struct.stderr deleted file mode 100644 index 39b1ef1e0..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/struct.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error[E0423]: expected value, found struct `UnitStruct` - --> $DIR/struct.rs:29:14 - | -LL | let us = UnitStruct; - | ^^^^^^^^^^ constructor is not visible here due to private fields - -error[E0603]: tuple struct constructor `TupleStruct` is private - --> $DIR/struct.rs:23:32 - | -LL | let ts_explicit = structs::TupleStruct(640, 480); - | ^^^^^^^^^^^ private tuple struct constructor - | -note: the tuple struct constructor `TupleStruct` is defined here - --> $DIR/auxiliary/structs.rs:12:1 - | -LL | #[non_exhaustive] - | ----------------- cannot be constructed because it is `#[non_exhaustive]` -LL | pub struct TupleStruct(pub u16, pub u16); - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0603]: unit struct `UnitStruct` is private - --> $DIR/struct.rs:32:32 - | -LL | let us_explicit = structs::UnitStruct; - | ^^^^^^^^^^ private unit struct - | -note: the unit struct `UnitStruct` is defined here - --> $DIR/auxiliary/structs.rs:9:1 - | -LL | #[non_exhaustive] - | ----------------- cannot be constructed because it is `#[non_exhaustive]` -LL | pub struct UnitStruct; - | ^^^^^^^^^^^^^^^^^^^^^ - -error[E0639]: cannot create non-exhaustive struct using struct expression - --> $DIR/struct.rs:7:14 - | -LL | let fr = FunctionalRecord { - | ______________^ -LL | | -LL | | first_field: 1920, -LL | | second_field: 1080, -LL | | ..FunctionalRecord::default() -LL | | }; - | |_____^ - -error[E0639]: cannot create non-exhaustive struct using struct expression - --> $DIR/struct.rs:14:14 - | -LL | let ns = NormalStruct { first_field: 640, second_field: 480 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0638]: `..` required with struct marked as non-exhaustive - --> $DIR/struct.rs:17:9 - | -LL | let NormalStruct { first_field, second_field } = ns; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: add `..` at the end of the field list to ignore all other fields - | -LL | let NormalStruct { first_field, second_field , .. } = ns; - | ~~~~~~ - -error[E0423]: cannot initialize a tuple struct which contains private fields - --> $DIR/struct.rs:20:14 - | -LL | let ts = TupleStruct(640, 480); - | ^^^^^^^^^^^ - -error[E0638]: `..` required with struct marked as non-exhaustive - --> $DIR/struct.rs:26:9 - | -LL | let TupleStruct { 0: first_field, 1: second_field } = ts; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: add `..` at the end of the field list to ignore all other fields - | -LL | let TupleStruct { 0: first_field, 1: second_field , .. } = ts; - | ~~~~~~ - -error[E0638]: `..` required with struct marked as non-exhaustive - --> $DIR/struct.rs:35:9 - | -LL | let UnitStruct { } = us; - | ^^^^^^^^^^^^^^ - | -help: add `..` at the end of the field list to ignore all other fields - | -LL | let UnitStruct { .. } = us; - | ~~~~ - -error: aborting due to 9 previous errors - -Some errors have detailed explanations: E0423, E0603, E0638, E0639. -For more information about an error, try `rustc --explain E0423`. diff --git a/tests/ui/rfc-2008-non-exhaustive/structs_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/structs_same_crate.rs deleted file mode 100644 index 5f76b0cb2..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/structs_same_crate.rs +++ /dev/null @@ -1,32 +0,0 @@ -// run-pass - -#![allow(unused_variables)] - -#[non_exhaustive] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -pub struct UnitStruct; - -#[non_exhaustive] -pub struct TupleStruct (pub u16, pub u16); - -fn main() { - let ns = NormalStruct { first_field: 640, second_field: 480 }; - - let NormalStruct { first_field, second_field } = ns; - - let ts = TupleStruct { 0: 340, 1: 480 }; - let ts_constructor = TupleStruct(340, 480); - - let TupleStruct { 0: first, 1: second } = ts; - let TupleStruct(first, second) = ts_constructor; - - let us = UnitStruct {}; - let us_constructor = UnitStruct; - - let UnitStruct { } = us; -} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs deleted file mode 100644 index a2735d4cb..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![crate_type = "rlib"] -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -pub enum PartiallyInhabitedVariants { - Tuple(u8), - #[non_exhaustive] Struct { x: ! } -} - -pub struct IndirectUninhabitedEnum(UninhabitedEnum); - -pub struct IndirectUninhabitedStruct(UninhabitedStruct); - -pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - -pub struct IndirectUninhabitedVariants(UninhabitedVariants); diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs deleted file mode 100644 index 80b9dc4c1..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs +++ /dev/null @@ -1,38 +0,0 @@ -// aux-build:uninhabited.rs -#![feature(never_type)] - -extern crate uninhabited; - -use uninhabited::{ - UninhabitedEnum, - UninhabitedStruct, - UninhabitedTupleStruct, - UninhabitedVariants, -}; - -// This test checks that uninhabited non-exhaustive types cannot coerce to any type, as the never -// type can. - -struct A; - -fn can_coerce_never_type_to_anything(x: !) -> A { - x -} - -fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { - x //~ ERROR mismatched types -} - -fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - x //~ ERROR mismatched types -} - -fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { - x //~ ERROR mismatched types -} - -fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { - x //~ ERROR mismatched types -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr deleted file mode 100644 index c209caab5..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/coercions.rs:23:5 - | -LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedEnum` - -error[E0308]: mismatched types - --> $DIR/coercions.rs:27:5 - | -LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedTupleStruct` - -error[E0308]: mismatched types - --> $DIR/coercions.rs:31:5 - | -LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedStruct` - -error[E0308]: mismatched types - --> $DIR/coercions.rs:35:5 - | -LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedVariants` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs deleted file mode 100644 index 6b911dd98..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -struct A; - -// This test checks that uninhabited non-exhaustive types defined in the same crate cannot coerce -// to any type, as the never type can. - -fn can_coerce_never_type_to_anything(x: !) -> A { - x -} - -fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { - x //~ ERROR mismatched types -} - -fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - x //~ ERROR mismatched types -} - -fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { - x //~ ERROR mismatched types -} - -fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { - x //~ ERROR mismatched types -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr deleted file mode 100644 index 289433edf..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:30:5 - | -LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedEnum` - -error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:34:5 - | -LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedTupleStruct` - -error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:38:5 - | -LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedStruct` - -error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:42:5 - | -LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { - | - expected `A` because of return type -LL | x - | ^ expected `A`, found `UninhabitedVariants` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs deleted file mode 100644 index 98a7fdbc5..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs +++ /dev/null @@ -1,36 +0,0 @@ -// aux-build:uninhabited.rs -#![feature(never_type)] - -extern crate uninhabited; - -use uninhabited::{ - IndirectUninhabitedEnum, - IndirectUninhabitedStruct, - IndirectUninhabitedTupleStruct, - IndirectUninhabitedVariants, -}; - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type through a level of -// indirection from an extern crate will not compile. - -fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( - x: IndirectUninhabitedVariants, -) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr deleted file mode 100644 index 66e93291c..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr +++ /dev/null @@ -1,79 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty - --> $DIR/indirect_match.rs:19:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:26:1 - | -LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedEnum` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty - --> $DIR/indirect_match.rs:23:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:28:1 - | -LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty - --> $DIR/indirect_match.rs:27:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedTupleStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:30:1 - | -LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedTupleStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty - --> $DIR/indirect_match.rs:33:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedVariants` defined here - --> $DIR/auxiliary/uninhabited.rs:32:1 - | -LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedVariants` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs deleted file mode 100644 index 8f090fe88..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs +++ /dev/null @@ -1,51 +0,0 @@ -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -pub struct IndirectUninhabitedEnum(UninhabitedEnum); - -pub struct IndirectUninhabitedStruct(UninhabitedStruct); - -pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - -pub struct IndirectUninhabitedVariants(UninhabitedVariants); - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type through a level of -// indirection from the defining crate will not compile without `#![feature(exhaustive_patterns)]`. - -fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( - x: IndirectUninhabitedVariants, -) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr deleted file mode 100644 index c12190541..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr +++ /dev/null @@ -1,79 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty - --> $DIR/indirect_match_same_crate.rs:34:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedEnum` defined here - --> $DIR/indirect_match_same_crate.rs:20:12 - | -LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); - | ^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedEnum` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty - --> $DIR/indirect_match_same_crate.rs:38:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedStruct` defined here - --> $DIR/indirect_match_same_crate.rs:22:12 - | -LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty - --> $DIR/indirect_match_same_crate.rs:42:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedTupleStruct` defined here - --> $DIR/indirect_match_same_crate.rs:24:12 - | -LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedTupleStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty - --> $DIR/indirect_match_same_crate.rs:48:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedVariants` defined here - --> $DIR/indirect_match_same_crate.rs:26:12 - | -LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedVariants` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs deleted file mode 100644 index be86519ec..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs +++ /dev/null @@ -1,40 +0,0 @@ -// aux-build:uninhabited.rs -#![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] -#![feature(never_type)] - -extern crate uninhabited; - -use uninhabited::{ - IndirectUninhabitedEnum, - IndirectUninhabitedStruct, - IndirectUninhabitedTupleStruct, - IndirectUninhabitedVariants, -}; - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type through a level of -// indirection from an extern crate will not compile. In particular, this enables the -// `exhaustive_patterns` feature as this can change the branch used in the compiler to determine -// this. - -fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( - x: IndirectUninhabitedVariants, -) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr deleted file mode 100644 index ef97c1fa1..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr +++ /dev/null @@ -1,79 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:23:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:26:1 - | -LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedEnum` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:27:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:28:1 - | -LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:31:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedTupleStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:30:1 - | -LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedTupleStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:37:11 - | -LL | match x {} - | ^ - | -note: `IndirectUninhabitedVariants` defined here - --> $DIR/auxiliary/uninhabited.rs:32:1 - | -LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `IndirectUninhabitedVariants` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs deleted file mode 100644 index 60289aa78..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs +++ /dev/null @@ -1,57 +0,0 @@ -// check-pass - -#![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -pub struct IndirectUninhabitedEnum(UninhabitedEnum); - -pub struct IndirectUninhabitedStruct(UninhabitedStruct); - -pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); - -pub struct IndirectUninhabitedVariants(UninhabitedVariants); - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate -// will compile. In particular, this enables the `exhaustive_patterns` feature as this can -// change the branch used in the compiler to determine this. -// Codegen is skipped because tests with long names can cause issues on Windows CI, see #60648. - -fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { - match x {} -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { - match x {} -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { - match x {} -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( - x: IndirectUninhabitedVariants, -) -> A { - match x {} -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs deleted file mode 100644 index 230ac7529..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs +++ /dev/null @@ -1,21 +0,0 @@ -// aux-build:uninhabited.rs -#![deny(unreachable_patterns)] -#![feature(never_type)] - -extern crate uninhabited; - -use uninhabited::PartiallyInhabitedVariants; - -// This test checks a redundant/useless pattern of a non-exhaustive enum/variant is still -// warned against. - -pub fn foo(x: PartiallyInhabitedVariants) { - match x { - PartiallyInhabitedVariants::Struct { .. } => {}, - PartiallyInhabitedVariants::Struct { .. } => {}, - //~^ ERROR unreachable pattern - _ => {}, - } -} - -fn main() { } diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr deleted file mode 100644 index f39e6ee29..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unreachable pattern - --> $DIR/issue-65157-repeated-match-arm.rs:15:9 - | -LL | PartiallyInhabitedVariants::Struct { .. } => {}, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/issue-65157-repeated-match-arm.rs:2:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match.rs deleted file mode 100644 index e54098d4d..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match.rs +++ /dev/null @@ -1,34 +0,0 @@ -// aux-build:uninhabited.rs -#![feature(never_type)] - -extern crate uninhabited; - -use uninhabited::{ - UninhabitedEnum, - UninhabitedStruct, - UninhabitedTupleStruct, - UninhabitedVariants, -}; - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type from an extern crate -// will not compile. - -fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr deleted file mode 100644 index a9c54af04..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr +++ /dev/null @@ -1,83 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty - --> $DIR/match.rs:19:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:5:1 - | -LL | pub enum UninhabitedEnum { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty - --> $DIR/match.rs:23:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:9:1 - | -LL | pub struct UninhabitedStruct { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty - --> $DIR/match.rs:27:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedTupleStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:14:1 - | -LL | pub struct UninhabitedTupleStruct(!); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedTupleStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered - --> $DIR/match.rs:31:11 - | -LL | match x {} - | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered - | -note: `UninhabitedVariants` defined here - --> $DIR/auxiliary/uninhabited.rs:17:23 - | -LL | pub enum UninhabitedVariants { - | ---------------------------- -LL | #[non_exhaustive] Tuple(!), - | ^^^^^ not covered -LL | #[non_exhaustive] Struct { x: ! } - | ^^^^^^ not covered - = note: the matched value is of type `UninhabitedVariants` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms - | -LL ~ match x { -LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), -LL ~ } - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs deleted file mode 100644 index ebbdfba15..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate -// will compile. - -fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { - match x {} -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr deleted file mode 100644 index ec2a2f6f0..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty - --> $DIR/match_same_crate.rs:30:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedStruct` defined here - --> $DIR/match_same_crate.rs:8:12 - | -LL | pub struct UninhabitedStruct { - | ^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty - --> $DIR/match_same_crate.rs:34:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedTupleStruct` defined here - --> $DIR/match_same_crate.rs:13:12 - | -LL | pub struct UninhabitedTupleStruct(!); - | ^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedTupleStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered - --> $DIR/match_same_crate.rs:38:11 - | -LL | match x {} - | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered - | -note: `UninhabitedVariants` defined here - --> $DIR/match_same_crate.rs:16:23 - | -LL | pub enum UninhabitedVariants { - | ------------------- -LL | #[non_exhaustive] Tuple(!), - | ^^^^^ not covered -LL | #[non_exhaustive] Struct { x: ! } - | ^^^^^^ not covered - = note: the matched value is of type `UninhabitedVariants` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms - | -LL ~ match x { -LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), -LL ~ } - | - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs deleted file mode 100644 index 900dfff65..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs +++ /dev/null @@ -1,37 +0,0 @@ -// aux-build:uninhabited.rs -#![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] -#![feature(never_type)] - -extern crate uninhabited; - -use uninhabited::{ - UninhabitedEnum, - UninhabitedStruct, - UninhabitedTupleStruct, - UninhabitedVariants, -}; - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type from an extern crate -// will not compile. In particular, this enables the `exhaustive_patterns` feature as this can -// change the branch used in the compiler to determine this. - -fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { - match x {} //~ ERROR non-exhaustive patterns -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr deleted file mode 100644 index b6b777ec5..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr +++ /dev/null @@ -1,83 +0,0 @@ -error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:22:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedEnum` defined here - --> $DIR/auxiliary/uninhabited.rs:5:1 - | -LL | pub enum UninhabitedEnum { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:26:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:9:1 - | -LL | pub struct UninhabitedStruct { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:30:11 - | -LL | match x {} - | ^ - | -note: `UninhabitedTupleStruct` defined here - --> $DIR/auxiliary/uninhabited.rs:14:1 - | -LL | pub struct UninhabitedTupleStruct(!); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the matched value is of type `UninhabitedTupleStruct` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown - | -LL ~ match x { -LL + _ => todo!(), -LL ~ } - | - -error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered - --> $DIR/match_with_exhaustive_patterns.rs:34:11 - | -LL | match x {} - | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered - | -note: `UninhabitedVariants` defined here - --> $DIR/auxiliary/uninhabited.rs:17:23 - | -LL | pub enum UninhabitedVariants { - | ---------------------------- -LL | #[non_exhaustive] Tuple(!), - | ^^^^^ not covered -LL | #[non_exhaustive] Struct { x: ! } - | ^^^^^^ not covered - = note: the matched value is of type `UninhabitedVariants` -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms - | -LL ~ match x { -LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), -LL ~ } - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs deleted file mode 100644 index de5530485..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs +++ /dev/null @@ -1,47 +0,0 @@ -// check-pass - -#![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -struct A; - -// This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate -// will compile. In particular, this enables the `exhaustive_patterns` feature as this can -// change the branch used in the compiler to determine this. -// Codegen is skipped because tests with long names can cause issues on Windows CI, see #60648. - -fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { - match x {} -} - -fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { - match x {} -} - -fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { - match x {} -} - -fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { - match x {} -} - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns.rs deleted file mode 100644 index 221b5cf6b..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns.rs +++ /dev/null @@ -1,59 +0,0 @@ -// aux-build:uninhabited.rs -// build-pass (FIXME(62277): could be check-pass?) -#![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] - -extern crate uninhabited; - -use uninhabited::{ - PartiallyInhabitedVariants, - UninhabitedEnum, - UninhabitedStruct, - UninhabitedTupleStruct, - UninhabitedVariants, -}; - -fn uninhabited_enum() -> Option { - None -} - -fn uninhabited_variant() -> Option { - None -} - -fn partially_inhabited_variant() -> PartiallyInhabitedVariants { - PartiallyInhabitedVariants::Tuple(3) -} - -fn uninhabited_struct() -> Option { - None -} - -fn uninhabited_tuple_struct() -> Option { - None -} - -// This test checks that non-exhaustive types that would normally be considered uninhabited within -// the defining crate are not considered uninhabited from extern crates. - -fn main() { - match uninhabited_enum() { - Some(_x) => (), // This line would normally error. - None => (), - } - - match uninhabited_variant() { - Some(_x) => (), // This line would normally error. - None => (), - } - - // This line would normally error. - while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inhabited_variant() { - } - - while let Some(_x) = uninhabited_struct() { // This line would normally error. - } - - while let Some(_x) = uninhabited_tuple_struct() { // This line would normally error. - } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs deleted file mode 100644 index ffc496a97..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs +++ /dev/null @@ -1,70 +0,0 @@ -#![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] -#![feature(never_type)] - -#[non_exhaustive] -pub enum UninhabitedEnum { -} - -#[non_exhaustive] -pub struct UninhabitedTupleStruct(!); - -#[non_exhaustive] -pub struct UninhabitedStruct { - _priv: !, -} - -pub enum UninhabitedVariants { - #[non_exhaustive] Tuple(!), - #[non_exhaustive] Struct { x: ! } -} - -pub enum PartiallyInhabitedVariants { - Tuple(u8), - #[non_exhaustive] Struct { x: ! } -} - -fn uninhabited_enum() -> Option { - None -} - -fn uninhabited_variant() -> Option { - None -} - -fn partially_inhabited_variant() -> PartiallyInhabitedVariants { - PartiallyInhabitedVariants::Tuple(3) -} - -fn uninhabited_struct() -> Option { - None -} - -fn uninhabited_tuple_struct() -> Option { - None -} - -// This test checks that non-exhaustive types that would normally be considered uninhabited within -// the defining crate are still considered uninhabited. - -fn main() { - match uninhabited_enum() { - Some(_x) => (), //~ ERROR unreachable pattern - None => (), - } - - match uninhabited_variant() { - Some(_x) => (), //~ ERROR unreachable pattern - None => (), - } - - while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() { - //~^ ERROR unreachable pattern - } - - while let Some(_x) = uninhabited_struct() { //~ ERROR unreachable pattern - } - - while let Some(_x) = uninhabited_tuple_struct() { //~ ERROR unreachable pattern - } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr b/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr deleted file mode 100644 index 8bfd6e91f..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: unreachable pattern - --> $DIR/patterns_same_crate.rs:52:9 - | -LL | Some(_x) => (), - | ^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/patterns_same_crate.rs:1:9 - | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: unreachable pattern - --> $DIR/patterns_same_crate.rs:57:9 - | -LL | Some(_x) => (), - | ^^^^^^^^ - -error: unreachable pattern - --> $DIR/patterns_same_crate.rs:61:15 - | -LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: unreachable pattern - --> $DIR/patterns_same_crate.rs:65:15 - | -LL | while let Some(_x) = uninhabited_struct() { - | ^^^^^^^^ - -error: unreachable pattern - --> $DIR/patterns_same_crate.rs:68:15 - | -LL | while let Some(_x) = uninhabited_tuple_struct() { - | ^^^^^^^^ - -error: aborting due to 5 previous errors - diff --git a/tests/ui/rfc-2008-non-exhaustive/variant.rs b/tests/ui/rfc-2008-non-exhaustive/variant.rs deleted file mode 100644 index bc346aea5..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/variant.rs +++ /dev/null @@ -1,33 +0,0 @@ -// aux-build:variants.rs - -extern crate variants; - -use variants::NonExhaustiveVariants; - -fn main() { - let variant_struct = NonExhaustiveVariants::Struct { field: 640 }; - //~^ ERROR cannot create non-exhaustive variant - - let variant_tuple = NonExhaustiveVariants::Tuple(640); - //~^ ERROR tuple variant `Tuple` is private [E0603] - - let variant_unit = NonExhaustiveVariants::Unit; - //~^ ERROR unit variant `Unit` is private [E0603] - - match variant_struct { - NonExhaustiveVariants::Unit => "", - //~^ ERROR unit variant `Unit` is private [E0603] - NonExhaustiveVariants::Tuple(fe_tpl) => "", - //~^ ERROR tuple variant `Tuple` is private [E0603] - NonExhaustiveVariants::Struct { field } => "" - //~^ ERROR `..` required with variant marked as non-exhaustive - }; - - if let NonExhaustiveVariants::Tuple(fe_tpl) = variant_struct { - //~^ ERROR tuple variant `Tuple` is private [E0603] - } - - if let NonExhaustiveVariants::Struct { field } = variant_struct { - //~^ ERROR `..` required with variant marked as non-exhaustive - } -} diff --git a/tests/ui/rfc-2008-non-exhaustive/variant.stderr b/tests/ui/rfc-2008-non-exhaustive/variant.stderr deleted file mode 100644 index 4083f57a9..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/variant.stderr +++ /dev/null @@ -1,102 +0,0 @@ -error[E0603]: tuple variant `Tuple` is private - --> $DIR/variant.rs:11:48 - | -LL | let variant_tuple = NonExhaustiveVariants::Tuple(640); - | ^^^^^ private tuple variant - | -note: the tuple variant `Tuple` is defined here - --> $DIR/auxiliary/variants.rs:5:23 - | -LL | #[non_exhaustive] Tuple(u32), - | ----------------- ^^^^^ - | | - | cannot be constructed because it is `#[non_exhaustive]` - -error[E0603]: unit variant `Unit` is private - --> $DIR/variant.rs:14:47 - | -LL | let variant_unit = NonExhaustiveVariants::Unit; - | ^^^^ private unit variant - | -note: the unit variant `Unit` is defined here - --> $DIR/auxiliary/variants.rs:4:23 - | -LL | #[non_exhaustive] Unit, - | ----------------- ^^^^ - | | - | cannot be constructed because it is `#[non_exhaustive]` - -error[E0603]: unit variant `Unit` is private - --> $DIR/variant.rs:18:32 - | -LL | NonExhaustiveVariants::Unit => "", - | ^^^^ private unit variant - | -note: the unit variant `Unit` is defined here - --> $DIR/auxiliary/variants.rs:4:23 - | -LL | #[non_exhaustive] Unit, - | ----------------- ^^^^ - | | - | cannot be constructed because it is `#[non_exhaustive]` - -error[E0603]: tuple variant `Tuple` is private - --> $DIR/variant.rs:20:32 - | -LL | NonExhaustiveVariants::Tuple(fe_tpl) => "", - | ^^^^^ private tuple variant - | -note: the tuple variant `Tuple` is defined here - --> $DIR/auxiliary/variants.rs:5:23 - | -LL | #[non_exhaustive] Tuple(u32), - | ----------------- ^^^^^ - | | - | cannot be constructed because it is `#[non_exhaustive]` - -error[E0603]: tuple variant `Tuple` is private - --> $DIR/variant.rs:26:35 - | -LL | if let NonExhaustiveVariants::Tuple(fe_tpl) = variant_struct { - | ^^^^^ private tuple variant - | -note: the tuple variant `Tuple` is defined here - --> $DIR/auxiliary/variants.rs:5:23 - | -LL | #[non_exhaustive] Tuple(u32), - | ----------------- ^^^^^ - | | - | cannot be constructed because it is `#[non_exhaustive]` - -error[E0639]: cannot create non-exhaustive variant using struct expression - --> $DIR/variant.rs:8:26 - | -LL | let variant_struct = NonExhaustiveVariants::Struct { field: 640 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0638]: `..` required with variant marked as non-exhaustive - --> $DIR/variant.rs:22:9 - | -LL | NonExhaustiveVariants::Struct { field } => "" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: add `..` at the end of the field list to ignore all other fields - | -LL | NonExhaustiveVariants::Struct { field , .. } => "" - | ~~~~~~ - -error[E0638]: `..` required with variant marked as non-exhaustive - --> $DIR/variant.rs:30:12 - | -LL | if let NonExhaustiveVariants::Struct { field } = variant_struct { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: add `..` at the end of the field list to ignore all other fields - | -LL | if let NonExhaustiveVariants::Struct { field , .. } = variant_struct { - | ~~~~~~ - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0603, E0638, E0639. -For more information about an error, try `rustc --explain E0603`. diff --git a/tests/ui/rfc-2008-non-exhaustive/variants_fictive_visibility.rs b/tests/ui/rfc-2008-non-exhaustive/variants_fictive_visibility.rs deleted file mode 100644 index dacaf489a..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/variants_fictive_visibility.rs +++ /dev/null @@ -1,12 +0,0 @@ -// build-pass (FIXME(62277): could be check-pass?) -// aux-build:variants.rs - -extern crate variants; - -const S: u8 = 0; - -// OK, `Struct` in value namespace is crate-private, so it's filtered away -// and there's no conflict with the previously defined `const S`. -use variants::NonExhaustiveVariants::Struct as S; - -fn main() {} diff --git a/tests/ui/rfc-2008-non-exhaustive/variants_same_crate.rs b/tests/ui/rfc-2008-non-exhaustive/variants_same_crate.rs deleted file mode 100644 index 5f2816ec6..000000000 --- a/tests/ui/rfc-2008-non-exhaustive/variants_same_crate.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - #[non_exhaustive] Tuple(u32), - #[non_exhaustive] Struct { field: u32 } -} - -fn main() { - let variant_tuple = NonExhaustiveVariants::Tuple(340); - let _variant_struct = NonExhaustiveVariants::Struct { field: 340 }; - - match variant_tuple { - NonExhaustiveVariants::Unit => "", - NonExhaustiveVariants::Tuple(_fe_tpl) => "", - NonExhaustiveVariants::Struct { field: _ } => "" - }; -} diff --git a/tests/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs b/tests/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs deleted file mode 100644 index fa04f4b12..000000000 --- a/tests/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Check that we if we get ahold of an object unsafe trait -// object with auto traits and lifetimes, we can downcast it -// -// check-pass - -#![feature(object_safe_for_dispatch)] - -trait Trait: Sized {} - -fn downcast_auto(t: &(dyn Trait + Send)) -> &dyn Trait { - t -} - -fn downcast_lifetime<'a, 'b, 't>(t: &'a (dyn Trait + 't)) - -> &'b (dyn Trait + 't) -where - 'a: 'b, - 't: 'a + 'b, -{ - t -} - -fn main() {} diff --git a/tests/ui/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs b/tests/ui/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs deleted file mode 100644 index 721890db4..000000000 --- a/tests/ui/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Check that we can manually implement an object-unsafe trait for its trait object. - -// run-pass - -#![feature(object_safe_for_dispatch)] - -trait Bad { - fn stat() -> char { - 'A' - } - fn virt(&self) -> char { - 'B' - } - fn indirect(&self) -> char { - Self::stat() - } -} - -trait Good { - fn good_virt(&self) -> char { - panic!() - } - fn good_indirect(&self) -> char { - panic!() - } -} - -impl<'a> Bad for dyn Bad + 'a { - fn stat() -> char { - 'C' - } - fn virt(&self) -> char { - 'D' - } -} - -struct Struct {} - -impl Bad for Struct {} - -impl Good for Struct {} - -fn main() { - let s = Struct {}; - - let mut res = String::new(); - - // Directly call static. - res.push(Struct::stat()); // "A" - res.push(::stat()); // "AC" - - let good: &dyn Good = &s; - - // These look similar enough... - let bad = unsafe { std::mem::transmute::<&dyn Good, &dyn Bad>(good) }; - - // Call virtual. - res.push(s.virt()); // "ACB" - res.push(bad.virt()); // "ACBD" - - // Indirectly call static. - res.push(s.indirect()); // "ACBDA" - res.push(bad.indirect()); // "ACBDAC" - - assert_eq!(&res, "ACBDAC"); -} diff --git a/tests/ui/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs b/tests/ui/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs deleted file mode 100644 index df97d2c13..000000000 --- a/tests/ui/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Check that we can statically dispatch methods for object -// unsafe trait objects, directly and indirectly -// -// check-pass - -#![feature(object_safe_for_dispatch)] - -trait Statics { - fn plain() {} - fn generic() {} -} - -trait Trait: Sized {} - -impl<'a> Statics for dyn Trait + 'a {} - -fn static_poly() { - T::plain(); - T::generic::(); -} - -fn inferred_poly(t: &T) { - static_poly::(); - T::plain(); - T::generic::(); -} - -fn call(t: &dyn Trait) { - static_poly::(); - inferred_poly(t); -} - -fn main() { - static_poly::(); - ::plain(); - ::generic::() -} diff --git a/tests/ui/rfc-2091-track-caller/call-chain.rs b/tests/ui/rfc-2091-track-caller/call-chain.rs deleted file mode 100644 index a8814ce28..000000000 --- a/tests/ui/rfc-2091-track-caller/call-chain.rs +++ /dev/null @@ -1,30 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[default] compile-flags: -Zinline-mir=false -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -use std::panic::Location; - -struct Foo; - -impl Foo { - #[inline(always)] - #[track_caller] - fn check_loc(&self, line: u32, col: u32) -> &Self { - let loc = Location::caller(); - assert_eq!(loc.file(), file!(), "file mismatch"); - assert_eq!(loc.line(), line, "line mismatch"); - assert_eq!(loc.column(), col, "column mismatch"); - self - } -} - -fn main() { - // Tests that when `Location::caller` is used in a method chain, - // it points to the start of the correct call (the first character after the dot) - // instead of to the very first expression in the chain - let foo = Foo; - foo. - check_loc(line!(), 9).check_loc(line!(), 31) - .check_loc(line!(), 10); -} diff --git a/tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs b/tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs deleted file mode 100644 index a3bed707e..000000000 --- a/tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Ensure that a `#[track_caller]` function, returning `caller_location()`, -// which coerced (to a function pointer) and called, inside a `const fn`, -// in turn called, results in the same output irrespective of whether -// we're in a const or runtime context. - -// run-pass -// compile-flags: -Z unleash-the-miri-inside-of-you - -#![feature(core_intrinsics, const_caller_location)] - -type L = &'static std::panic::Location<'static>; - -#[track_caller] -const fn attributed() -> L { - std::intrinsics::caller_location() -} - -const fn calling_attributed() -> L { - // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers. - let ptr: fn() -> L = attributed; - ptr() -} - -fn main() { - const CONSTANT: L = calling_attributed(); - let runtime = calling_attributed(); - - assert_eq!( - (runtime.file(), runtime.line(), runtime.column()), - (CONSTANT.file(), CONSTANT.line(), CONSTANT.column()), - ); -} diff --git a/tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr b/tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr deleted file mode 100644 index cf8ca5771..000000000 --- a/tests/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:21:5 - | -LL | ptr() - | ^^^^^ - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-2091-track-caller/caller-location-intrinsic.rs b/tests/ui/rfc-2091-track-caller/caller-location-intrinsic.rs deleted file mode 100644 index e5754d355..000000000 --- a/tests/ui/rfc-2091-track-caller/caller-location-intrinsic.rs +++ /dev/null @@ -1,27 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -#[inline(never)] -#[track_caller] -fn codegen_caller_loc() -> &'static core::panic::Location<'static> { - core::panic::Location::caller() -} - -macro_rules! caller_location_from_macro { - () => (codegen_caller_loc()); -} - -fn main() { - let loc = codegen_caller_loc(); - assert_eq!(loc.file(), file!()); - assert_eq!(loc.line(), 16); - assert_eq!(loc.column(), 15); - - // `Location::caller()` in a macro should behave similarly to `file!` and `line!`, - // i.e. point to where the macro was invoked, instead of the macro itself. - let loc2 = caller_location_from_macro!(); - assert_eq!(loc2.file(), file!()); - assert_eq!(loc2.line(), 23); - assert_eq!(loc2.column(), 16); -} diff --git a/tests/ui/rfc-2091-track-caller/const-caller-location.rs b/tests/ui/rfc-2091-track-caller/const-caller-location.rs deleted file mode 100644 index 6e15cf3fe..000000000 --- a/tests/ui/rfc-2091-track-caller/const-caller-location.rs +++ /dev/null @@ -1,43 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -#![feature(const_caller_location)] - -use std::panic::Location; - -const LOCATION: &Location = Location::caller(); - -const TRACKED: &Location = tracked(); -#[track_caller] -const fn tracked() -> &'static Location <'static> { - Location::caller() -} - -const NESTED: &Location = nested_location(); -const fn nested_location() -> &'static Location<'static> { - Location::caller() -} - -const CONTAINED: &Location = contained(); -const fn contained() -> &'static Location<'static> { - tracked() -} - -fn main() { - assert_eq!(LOCATION.file(), file!()); - assert_eq!(LOCATION.line(), 9); - assert_eq!(LOCATION.column(), 29); - - assert_eq!(TRACKED.file(), file!()); - assert_eq!(TRACKED.line(), 11); - assert_eq!(TRACKED.column(), 28); - - assert_eq!(NESTED.file(), file!()); - assert_eq!(NESTED.line(), 19); - assert_eq!(NESTED.column(), 5); - - assert_eq!(CONTAINED.file(), file!()); - assert_eq!(CONTAINED.line(), 24); - assert_eq!(CONTAINED.column(), 5); -} diff --git a/tests/ui/rfc-2091-track-caller/diverging-caller-location.rs b/tests/ui/rfc-2091-track-caller/diverging-caller-location.rs deleted file mode 100644 index 668111955..000000000 --- a/tests/ui/rfc-2091-track-caller/diverging-caller-location.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-fail - -//! This test ensures that `#[track_caller]` can be applied directly to diverging functions, as -//! the tracking issue says: https://github.com/rust-lang/rust/issues/47809#issue-292138490. -//! Because the annotated function must diverge and a panic keeps that faster than an infinite loop, -//! we don't inspect the location returned -- it would be difficult to distinguish between the -//! explicit panic and a failed assertion. That it compiles and runs is enough for this one. - -#[track_caller] -fn doesnt_return() -> ! { - let _location = core::panic::Location::caller(); - panic!("huzzah"); -} - -fn main() { - doesnt_return(); -} diff --git a/tests/ui/rfc-2091-track-caller/error-odd-syntax.rs b/tests/ui/rfc-2091-track-caller/error-odd-syntax.rs deleted file mode 100644 index 6f4290e2a..000000000 --- a/tests/ui/rfc-2091-track-caller/error-odd-syntax.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[track_caller(1)] -fn f() {} -//~^^ ERROR malformed `track_caller` attribute input - -fn main() {} diff --git a/tests/ui/rfc-2091-track-caller/error-odd-syntax.stderr b/tests/ui/rfc-2091-track-caller/error-odd-syntax.stderr deleted file mode 100644 index e7ddf8df4..000000000 --- a/tests/ui/rfc-2091-track-caller/error-odd-syntax.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: malformed `track_caller` attribute input - --> $DIR/error-odd-syntax.rs:1:1 - | -LL | #[track_caller(1)] - | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[track_caller]` - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2091-track-caller/error-with-invalid-abi.rs b/tests/ui/rfc-2091-track-caller/error-with-invalid-abi.rs deleted file mode 100644 index 074e1ceb7..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-invalid-abi.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[track_caller] -extern "C" fn f() {} -//~^^ ERROR `#[track_caller]` requires Rust ABI - -extern "C" { - #[track_caller] - fn g(); - //~^^ ERROR `#[track_caller]` requires Rust ABI -} - -fn main() {} diff --git a/tests/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr b/tests/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr deleted file mode 100644 index bcc0c8170..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-invalid-abi.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/error-with-invalid-abi.rs:1:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/error-with-invalid-abi.rs:6:5 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0737`. diff --git a/tests/ui/rfc-2091-track-caller/error-with-main.rs b/tests/ui/rfc-2091-track-caller/error-with-main.rs deleted file mode 100644 index b2ea31bb5..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-main.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[track_caller] //~ ERROR `main` function is not allowed to be -fn main() { - panic!("{}: oh no", std::panic::Location::caller()); -} diff --git a/tests/ui/rfc-2091-track-caller/error-with-main.stderr b/tests/ui/rfc-2091-track-caller/error-with-main.stderr deleted file mode 100644 index 6d6562dae..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-main.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `main` function is not allowed to be `#[track_caller]` - --> $DIR/error-with-main.rs:1:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ help: remove this annotation -LL | fn main() { - | --------- `main` function is not allowed to be `#[track_caller]` - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2091-track-caller/error-with-naked.rs b/tests/ui/rfc-2091-track-caller/error-with-naked.rs deleted file mode 100644 index 43e33cbb1..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-naked.rs +++ /dev/null @@ -1,24 +0,0 @@ -// needs-asm-support -#![feature(naked_functions)] - -use std::arch::asm; - -#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` -//~^ ERROR `#[track_caller]` requires Rust ABI -#[naked] -extern "C" fn f() { - asm!("", options(noreturn)); -} - -struct S; - -impl S { - #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` - //~^ ERROR `#[track_caller]` requires Rust ABI - #[naked] - extern "C" fn g() { - asm!("", options(noreturn)); - } -} - -fn main() {} diff --git a/tests/ui/rfc-2091-track-caller/error-with-naked.stderr b/tests/ui/rfc-2091-track-caller/error-with-naked.stderr deleted file mode 100644 index 3f7d0df42..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-naked.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0736]: cannot use `#[track_caller]` with `#[naked]` - --> $DIR/error-with-naked.rs:6:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error[E0736]: cannot use `#[track_caller]` with `#[naked]` - --> $DIR/error-with-naked.rs:16:5 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/error-with-naked.rs:6:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/error-with-naked.rs:16:5 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0736, E0737. -For more information about an error, try `rustc --explain E0736`. diff --git a/tests/ui/rfc-2091-track-caller/error-with-start.rs b/tests/ui/rfc-2091-track-caller/error-with-start.rs deleted file mode 100644 index 0cab47170..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-start.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(start)] - -#[start] -#[track_caller] //~ ERROR `start` is not allowed to be `#[track_caller]` -fn start(_argc: isize, _argv: *const *const u8) -> isize { - panic!("{}: oh no", std::panic::Location::caller()); -} diff --git a/tests/ui/rfc-2091-track-caller/error-with-start.stderr b/tests/ui/rfc-2091-track-caller/error-with-start.stderr deleted file mode 100644 index 454c98ff9..000000000 --- a/tests/ui/rfc-2091-track-caller/error-with-start.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `start` is not allowed to be `#[track_caller]` - --> $DIR/error-with-start.rs:4:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ -LL | fn start(_argc: isize, _argv: *const *const u8) -> isize { - | -------------------------------------------------------- `start` is not allowed to be `#[track_caller]` - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs b/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs deleted file mode 100644 index 23d2a4b0a..000000000 --- a/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[default] compile-flags: -Zinline-mir=no -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -macro_rules! caller_location_from_macro { - () => (core::panic::Location::caller()); -} - -fn main() { - let loc = core::panic::Location::caller(); - assert_eq!(loc.file(), file!()); - assert_eq!(loc.line(), 11); - assert_eq!(loc.column(), 15); - - // `Location::caller()` in a macro should behave similarly to `file!` and `line!`, - // i.e. point to where the macro was invoked, instead of the macro itself. - let loc2 = caller_location_from_macro!(); - assert_eq!(loc2.file(), file!()); - assert_eq!(loc2.line(), 18); - assert_eq!(loc2.column(), 16); -} diff --git a/tests/ui/rfc-2091-track-caller/macro-declaration.rs b/tests/ui/rfc-2091-track-caller/macro-declaration.rs deleted file mode 100644 index 6ca09fac8..000000000 --- a/tests/ui/rfc-2091-track-caller/macro-declaration.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -// See https://github.com/rust-lang/rust/issues/95151 -#[track_caller] -macro_rules! _foo { - () => {}; -} - -fn main() { -} diff --git a/tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs b/tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs deleted file mode 100644 index a2e8eb27e..000000000 --- a/tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[default] compile-flags: -Zinline-mir=no -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -use std::panic::Location; - -macro_rules! f { - () => { - Location::caller() - }; -} - -#[inline(always)] -fn g() -> &'static Location<'static> { - f!() -} - -fn main() { - let loc = g(); - assert_eq!(loc.line(), 16); - assert_eq!(loc.column(), 5); -} diff --git a/tests/ui/rfc-2091-track-caller/only-for-fns.rs b/tests/ui/rfc-2091-track-caller/only-for-fns.rs deleted file mode 100644 index 2d2b01b6f..000000000 --- a/tests/ui/rfc-2091-track-caller/only-for-fns.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[track_caller] -struct S; -//~^^ ERROR attribute should be applied to a function definition - -fn main() {} diff --git a/tests/ui/rfc-2091-track-caller/only-for-fns.stderr b/tests/ui/rfc-2091-track-caller/only-for-fns.stderr deleted file mode 100644 index b36597bde..000000000 --- a/tests/ui/rfc-2091-track-caller/only-for-fns.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0739]: attribute should be applied to a function definition - --> $DIR/only-for-fns.rs:1:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ -LL | struct S; - | --------- not a function definition - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0739`. diff --git a/tests/ui/rfc-2091-track-caller/pass.rs b/tests/ui/rfc-2091-track-caller/pass.rs deleted file mode 100644 index 1b13ea3e9..000000000 --- a/tests/ui/rfc-2091-track-caller/pass.rs +++ /dev/null @@ -1,10 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -#[track_caller] -fn f() {} - -fn main() { - f(); -} diff --git a/tests/ui/rfc-2091-track-caller/std-panic-locations.rs b/tests/ui/rfc-2091-track-caller/std-panic-locations.rs deleted file mode 100644 index f11456250..000000000 --- a/tests/ui/rfc-2091-track-caller/std-panic-locations.rs +++ /dev/null @@ -1,64 +0,0 @@ -// run-pass -// needs-unwind -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -#![allow(unconditional_panic)] - -//! Test that panic locations for `#[track_caller]` functions in std have the correct -//! location reported. - -use std::cell::RefCell; -use std::collections::{BTreeMap, HashMap, VecDeque}; -use std::ops::{Index, IndexMut}; -use std::panic::{AssertUnwindSafe, UnwindSafe}; - -fn main() { - // inspect the `PanicInfo` we receive to ensure the right file is the source - std::panic::set_hook(Box::new(|info| { - let actual = info.location().unwrap(); - if actual.file() != file!() { - eprintln!("expected a location in the test file, found {:?}", actual); - panic!(); - } - })); - - fn assert_panicked(f: impl FnOnce() + UnwindSafe) { - std::panic::catch_unwind(f).unwrap_err(); - } - - let nope: Option<()> = None; - assert_panicked(|| nope.unwrap()); - assert_panicked(|| nope.expect("")); - - let oops: Result<(), ()> = Err(()); - assert_panicked(|| oops.unwrap()); - assert_panicked(|| oops.expect("")); - - let fine: Result<(), ()> = Ok(()); - assert_panicked(|| fine.unwrap_err()); - assert_panicked(|| fine.expect_err("")); - - let mut small = [0]; // the implementation backing str, vec, etc - assert_panicked(move || { small.index(1); }); - assert_panicked(move || { small[1]; }); - assert_panicked(move || { small.index_mut(1); }); - assert_panicked(move || { small[1] += 1; }); - - let sorted: BTreeMap = Default::default(); - assert_panicked(|| { sorted.index(&false); }); - assert_panicked(|| { sorted[&false]; }); - - let unsorted: HashMap = Default::default(); - assert_panicked(|| { unsorted.index(&false); }); - assert_panicked(|| { unsorted[&false]; }); - - let weirdo: VecDeque<()> = Default::default(); - assert_panicked(|| { weirdo.index(1); }); - assert_panicked(|| { weirdo[1]; }); - - let refcell: RefCell<()> = Default::default(); - let _conflicting = refcell.borrow_mut(); - assert_panicked(AssertUnwindSafe(|| { refcell.borrow(); })); - assert_panicked(AssertUnwindSafe(|| { refcell.borrow_mut(); })); -} diff --git a/tests/ui/rfc-2091-track-caller/track-caller-attribute.rs b/tests/ui/rfc-2091-track-caller/track-caller-attribute.rs deleted file mode 100644 index 9d28eb9de..000000000 --- a/tests/ui/rfc-2091-track-caller/track-caller-attribute.rs +++ /dev/null @@ -1,40 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -use std::panic::Location; - -#[track_caller] -fn tracked() -> &'static Location<'static> { - Location::caller() -} - -fn nested_intrinsic() -> &'static Location<'static> { - Location::caller() -} - -fn nested_tracked() -> &'static Location<'static> { - tracked() -} - -fn main() { - let location = Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), 21); - assert_eq!(location.column(), 20); - - let tracked = tracked(); - assert_eq!(tracked.file(), file!()); - assert_eq!(tracked.line(), 26); - assert_eq!(tracked.column(), 19); - - let nested = nested_intrinsic(); - assert_eq!(nested.file(), file!()); - assert_eq!(nested.line(), 13); - assert_eq!(nested.column(), 5); - - let contained = nested_tracked(); - assert_eq!(contained.file(), file!()); - assert_eq!(contained.line(), 17); - assert_eq!(contained.column(), 5); -} diff --git a/tests/ui/rfc-2091-track-caller/track-caller-ffi.rs b/tests/ui/rfc-2091-track-caller/track-caller-ffi.rs deleted file mode 100644 index 5115f687c..000000000 --- a/tests/ui/rfc-2091-track-caller/track-caller-ffi.rs +++ /dev/null @@ -1,48 +0,0 @@ -// run-pass - -use std::panic::Location; - -extern "Rust" { - #[track_caller] - fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>; - fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static>; -} - -fn rust_track_caller_ffi_test_nested_tracked() -> &'static Location<'static> { - unsafe { rust_track_caller_ffi_test_tracked() } -} - -mod provides { - use std::panic::Location; - #[track_caller] // UB if we did not have this! - #[no_mangle] - fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static> { - Location::caller() - } - #[no_mangle] - fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static> { - Location::caller() - } -} - -fn main() { - let location = Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), 29); - assert_eq!(location.column(), 20); - - let tracked = unsafe { rust_track_caller_ffi_test_tracked() }; - assert_eq!(tracked.file(), file!()); - assert_eq!(tracked.line(), 34); - assert_eq!(tracked.column(), 28); - - let untracked = unsafe { rust_track_caller_ffi_test_untracked() }; - assert_eq!(untracked.file(), file!()); - assert_eq!(untracked.line(), 24); - assert_eq!(untracked.column(), 9); - - let contained = rust_track_caller_ffi_test_nested_tracked(); - assert_eq!(contained.file(), file!()); - assert_eq!(contained.line(), 12); - assert_eq!(contained.column(), 14); -} diff --git a/tests/ui/rfc-2091-track-caller/tracked-closure.rs b/tests/ui/rfc-2091-track-caller/tracked-closure.rs deleted file mode 100644 index 670c423a7..000000000 --- a/tests/ui/rfc-2091-track-caller/tracked-closure.rs +++ /dev/null @@ -1,154 +0,0 @@ -// run-pass - -#![feature(stmt_expr_attributes)] -#![feature(closure_track_caller)] -#![feature(generator_trait)] -#![feature(generators)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; -use std::panic::Location; - -type Loc = &'static Location<'static>; - -#[track_caller] -fn mono_invoke_fn (&'static str, bool, Loc)>( - val: &F -) -> (&'static str, bool, Loc) { - val("from_mono", false) -} - -#[track_caller] -fn mono_invoke_fn_once (&'static str, bool, Loc)>( - val: F -) -> (&'static str, bool, Loc) { - val("from_mono", false) -} - -#[track_caller] -fn dyn_invoke_fn_mut( - val: &mut dyn FnMut(&'static str, bool) -> (&'static str, bool, Loc) -) -> (&'static str, bool, Loc) { - val("from_dyn", false) -} - -#[track_caller] -fn dyn_invoke_fn_once( - val: Box (&'static str, bool, Loc)> -) -> (&'static str, bool, Loc) { - val("from_dyn", false) -} - - -fn test_closure() { - let mut track_closure = #[track_caller] |first: &'static str, second: bool| { - (first, second, Location::caller()) - }; - let (first_arg, first_bool, first_loc) = track_closure("first_arg", true); - let first_line = line!() - 1; - assert_eq!(first_arg, "first_arg"); - assert_eq!(first_bool, true); - assert_eq!(first_loc.file(), file!()); - assert_eq!(first_loc.line(), first_line); - assert_eq!(first_loc.column(), 46); - - let (dyn_arg, dyn_bool, dyn_loc) = dyn_invoke_fn_mut(&mut track_closure); - assert_eq!(dyn_arg, "from_dyn"); - assert_eq!(dyn_bool, false); - // `FnMut::call_mut` does not have `#[track_caller]`, - // so this will not match - assert_ne!(dyn_loc.file(), file!()); - - let (dyn_arg, dyn_bool, dyn_loc) = dyn_invoke_fn_once(Box::new(track_closure)); - assert_eq!(dyn_arg, "from_dyn"); - assert_eq!(dyn_bool, false); - // `FnOnce::call_once` does not have `#[track_caller]` - // so this will not match - assert_ne!(dyn_loc.file(), file!()); - - - let (mono_arg, mono_bool, mono_loc) = mono_invoke_fn(&track_closure); - let mono_line = line!() - 1; - assert_eq!(mono_arg, "from_mono"); - assert_eq!(mono_bool, false); - assert_eq!(mono_loc.file(), file!()); - assert_eq!(mono_loc.line(), mono_line); - assert_eq!(mono_loc.column(), 43); - - let (mono_arg, mono_bool, mono_loc) = mono_invoke_fn_once(track_closure); - let mono_line = line!() - 1; - assert_eq!(mono_arg, "from_mono"); - assert_eq!(mono_bool, false); - assert_eq!(mono_loc.file(), file!()); - assert_eq!(mono_loc.line(), mono_line); - assert_eq!(mono_loc.column(), 43); - - let non_tracked_caller = || Location::caller(); - let non_tracked_line = line!() - 1; // This is the line of the closure, not its caller - let non_tracked_loc = non_tracked_caller(); - assert_eq!(non_tracked_loc.file(), file!()); - assert_eq!(non_tracked_loc.line(), non_tracked_line); - assert_eq!(non_tracked_loc.column(), 33); -} - - -#[track_caller] -fn mono_generator>( - val: Pin<&mut F> -) -> (&'static str, String, Loc) { - match val.resume("Mono".to_string()) { - GeneratorState::Yielded(val) => val, - _ => unreachable!() - } -} - -#[track_caller] -fn dyn_generator( - val: Pin<&mut dyn Generator> -) -> (&'static str, String, Loc) { - match val.resume("Dyn".to_string()) { - GeneratorState::Yielded(val) => val, - _ => unreachable!() - } -} - -fn test_generator() { - let generator = #[track_caller] |arg: String| { - yield ("first", arg.clone(), Location::caller()); - yield ("second", arg.clone(), Location::caller()); - }; - - let mut pinned = Box::pin(generator); - let (dyn_ret, dyn_arg, dyn_loc) = dyn_generator(pinned.as_mut()); - assert_eq!(dyn_ret, "first"); - assert_eq!(dyn_arg, "Dyn".to_string()); - // The `Generator` trait does not have `#[track_caller]` on `resume`, so - // this will not match. - assert_ne!(dyn_loc.file(), file!()); - - - let (mono_ret, mono_arg, mono_loc) = mono_generator(pinned.as_mut()); - let mono_line = line!() - 1; - assert_eq!(mono_ret, "second"); - // The generator ignores the argument to the second `resume` call - assert_eq!(mono_arg, "Dyn".to_string()); - assert_eq!(mono_loc.file(), file!()); - assert_eq!(mono_loc.line(), mono_line); - assert_eq!(mono_loc.column(), 42); - - let non_tracked_generator = || { yield Location::caller(); }; - let non_tracked_line = line!() - 1; // This is the line of the generator, not its caller - let non_tracked_loc = match Box::pin(non_tracked_generator).as_mut().resume(()) { - GeneratorState::Yielded(val) => val, - _ => unreachable!() - }; - assert_eq!(non_tracked_loc.file(), file!()); - assert_eq!(non_tracked_loc.line(), non_tracked_line); - assert_eq!(non_tracked_loc.column(), 44); - -} - -fn main() { - test_closure(); - test_generator(); -} diff --git a/tests/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs b/tests/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs deleted file mode 100644 index 658812578..000000000 --- a/tests/ui/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs +++ /dev/null @@ -1,62 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -fn pass_to_ptr_call(f: fn(T), x: T) { - f(x); -} - -#[track_caller] -fn tracked_unit(_: ()) { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); -} - -trait Trait { - fn trait_tracked_unit(_: ()); -} - -impl Trait for () { - #[track_caller] - fn trait_tracked_unit(_: ()) { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); - } -} - -trait TrackedTrait { - #[track_caller] - fn trait_tracked_unit_default(_: ()) { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); - } -} - -impl TrackedTrait for () {} - -trait BlanketTrackedTrait { - #[track_caller] - fn tracked_blanket(_: ()); -} - -impl BlanketTrackedTrait for () { - fn tracked_blanket(_: ()) { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); - } -} - -fn main() { - pass_to_ptr_call(tracked_unit, ()); - pass_to_ptr_call(<() as Trait>::trait_tracked_unit, ()); - pass_to_ptr_call(<() as TrackedTrait>::trait_tracked_unit_default, ()); - pass_to_ptr_call(<() as BlanketTrackedTrait>::tracked_blanket, ()); -} diff --git a/tests/ui/rfc-2091-track-caller/tracked-fn-ptr.rs b/tests/ui/rfc-2091-track-caller/tracked-fn-ptr.rs deleted file mode 100644 index 8bb4dd288..000000000 --- a/tests/ui/rfc-2091-track-caller/tracked-fn-ptr.rs +++ /dev/null @@ -1,62 +0,0 @@ -// run-pass -// revisions: default mir-opt -//[mir-opt] compile-flags: -Zmir-opt-level=4 - -fn ptr_call(f: fn()) { - f(); -} - -#[track_caller] -fn tracked() { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); -} - -trait Trait { - fn trait_tracked(); -} - -impl Trait for () { - #[track_caller] - fn trait_tracked() { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); - } -} - -trait TrackedTrait { - #[track_caller] - fn trait_tracked_default() { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); - } -} - -impl TrackedTrait for () {} - -trait TraitBlanketTracked { - #[track_caller] - fn tracked_blanket(); -} - -impl TraitBlanketTracked for () { - fn tracked_blanket() { - let expected_line = line!() - 1; - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); - } -} - -fn main() { - ptr_call(tracked); - ptr_call(<() as Trait>::trait_tracked); - ptr_call(<() as TrackedTrait>::trait_tracked_default); - ptr_call(<() as TraitBlanketTracked>::tracked_blanket); -} diff --git a/tests/ui/rfc-2091-track-caller/tracked-trait-impls.rs b/tests/ui/rfc-2091-track-caller/tracked-trait-impls.rs deleted file mode 100644 index 4db4c29e5..000000000 --- a/tests/ui/rfc-2091-track-caller/tracked-trait-impls.rs +++ /dev/null @@ -1,77 +0,0 @@ -// run-pass - -macro_rules! assert_expansion_site_is_tracked { - () => {{ - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_ne!(location.line(), line!(), "line should be outside this fn"); - }} -} - -trait Tracked { - fn local_tracked(&self); - - #[track_caller] - fn blanket_tracked(&self); - - #[track_caller] - fn default_tracked(&self) { - assert_expansion_site_is_tracked!(); - } -} - -impl Tracked for () { - #[track_caller] - fn local_tracked(&self) { - assert_expansion_site_is_tracked!(); - } - - fn blanket_tracked(&self) { - assert_expansion_site_is_tracked!(); - } -} - -impl Tracked for bool { - #[track_caller] - fn local_tracked(&self) { - assert_expansion_site_is_tracked!(); - } - - fn blanket_tracked(&self) { - assert_expansion_site_is_tracked!(); - } - - fn default_tracked(&self) { - assert_expansion_site_is_tracked!(); - } -} - -impl Tracked for u8 { - #[track_caller] - fn local_tracked(&self) { - assert_expansion_site_is_tracked!(); - } - - fn blanket_tracked(&self) { - assert_expansion_site_is_tracked!(); - } - - #[track_caller] - fn default_tracked(&self) { - assert_expansion_site_is_tracked!(); - } -} - -fn main() { - ().local_tracked(); - ().default_tracked(); - ().blanket_tracked(); - - true.local_tracked(); - true.default_tracked(); - true.blanket_tracked(); - - 0u8.local_tracked(); - 0u8.default_tracked(); - 0u8.blanket_tracked(); -} diff --git a/tests/ui/rfc-2091-track-caller/tracked-trait-obj.rs b/tests/ui/rfc-2091-track-caller/tracked-trait-obj.rs deleted file mode 100644 index 06883a857..000000000 --- a/tests/ui/rfc-2091-track-caller/tracked-trait-obj.rs +++ /dev/null @@ -1,61 +0,0 @@ -// run-pass - -trait Tracked { - #[track_caller] - fn track_caller_trait_method(&self, line: u32, col: u32) { - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - // The trait method definition is annotated with `#[track_caller]`, - // so caller location information will work through a method - // call on a trait object - assert_eq!(location.line(), line, "Bad line"); - assert_eq!(location.column(), col, "Bad col"); - } - - fn track_caller_not_on_trait_method(&self); - - #[track_caller] - fn track_caller_through_self(self: Box, line: u32, col: u32); -} - -impl Tracked for () { - // We have `#[track_caller]` on the implementation of the method, - // but not on the definition of the method in the trait. Therefore, - // caller location information will *not* work through a method call - // on a trait object. Instead, we will get the location of this method - #[track_caller] - fn track_caller_not_on_trait_method(&self) { - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - assert_eq!(location.line(), line!() - 3); - assert_eq!(location.column(), 5); - } - - // We don't have a `#[track_caller]` attribute, but - // `#[track_caller]` is present on the trait definition, - // so we'll still get location information - fn track_caller_through_self(self: Box, line: u32, col: u32) { - let location = std::panic::Location::caller(); - assert_eq!(location.file(), file!()); - // The trait method definition is annotated with `#[track_caller]`, - // so caller location information will work through a method - // call on a trait object - assert_eq!(location.line(), line, "Bad line"); - assert_eq!(location.column(), col, "Bad col"); - } -} - -fn main() { - let tracked: &dyn Tracked = &(); - // The column is the start of 'track_caller_trait_method' - tracked.track_caller_trait_method(line!(), 13); - - const TRACKED: &dyn Tracked = &(); - // The column is the start of 'track_caller_trait_method' - TRACKED.track_caller_trait_method(line!(), 13); - TRACKED.track_caller_not_on_trait_method(); - - // The column is the start of `track_caller_through_self` - let boxed: Box = Box::new(()); - boxed.track_caller_through_self(line!(), 11); -} diff --git a/tests/ui/rfc-2093-infer-outlives/cross-crate.rs b/tests/ui/rfc-2093-infer-outlives/cross-crate.rs deleted file mode 100644 index a9bfeabf1..000000000 --- a/tests/ui/rfc-2093-infer-outlives/cross-crate.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'a, T> { //~ ERROR rustc_outlives - bar: std::slice::IterMut<'a, T> -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/cross-crate.stderr b/tests/ui/rfc-2093-infer-outlives/cross-crate.stderr deleted file mode 100644 index 76300cce5..000000000 --- a/tests/ui/rfc-2093-infer-outlives/cross-crate.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/cross-crate.rs:4:1 - | -LL | struct Foo<'a, T> { - | ^^^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs b/tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs deleted file mode 100644 index d3940b13b..000000000 --- a/tests/ui/rfc-2093-infer-outlives/dont-infer-static.rs +++ /dev/null @@ -1,12 +0,0 @@ -/* - * We don't infer `T: 'static` outlives relationships. - */ - -struct Foo { - bar: Bar //~ ERROR the parameter type `U` may not live long enough [E0310] -} -struct Bar { - x: T, -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr deleted file mode 100644 index 0c388f5fe..000000000 --- a/tests/ui/rfc-2093-infer-outlives/dont-infer-static.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0310]: the parameter type `U` may not live long enough - --> $DIR/dont-infer-static.rs:6:10 - | -LL | bar: Bar - | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/dont-infer-static.rs:8:15 - | -LL | struct Bar { - | ^^^^^^^ -help: consider adding an explicit lifetime bound... - | -LL | struct Foo { - | +++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/rfc-2093-infer-outlives/enum.rs b/tests/ui/rfc-2093-infer-outlives/enum.rs deleted file mode 100644 index 71d2d3222..000000000 --- a/tests/ui/rfc-2093-infer-outlives/enum.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![feature(rustc_attrs)] - -// Needs an explicit where clause stating outlives condition. (RFC 2093) - -// Type T needs to outlive lifetime 'a. -#[rustc_outlives] -enum Foo<'a, T> { //~ ERROR rustc_outlives - One(Bar<'a, T>) -} - -// Type U needs to outlive lifetime 'b -#[rustc_outlives] -struct Bar<'b, U> { //~ ERROR rustc_outlives - field2: &'b U -} - -// Type K needs to outlive lifetime 'c. -#[rustc_outlives] -enum Ying<'c, K> { //~ ERROR rustc_outlives - One(&'c Yang) -} - -struct Yang { - field2: V -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/enum.stderr b/tests/ui/rfc-2093-infer-outlives/enum.stderr deleted file mode 100644 index b6ce2450e..000000000 --- a/tests/ui/rfc-2093-infer-outlives/enum.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: rustc_outlives - --> $DIR/enum.rs:7:1 - | -LL | enum Foo<'a, T> { - | ^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: rustc_outlives - --> $DIR/enum.rs:13:1 - | -LL | struct Bar<'b, U> { - | ^^^^^^^^^^^^^^^^^ - | - = note: U: 'b - -error: rustc_outlives - --> $DIR/enum.rs:19:1 - | -LL | enum Ying<'c, K> { - | ^^^^^^^^^^^^^^^^ - | - = note: K: 'c - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs b/tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs deleted file mode 100644 index 419fb0a0e..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-dyn.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(rustc_attrs)] - -trait Trait<'x, T> where T: 'x { -} - -#[rustc_outlives] -struct Foo<'a, A> //~ ERROR rustc_outlives -{ - foo: Box> -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr deleted file mode 100644 index 595a5c280..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-dyn.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/explicit-dyn.rs:7:1 - | -LL | struct Foo<'a, A> - | ^^^^^^^^^^^^^^^^^ - | - = note: A: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-enum.rs b/tests/ui/rfc-2093-infer-outlives/explicit-enum.rs deleted file mode 100644 index c330c27fe..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-enum.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -enum Foo<'a, U> { //~ ERROR rustc_outlives - One(Bar<'a, U>) -} - -struct Bar<'x, T> where T: 'x { - x: &'x (), - y: T, -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr deleted file mode 100644 index 3059f95ae..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-enum.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/explicit-enum.rs:4:1 - | -LL | enum Foo<'a, U> { - | ^^^^^^^^^^^^^^^ - | - = note: U: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-projection.rs b/tests/ui/rfc-2093-infer-outlives/explicit-projection.rs deleted file mode 100644 index 00b895288..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-projection.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] - -trait Trait<'x, T> where T: 'x { - type Type; -} - -#[rustc_outlives] -struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives -{ - foo: >::Type -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr deleted file mode 100644 index 589e95899..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-projection.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/explicit-projection.rs:8:1 - | -LL | struct Foo<'a, A, B> where A: Trait<'a, B> - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: B: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-struct.rs b/tests/ui/rfc-2093-infer-outlives/explicit-struct.rs deleted file mode 100644 index 3d5e610b9..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-struct.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'b, U> { //~ ERROR rustc_outlives - bar: Bar<'b, U> -} - -struct Bar<'a, T> where T: 'a { - x: &'a (), - y: T, -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr deleted file mode 100644 index 9912e36b2..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-struct.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/explicit-struct.rs:4:1 - | -LL | struct Foo<'b, U> { - | ^^^^^^^^^^^^^^^^^ - | - = note: U: 'b - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-union.rs b/tests/ui/rfc-2093-infer-outlives/explicit-union.rs deleted file mode 100644 index 871208b5b..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-union.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -union Foo<'b, U: Copy> { //~ ERROR rustc_outlives - bar: Bar<'b, U> -} - -#[derive(Clone, Copy)] -union Bar<'a, T: Copy> where T: 'a { - x: &'a (), - y: T, -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/explicit-union.stderr b/tests/ui/rfc-2093-infer-outlives/explicit-union.stderr deleted file mode 100644 index 16b64bdc2..000000000 --- a/tests/ui/rfc-2093-infer-outlives/explicit-union.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/explicit-union.rs:4:1 - | -LL | union Foo<'b, U: Copy> { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: U: 'b - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/issue-54467.rs b/tests/ui/rfc-2093-infer-outlives/issue-54467.rs deleted file mode 100644 index c712f15e3..000000000 --- a/tests/ui/rfc-2093-infer-outlives/issue-54467.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Regression test for #54467: -// -// Here, the trait object has an "inferred outlives" requirement that -// `>::Item: 'a`; but since we don't know what -// `Self` is, we were (incorrectly) messing things up, leading to -// strange errors. This test ensures that we do not give compilation -// errors. -// -// check-pass - -trait MyIterator<'a>: Iterator where Self::Item: 'a { } - -struct MyStruct<'a, A> { - item: Box> -} - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/nested-enum.rs b/tests/ui/rfc-2093-infer-outlives/nested-enum.rs deleted file mode 100644 index 0cd706e7a..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-enum.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -enum Foo<'a, T> { //~ ERROR rustc_outlives - - One(Bar<'a, T>) -} - -struct Bar<'b, U> { - field2: &'b U -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/nested-enum.stderr b/tests/ui/rfc-2093-infer-outlives/nested-enum.stderr deleted file mode 100644 index 4350e6e8b..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-enum.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/nested-enum.rs:4:1 - | -LL | enum Foo<'a, T> { - | ^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/nested-regions.rs b/tests/ui/rfc-2093-infer-outlives/nested-regions.rs deleted file mode 100644 index a01c50681..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-regions.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives - x: &'a &'b T -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/nested-regions.stderr b/tests/ui/rfc-2093-infer-outlives/nested-regions.stderr deleted file mode 100644 index c08add7ed..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-regions.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: rustc_outlives - --> $DIR/nested-regions.rs:4:1 - | -LL | struct Foo<'a, 'b, T> { - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: 'b: 'a - = note: T: 'a - = note: T: 'b - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/nested-structs.rs b/tests/ui/rfc-2093-infer-outlives/nested-structs.rs deleted file mode 100644 index ac6817d22..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-structs.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'a, T> { //~ ERROR rustc_outlives - field1: Bar<'a, T> -} - -struct Bar<'b, U> { - field2: &'b U -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/nested-structs.stderr b/tests/ui/rfc-2093-infer-outlives/nested-structs.stderr deleted file mode 100644 index 769555234..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-structs.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/nested-structs.rs:4:1 - | -LL | struct Foo<'a, T> { - | ^^^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/nested-union.rs b/tests/ui/rfc-2093-infer-outlives/nested-union.rs deleted file mode 100644 index 27ebd0b54..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-union.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -union Foo<'a, T: Copy> { //~ ERROR rustc_outlives - field1: Bar<'a, T> -} - -// Type U needs to outlive lifetime 'b -#[derive(Clone, Copy)] -union Bar<'b, U: Copy> { - field2: &'b U -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/nested-union.stderr b/tests/ui/rfc-2093-infer-outlives/nested-union.stderr deleted file mode 100644 index a785c63ce..000000000 --- a/tests/ui/rfc-2093-infer-outlives/nested-union.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/nested-union.rs:4:1 - | -LL | union Foo<'a, T: Copy> { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/privacy.rs b/tests/ui/rfc-2093-infer-outlives/privacy.rs deleted file mode 100644 index 180f5ac6c..000000000 --- a/tests/ui/rfc-2093-infer-outlives/privacy.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Test that we do not get a privacy error here. Initially, we did, -// because we inferred an outlives predciate of ` as -// Private>::Out: 'a`, but the private trait is -- well -- private, -// and hence it was not something that a pub trait could refer to. -// -// run-pass - -#![allow(dead_code)] - -pub struct Foo<'a> { - field: Option<&'a as Private>::Out> -} - -trait Private { - type Out: ?Sized; -} - -impl Private for T { type Out = Self; } - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/projection.rs b/tests/ui/rfc-2093-infer-outlives/projection.rs deleted file mode 100644 index 411c86da1..000000000 --- a/tests/ui/rfc-2093-infer-outlives/projection.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives - bar: &'a T::Item -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/projection.stderr b/tests/ui/rfc-2093-infer-outlives/projection.stderr deleted file mode 100644 index d9342013f..000000000 --- a/tests/ui/rfc-2093-infer-outlives/projection.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/projection.rs:4:1 - | -LL | struct Foo<'a, T: Iterator> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: ::Item: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/reference.rs b/tests/ui/rfc-2093-infer-outlives/reference.rs deleted file mode 100644 index a48a3315a..000000000 --- a/tests/ui/rfc-2093-infer-outlives/reference.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'a, T> { //~ ERROR rustc_outlives - bar: &'a T, -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/reference.stderr b/tests/ui/rfc-2093-infer-outlives/reference.stderr deleted file mode 100644 index 508114357..000000000 --- a/tests/ui/rfc-2093-infer-outlives/reference.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/reference.rs:4:1 - | -LL | struct Foo<'a, T> { - | ^^^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs b/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs deleted file mode 100644 index 8b491ee4e..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Various examples of structs whose fields are not well-formed. - -#![allow(dead_code)] - -trait Dummy<'a> { - type Out; -} -impl<'a, T> Dummy<'a> for T -where - T: 'a, -{ - type Out = (); -} -type RequireOutlives<'a, T> = >::Out; - -enum Ref1<'a, T> { - Ref1Variant1(RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough -} - -enum Ref2<'a, T> { - Ref2Variant1, - Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough -} - -enum RefOk<'a, T: 'a> { - RefOkVariant1(&'a T), -} - -// This is now well formed. RFC 2093 -enum RefIndirect<'a, T> { - RefIndirectVariant1(isize, RefOk<'a, T>), -} - -enum RefDouble<'a, 'b, T> { - RefDoubleVariant1(&'a RequireOutlives<'b, T>), - //~^ the parameter type `T` may not live long enough [E0309] -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr deleted file mode 100644 index 2c660b285..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:17:18 - | -LL | Ref1Variant1(RequireOutlives<'a, T>), - | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound... - | -LL | enum Ref1<'a, T: 'a> { - | ++++ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:22:25 - | -LL | Ref2Variant2(isize, RequireOutlives<'a, T>), - | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound... - | -LL | enum Ref2<'a, T: 'a> { - | ++++ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:35:23 - | -LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound... - | -LL | enum RefDouble<'a, 'b, T: 'b> { - | ++++ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs deleted file mode 100644 index 36b024d2e..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - - -#![allow(dead_code)] - -mod rev_variant_struct_region { - struct Foo<'a> { - x: fn(&'a i32), - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime - } -} - - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr deleted file mode 100644 index 5dff4c8ff..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:20 - | -LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs deleted file mode 100644 index 47a38f7c4..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - - -#![allow(dead_code)] - -mod variant_struct_region { - struct Foo<'a> { - x: &'a i32, - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime - } -} - - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr deleted file mode 100644 index 975776cdd..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region.rs:17:20 - | -LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-nominal-type-region.rs:16:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-nominal-type-region.rs:16:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs deleted file mode 100644 index 083ba8948..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - - -#![allow(dead_code)] - -mod variant_struct_type { - struct Foo { - x: fn(T) - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime - } -} - - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr deleted file mode 100644 index be05ecec0..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:20 - | -LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs deleted file mode 100644 index f3e4e39ac..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - - -#![allow(dead_code)] - -mod variant_struct_type { - struct Foo { - x: T - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime - } -} - - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr deleted file mode 100644 index 4ba1778d6..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type.rs:17:20 - | -LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-nominal-type-type.rs:16:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-nominal-type-type.rs:16:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs b/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs deleted file mode 100644 index 552c6cf00..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Various examples of structs whose fields are not well-formed. - -#![allow(dead_code)] - -trait Trait<'a, T> { - type Out; -} -trait Trait1<'a, 'b, T> { - type Out; -} - -impl<'a, T> Trait<'a, T> for usize { - type Out = &'a T; //~ ERROR `T` may not live long enough -} - -struct RefOk<'a, T:'a> { - field: &'a T -} - -impl<'a, T> Trait<'a, T> for u32 { - type Out = RefOk<'a, T>; //~ ERROR `T` may not live long enough -} - -impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - type Out = &'a &'b T; //~ ERROR reference has a longer lifetime than the data -} - -fn main() { } diff --git a/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr deleted file mode 100644 index 34ff1362c..000000000 --- a/tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:13:16 - | -LL | type Out = &'a T; - | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at - | -help: consider adding an explicit lifetime bound... - | -LL | impl<'a, T: 'a> Trait<'a, T> for usize { - | ++++ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:21:16 - | -LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/regions-struct-not-wf.rs:16:20 - | -LL | struct RefOk<'a, T:'a> { - | ^^ -help: consider adding an explicit lifetime bound... - | -LL | impl<'a, T: 'a> Trait<'a, T> for u32 { - | ++++ - -error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:25:16 - | -LL | type Out = &'a &'b T; - | ^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-struct-not-wf.rs:24:6 - | -LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-struct-not-wf.rs:24:10 - | -LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - | ^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. diff --git a/tests/ui/rfc-2093-infer-outlives/self-dyn.rs b/tests/ui/rfc-2093-infer-outlives/self-dyn.rs deleted file mode 100644 index c53d6c18f..000000000 --- a/tests/ui/rfc-2093-infer-outlives/self-dyn.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] - -trait Trait<'x, 's, T> where T: 'x, - 's: { -} - -#[rustc_outlives] -struct Foo<'a, 'b, A> //~ ERROR rustc_outlives -{ - foo: Box> -} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/self-dyn.stderr b/tests/ui/rfc-2093-infer-outlives/self-dyn.stderr deleted file mode 100644 index 9c836b190..000000000 --- a/tests/ui/rfc-2093-infer-outlives/self-dyn.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/self-dyn.rs:8:1 - | -LL | struct Foo<'a, 'b, A> - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: A: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2093-infer-outlives/self-structs.rs b/tests/ui/rfc-2093-infer-outlives/self-structs.rs deleted file mode 100644 index 8f2d29d6f..000000000 --- a/tests/ui/rfc-2093-infer-outlives/self-structs.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives - field1: dyn Bar<'a, 'b, T> -} - -trait Bar<'x, 's, U> - where U: 'x, - Self:'s -{} - -fn main() {} diff --git a/tests/ui/rfc-2093-infer-outlives/self-structs.stderr b/tests/ui/rfc-2093-infer-outlives/self-structs.stderr deleted file mode 100644 index 2b4625f77..000000000 --- a/tests/ui/rfc-2093-infer-outlives/self-structs.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: rustc_outlives - --> $DIR/self-structs.rs:4:1 - | -LL | struct Foo<'a, 'b, T> { - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: T: 'a - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.rs b/tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.rs deleted file mode 100644 index 79f6b0dfe..000000000 --- a/tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.rs +++ /dev/null @@ -1,11 +0,0 @@ -struct S; - -pub mod m { - fn f() { - let s = ::m::crate::S; //~ ERROR failed to resolve - let s1 = ::crate::S; //~ ERROR failed to resolve - let s2 = crate::S; // no error - } -} - -fn main() {} diff --git a/tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr b/tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr deleted file mode 100644 index 7e7ee3ce0..000000000 --- a/tests/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0433]: failed to resolve: `crate` in paths can only be used in start position - --> $DIR/crate-path-non-absolute.rs:5:22 - | -LL | let s = ::m::crate::S; - | ^^^^^ `crate` in paths can only be used in start position - -error[E0433]: failed to resolve: global paths cannot start with `crate` - --> $DIR/crate-path-non-absolute.rs:6:20 - | -LL | let s1 = ::crate::S; - | ^^^^^ global paths cannot start with `crate` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs b/tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs deleted file mode 100644 index 019ef8e9d..000000000 --- a/tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() { - let crate = 0; - //~^ ERROR expected unit struct, unit variant or constant, found module `crate` -} diff --git a/tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr b/tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr deleted file mode 100644 index c39a70f66..000000000 --- a/tests/ui/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0532]: expected unit struct, unit variant or constant, found module `crate` - --> $DIR/keyword-crate-as-identifier.rs:2:9 - | -LL | let crate = 0; - | ^^^^^ not a unit struct, unit variant or constant - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs b/tests/ui/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs deleted file mode 100644 index c4d444764..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Debug)] -pub struct S; - -#[derive(Debug)] -pub struct Z; diff --git a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.rs b/tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.rs deleted file mode 100644 index 9c0e0bef4..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.rs +++ /dev/null @@ -1,5 +0,0 @@ -// edition:2018 - -use xcrate::S; //~ ERROR unresolved import `xcrate` - -fn main() {} diff --git a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr b/tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr deleted file mode 100644 index 818915721..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0432]: unresolved import `xcrate` - --> $DIR/non-existent-1.rs:3:5 - | -LL | use xcrate::S; - | ^^^^^^ use of undeclared crate or module `xcrate` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs b/tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs deleted file mode 100644 index def60feb5..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs +++ /dev/null @@ -1,6 +0,0 @@ -// edition:2018 - -fn main() { - let s = ::xcrate::S; - //~^ ERROR failed to resolve: could not find `xcrate` in the list of imported crates -} diff --git a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr b/tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr deleted file mode 100644 index 7df4f06d1..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0433]: failed to resolve: could not find `xcrate` in the list of imported crates - --> $DIR/non-existent-2.rs:4:15 - | -LL | let s = ::xcrate::S; - | ^^^^^^ could not find `xcrate` in the list of imported crates - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.rs b/tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.rs deleted file mode 100644 index 486159c0e..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.rs +++ /dev/null @@ -1,5 +0,0 @@ -// edition:2018 - -use ycrate; //~ ERROR unresolved import `ycrate` - -fn main() {} diff --git a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.stderr b/tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.stderr deleted file mode 100644 index bd6778cf3..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/non-existent-3.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0432]: unresolved import `ycrate` - --> $DIR/non-existent-3.rs:3:5 - | -LL | use ycrate; - | ^^^^^^ no external crate `ycrate` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfc-2126-extern-absolute-paths/not-allowed.rs b/tests/ui/rfc-2126-extern-absolute-paths/not-allowed.rs deleted file mode 100644 index acb4bbebe..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/not-allowed.rs +++ /dev/null @@ -1,9 +0,0 @@ -// edition:2018 - -// Tests that arbitrary crates (other than `core`, `std` and `meta`) -// aren't allowed without `--extern`, even if they're in the sysroot. -use alloc; //~ ERROR unresolved import `alloc` -use test; // OK, imports the built-in attribute macro `#[test]`, but not the `test` crate. -use proc_macro; // OK, imports the built-in `proc_macro` attribute, but not the `proc_macro` crate. - -fn main() {} diff --git a/tests/ui/rfc-2126-extern-absolute-paths/not-allowed.stderr b/tests/ui/rfc-2126-extern-absolute-paths/not-allowed.stderr deleted file mode 100644 index 122e8fd35..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/not-allowed.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0432]: unresolved import `alloc` - --> $DIR/not-allowed.rs:5:5 - | -LL | use alloc; - | ^^^^^ no external crate `alloc` - | -help: consider importing one of these items instead - | -LL | use core::alloc; - | ~~~~~~~~~~~ -LL | use std::alloc; - | ~~~~~~~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfc-2126-extern-absolute-paths/single-segment.rs b/tests/ui/rfc-2126-extern-absolute-paths/single-segment.rs deleted file mode 100644 index 72e50d78b..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/single-segment.rs +++ /dev/null @@ -1,11 +0,0 @@ -// aux-build:xcrate.rs -// compile-flags:--extern xcrate -// edition:2018 - -use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` -use *; //~ ERROR cannot glob-import all possible crates - -fn main() { - let s = ::xcrate; //~ ERROR expected value, found crate `xcrate` - //~^ NOTE not a value -} diff --git a/tests/ui/rfc-2126-extern-absolute-paths/single-segment.stderr b/tests/ui/rfc-2126-extern-absolute-paths/single-segment.stderr deleted file mode 100644 index 253cc1bc5..000000000 --- a/tests/ui/rfc-2126-extern-absolute-paths/single-segment.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: crate root imports need to be explicitly named: `use crate as name;` - --> $DIR/single-segment.rs:5:5 - | -LL | use crate; - | ^^^^^ - -error: cannot glob-import all possible crates - --> $DIR/single-segment.rs:6:5 - | -LL | use *; - | ^ - -error[E0423]: expected value, found crate `xcrate` - --> $DIR/single-segment.rs:9:13 - | -LL | let s = ::xcrate; - | ^^^^^^^^ not a value - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/rfc-2294-if-let-guard/bindings.rs b/tests/ui/rfc-2294-if-let-guard/bindings.rs deleted file mode 100644 index 1f32e4af1..000000000 --- a/tests/ui/rfc-2294-if-let-guard/bindings.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(if_let_guard)] - -fn main() { - match Some(None) { - Some(x) if let Some(y) = x => (x, y), - _ => y, //~ ERROR cannot find value `y` - } - y //~ ERROR cannot find value `y` -} diff --git a/tests/ui/rfc-2294-if-let-guard/bindings.stderr b/tests/ui/rfc-2294-if-let-guard/bindings.stderr deleted file mode 100644 index 2463b7f3e..000000000 --- a/tests/ui/rfc-2294-if-let-guard/bindings.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0425]: cannot find value `y` in this scope - --> $DIR/bindings.rs:6:14 - | -LL | _ => y, - | ^ not found in this scope - -error[E0425]: cannot find value `y` in this scope - --> $DIR/bindings.rs:8:5 - | -LL | y - | ^ not found in this scope - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/rfc-2294-if-let-guard/feature-gate.rs b/tests/ui/rfc-2294-if-let-guard/feature-gate.rs deleted file mode 100644 index 3beb20f0a..000000000 --- a/tests/ui/rfc-2294-if-let-guard/feature-gate.rs +++ /dev/null @@ -1,96 +0,0 @@ -// gate-test-if_let_guard - -use std::ops::Range; - -fn _if_let_guard() { - match () { - () if let 0 = 1 => {} - //~^ ERROR `if let` guards are experimental - - () if (let 0 = 1) => {} - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - - () if (((let 0 = 1))) => {} - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - - () if true && let 0 = 1 => {} - //~^ ERROR `if let` guards are experimental - //~| ERROR `let` expressions in this position are unstable - - () if let 0 = 1 && true => {} - //~^ ERROR `if let` guards are experimental - //~| ERROR `let` expressions in this position are unstable - - () if (let 0 = 1) && true => {} - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - - () if true && (let 0 = 1) => {} - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - - () if (let 0 = 1) && (let 0 = 1) => {} - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - - () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - //~^ ERROR `if let` guards are experimental - //~| ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - - - () if let Range { start: _, end: _ } = (true..true) && false => {} - //~^ ERROR `if let` guards are experimental - //~| ERROR `let` expressions in this position are unstable - - _ => {} - } -} - -fn _macros() { - macro_rules! use_expr { - ($e:expr) => { - match () { - () if $e => {} - _ => {} - } - } - } - use_expr!((let 0 = 1 && 0 == 0)); - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - use_expr!((let 0 = 1)); - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR expected expression, found `let` statement - //~| ERROR `let` expressions are not supported here - match () { - #[cfg(FALSE)] - () if let 0 = 1 => {} - //~^ ERROR `if let` guards are experimental - _ => {} - } - use_expr!(let 0 = 1); - //~^ ERROR no rules expected the token `let` -} - -fn main() {} diff --git a/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr b/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr deleted file mode 100644 index dc182ce46..000000000 --- a/tests/ui/rfc-2294-if-let-guard/feature-gate.stderr +++ /dev/null @@ -1,431 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:10:16 - | -LL | () if (let 0 = 1) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:15:18 - | -LL | () if (((let 0 = 1))) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:28:16 - | -LL | () if (let 0 = 1) && true => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:33:24 - | -LL | () if true && (let 0 = 1) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:38:16 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:38:31 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:46:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:46:55 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:46:68 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:78:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:82:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^ - -error: no rules expected the token `let` - --> $DIR/feature-gate.rs:92:15 - | -LL | macro_rules! use_expr { - | --------------------- when calling this macro -... -LL | use_expr!(let 0 = 1); - | ^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr` - --> $DIR/feature-gate.rs:71:10 - | -LL | ($e:expr) => { - | ^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:10:16 - | -LL | () if (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:10:16 - | -LL | () if (let 0 = 1) => {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:15:18 - | -LL | () if (((let 0 = 1))) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:15:18 - | -LL | () if (((let 0 = 1))) => {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:28:16 - | -LL | () if (let 0 = 1) && true => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:28:16 - | -LL | () if (let 0 = 1) && true => {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:33:24 - | -LL | () if true && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:33:24 - | -LL | () if true && (let 0 = 1) => {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:38:16 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:38:16 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:38:31 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:38:31 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:46:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:46:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:46:55 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:46:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:46:68 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:46:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:78:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:78:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/feature-gate.rs:82:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:82:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:7:12 - | -LL | () if let 0 = 1 => {} - | ^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:20:12 - | -LL | () if true && let 0 = 1 => {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:24:12 - | -LL | () if let 0 = 1 && true => {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:46:12 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:61:12 - | -LL | () if let Range { start: _, end: _ } = (true..true) && false => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:88:12 - | -LL | () if let 0 = 1 => {} - | ^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:10:16 - | -LL | () if (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:15:18 - | -LL | () if (((let 0 = 1))) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:20:23 - | -LL | () if true && let 0 = 1 => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:24:15 - | -LL | () if let 0 = 1 && true => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:28:16 - | -LL | () if (let 0 = 1) && true => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:33:24 - | -LL | () if true && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:38:16 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:38:31 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:46:15 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:46:28 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:46:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:46:55 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:46:68 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:61:15 - | -LL | () if let Range { start: _, end: _ } = (true..true) && false => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:78:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:82:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error: aborting due to 45 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2294-if-let-guard/run-pass.rs b/tests/ui/rfc-2294-if-let-guard/run-pass.rs deleted file mode 100644 index a303a0d1f..000000000 --- a/tests/ui/rfc-2294-if-let-guard/run-pass.rs +++ /dev/null @@ -1,40 +0,0 @@ -// run-pass - -#![feature(if_let_guard)] - -enum Foo { - Bar, - Baz, - Qux(u8), -} - -fn bar(x: bool) -> Foo { - if x { Foo::Baz } else { Foo::Bar } -} - -fn baz(x: u8) -> Foo { - if x % 2 == 0 { Foo::Bar } else { Foo::Baz } -} - -fn qux(x: u8) -> Foo { - Foo::Qux(x.rotate_left(1)) -} - -fn main() { - match Some((true, 3)) { - Some((x, _)) if let Foo::Bar = bar(x) => panic!(), - Some((_, x)) if let Foo::Baz = baz(x) => {}, - _ => panic!(), - } - match Some(42) { - Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84), - _ => panic!(), - } - - // issue #88015 - #[allow(irrefutable_let_patterns)] - match () { - () | () if let x = 42 => assert_eq!(x, 42), - _ => panic!() - } -} diff --git a/tests/ui/rfc-2294-if-let-guard/typeck.rs b/tests/ui/rfc-2294-if-let-guard/typeck.rs deleted file mode 100644 index ad178dfa4..000000000 --- a/tests/ui/rfc-2294-if-let-guard/typeck.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(if_let_guard)] - -fn ok() -> Result, ()> { - Ok(Some(true)) -} - -fn main() { - match ok() { - Ok(x) if let Err(_) = x => {}, - //~^ ERROR mismatched types - Ok(x) if let 0 = x => {}, - //~^ ERROR mismatched types - _ => {} - } -} diff --git a/tests/ui/rfc-2294-if-let-guard/typeck.stderr b/tests/ui/rfc-2294-if-let-guard/typeck.stderr deleted file mode 100644 index 4ce97a68a..000000000 --- a/tests/ui/rfc-2294-if-let-guard/typeck.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/typeck.rs:9:22 - | -LL | Ok(x) if let Err(_) = x => {}, - | ^^^^^^ - this expression has type `Option` - | | - | expected `Option`, found `Result<_, _>` - | - = note: expected enum `Option` - found enum `Result<_, _>` - -error[E0308]: mismatched types - --> $DIR/typeck.rs:11:22 - | -LL | Ok(x) if let 0 = x => {}, - | ^ - this expression has type `Option` - | | - | expected `Option`, found integer - | - = note: expected enum `Option` - found type `{integer}` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-2294-if-let-guard/warns.rs b/tests/ui/rfc-2294-if-let-guard/warns.rs deleted file mode 100644 index 3ad1a50c6..000000000 --- a/tests/ui/rfc-2294-if-let-guard/warns.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(if_let_guard)] - -#[deny(irrefutable_let_patterns)] -fn irrefutable_let_guard() { - match Some(()) { - Some(x) if let () = x => {} - //~^ ERROR irrefutable `if let` guard - _ => {} - } -} - -#[deny(unreachable_patterns)] -fn unreachable_pattern() { - match Some(()) { - x if let None | None = x => {} - //~^ ERROR unreachable pattern - _ => {} - } -} - -fn main() {} diff --git a/tests/ui/rfc-2294-if-let-guard/warns.stderr b/tests/ui/rfc-2294-if-let-guard/warns.stderr deleted file mode 100644 index 75f22ac8d..000000000 --- a/tests/ui/rfc-2294-if-let-guard/warns.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error: irrefutable `if let` guard pattern - --> $DIR/warns.rs:6:24 - | -LL | Some(x) if let () = x => {} - | ^^ - | - = note: this pattern will always match, so the guard is useless - = help: consider removing the guard and adding a `let` inside the match arm -note: the lint level is defined here - --> $DIR/warns.rs:3:8 - | -LL | #[deny(irrefutable_let_patterns)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: unreachable pattern - --> $DIR/warns.rs:15:25 - | -LL | x if let None | None = x => {} - | ^^^^ - | -note: the lint level is defined here - --> $DIR/warns.rs:12:8 - | -LL | #[deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2306/convert-id-const-with-gate.rs b/tests/ui/rfc-2306/convert-id-const-with-gate.rs deleted file mode 100644 index 762dfbe48..000000000 --- a/tests/ui/rfc-2306/convert-id-const-with-gate.rs +++ /dev/null @@ -1,7 +0,0 @@ -// This test should pass since 'identity' is const fn. - -// build-pass (FIXME(62277): could be check-pass?) - -fn main() { - const _FOO: u8 = ::std::convert::identity(42u8); -} diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs deleted file mode 100644 index 542be3942..000000000 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs +++ /dev/null @@ -1,69 +0,0 @@ -// run-pass -// check-run-results - -// Tests ensuring that `dbg!(expr)` has the expected run-time behavior. -// as well as some compile time properties we expect. - -#![allow(dropping_copy_types)] - -#[derive(Copy, Clone, Debug)] -struct Unit; - -#[derive(Copy, Clone, Debug, PartialEq)] -struct Point { - x: T, - y: T, -} - -#[derive(Debug, PartialEq)] -struct NoCopy(usize); - -fn main() { - let a: Unit = dbg!(Unit); - let _: Unit = dbg!(a); - // We can move `a` because it's Copy. - drop(a); - - // `Point` will be faithfully formatted according to `{:#?}`. - let a = Point { x: 42, y: 24 }; - let b: Point = dbg!(Point { x: 42, y: 24 }); // test stringify!(..) - let c: Point = dbg!(b); - // Identity conversion: - assert_eq!(a, b); - assert_eq!(a, c); - // We can move `b` because it's Copy. - drop(b); - - // Without parameters works as expected. - let _: () = dbg!(); - - // Test that we can borrow and that successive applications is still identity. - let a = NoCopy(1337); - let b: &NoCopy = dbg!(dbg!(&a)); - assert_eq!(&a, b); - - // Test involving lifetimes of temporaries: - fn f<'a>(x: &'a u8) -> &'a u8 { x } - let a: &u8 = dbg!(f(&42)); - assert_eq!(a, &42); - - // Test side effects: - let mut foo = 41; - assert_eq!(7331, dbg!({ - foo += 1; - eprintln!("before"); - 7331 - })); - assert_eq!(foo, 42); - - // Test trailing comma: - assert_eq!(("Yeah",), dbg!(("Yeah",))); - - // Test multiple arguments: - assert_eq!((1u8, 2u32), dbg!(1, - 2)); - - // Test multiple arguments + trailing comma: - assert_eq!((1u8, 2u32, "Yeah"), dbg!(1u8, 2u32, - "Yeah",)); -} diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr b/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr deleted file mode 100644 index a20a6062c..000000000 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr +++ /dev/null @@ -1,28 +0,0 @@ -[$DIR/dbg-macro-expected-behavior.rs:22] Unit = Unit -[$DIR/dbg-macro-expected-behavior.rs:23] a = Unit -[$DIR/dbg-macro-expected-behavior.rs:29] Point { x: 42, y: 24 } = Point { - x: 42, - y: 24, -} -[$DIR/dbg-macro-expected-behavior.rs:30] b = Point { - x: 42, - y: 24, -} -[$DIR/dbg-macro-expected-behavior.rs:38] -[$DIR/dbg-macro-expected-behavior.rs:42] &a = NoCopy( - 1337, -) -[$DIR/dbg-macro-expected-behavior.rs:42] dbg!(& a) = NoCopy( - 1337, -) -[$DIR/dbg-macro-expected-behavior.rs:47] f(&42) = 42 -before -[$DIR/dbg-macro-expected-behavior.rs:52] { foo += 1; eprintln!("before"); 7331 } = 7331 -[$DIR/dbg-macro-expected-behavior.rs:60] ("Yeah",) = ( - "Yeah", -) -[$DIR/dbg-macro-expected-behavior.rs:63] 1 = 1 -[$DIR/dbg-macro-expected-behavior.rs:63] 2 = 2 -[$DIR/dbg-macro-expected-behavior.rs:67] 1u8 = 1 -[$DIR/dbg-macro-expected-behavior.rs:67] 2u32 = 2 -[$DIR/dbg-macro-expected-behavior.rs:67] "Yeah" = "Yeah" diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs b/tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs deleted file mode 100644 index 9f3c567b6..000000000 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Test ensuring that `dbg!(expr)` will take ownership of the argument. - -#[derive(Debug)] -struct NoCopy(usize); - -fn main() { - let a = NoCopy(0); - let _ = dbg!(a); - let _ = dbg!(a); //~ ERROR use of moved value -} diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr deleted file mode 100644 index e97fdcce1..000000000 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:9:18 - | -LL | let a = NoCopy(0); - | - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait -LL | let _ = dbg!(a); - | ------- value moved here -LL | let _ = dbg!(a); - | ^ value used here after move - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs b/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs deleted file mode 100644 index f2fb62d76..000000000 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`. - -struct NotDebug; - -fn main() { - let _: NotDebug = dbg!(NotDebug); //~ ERROR `NotDebug` doesn't implement `Debug` -} diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr deleted file mode 100644 index ce165e646..000000000 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `NotDebug` doesn't implement `Debug` - --> $DIR/dbg-macro-requires-debug.rs:6:23 - | -LL | let _: NotDebug = dbg!(NotDebug); - | ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}` - | - = help: the trait `Debug` is not implemented for `NotDebug` - = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider annotating `NotDebug` with `#[derive(Debug)]` - | -LL + #[derive(Debug)] -LL | struct NotDebug; - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs b/tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs deleted file mode 100644 index 5053c115b..000000000 --- a/tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(do_not_recommend)] - -pub trait Foo { -} - -impl Foo for i32 { -} - -pub trait Bar { -} - -#[do_not_recommend] -impl Bar for T { -} - -fn stuff(_: T) {} - -fn main() { - stuff(1u8); - //~^ the trait bound `u8: Foo` is not satisfied -} diff --git a/tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr b/tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr deleted file mode 100644 index a3e559054..000000000 --- a/tests/ui/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: the trait bound `u8: Foo` is not satisfied - --> $DIR/feature-gate-do_not_recommend.rs:19:11 - | -LL | stuff(1u8); - | ----- ^^^ the trait `Foo` is not implemented for `u8` - | | - | required by a bound introduced by this call - | - = help: the trait `Foo` is implemented for `i32` -note: required for `u8` to implement `Bar` - --> $DIR/feature-gate-do_not_recommend.rs:13:14 - | -LL | impl Bar for T { - | --- ^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required by a bound in `stuff` - --> $DIR/feature-gate-do_not_recommend.rs:16:13 - | -LL | fn stuff(_: T) {} - | ^^^ required by this bound in `stuff` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs b/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs deleted file mode 100644 index 91863f5e4..000000000 --- a/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![feature(do_not_recommend)] - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -const CONST: () = (); - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -static Static: () = (); - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -type Type = (); - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -enum Enum { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -extern { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -fn fun() { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -struct Struct { -} - -#[do_not_recommend] -//~^ `#[do_not_recommend]` can only be placed -trait Trait { -} - -#[do_not_recommend] -impl Trait for i32 { -} - -fn main() { -} diff --git a/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr b/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr deleted file mode 100644 index 01ebc23c8..000000000 --- a/tests/ui/rfc-2397-do-not-recommend/incorrect-locations.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:3:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:7:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:11:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:15:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:20:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:25:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:30:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: `#[do_not_recommend]` can only be placed on trait implementations - --> $DIR/incorrect-locations.rs:35:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 8 previous errors - diff --git a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs b/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs deleted file mode 100644 index f0c5c222e..000000000 --- a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.rs +++ /dev/null @@ -1,10 +0,0 @@ -trait Foo { -} - -#[do_not_recommend] -//~^ ERROR the `#[do_not_recommend]` attribute is an experimental feature -impl Foo for i32 { -} - -fn main() { -} diff --git a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr b/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr deleted file mode 100644 index 1597e5be4..000000000 --- a/tests/ui/rfc-2397-do-not-recommend/unstable-feature.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: the `#[do_not_recommend]` attribute is an experimental feature - --> $DIR/unstable-feature.rs:4:1 - | -LL | #[do_not_recommend] - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51992 for more information - = help: add `#![feature(do_not_recommend)]` 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/rfc-2457/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs b/tests/ui/rfc-2457/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs deleted file mode 100644 index e373b6438..000000000 --- a/tests/ui/rfc-2457/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs +++ /dev/null @@ -1 +0,0 @@ -pub trait Foo {} diff --git a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.rs b/tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.rs deleted file mode 100644 index c07ba54af..000000000 --- a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.rs +++ /dev/null @@ -1,3 +0,0 @@ -extern crate ьаг; //~ ERROR cannot load a crate with a non-ascii name `ьаг` - -fn main() {} diff --git a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.stderr b/tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.stderr deleted file mode 100644 index a8f3abe59..000000000 --- a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-1.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: cannot load a crate with a non-ascii name `ьаг` - --> $DIR/crate_name_nonascii_forbidden-1.rs:1:1 - | -LL | extern crate ьаг; - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.rs b/tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.rs deleted file mode 100644 index f8e033937..000000000 --- a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags:--extern му_сгате -// edition:2018 - -use му_сгате::baz; //~ ERROR cannot load a crate with a non-ascii name `му_сгате` - -fn main() {} diff --git a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.stderr b/tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.stderr deleted file mode 100644 index 05fc4fb22..000000000 --- a/tests/ui/rfc-2457/crate_name_nonascii_forbidden-2.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: cannot load a crate with a non-ascii name `му_сгате` - --> $DIR/crate_name_nonascii_forbidden-2.rs:4:5 - | -LL | use му_сгате::baz; - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2457/extern_block_nonascii_forbidden.rs b/tests/ui/rfc-2457/extern_block_nonascii_forbidden.rs deleted file mode 100644 index ad6825404..000000000 --- a/tests/ui/rfc-2457/extern_block_nonascii_forbidden.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(extern_types)] - -extern "C" { - type 一; //~ items in `extern` blocks cannot use non-ascii identifiers - fn 二(); //~ items in `extern` blocks cannot use non-ascii identifiers - static 三: usize; //~ items in `extern` blocks cannot use non-ascii identifiers -} - -fn main() {} diff --git a/tests/ui/rfc-2457/extern_block_nonascii_forbidden.stderr b/tests/ui/rfc-2457/extern_block_nonascii_forbidden.stderr deleted file mode 100644 index ca1b8a6e7..000000000 --- a/tests/ui/rfc-2457/extern_block_nonascii_forbidden.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error: items in `extern` blocks cannot use non-ascii identifiers - --> $DIR/extern_block_nonascii_forbidden.rs:4:10 - | -LL | extern "C" { - | ---------- in this `extern` block -LL | type 一; - | ^^ - | - = note: this limitation may be lifted in the future; see issue #83942 for more information - -error: items in `extern` blocks cannot use non-ascii identifiers - --> $DIR/extern_block_nonascii_forbidden.rs:5:8 - | -LL | extern "C" { - | ---------- in this `extern` block -LL | type 一; -LL | fn 二(); - | ^^ - | - = note: this limitation may be lifted in the future; see issue #83942 for more information - -error: items in `extern` blocks cannot use non-ascii identifiers - --> $DIR/extern_block_nonascii_forbidden.rs:6:12 - | -LL | extern "C" { - | ---------- in this `extern` block -... -LL | static 三: usize; - | ^^ - | - = note: this limitation may be lifted in the future; see issue #83942 for more information - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2457/idents-normalized.rs b/tests/ui/rfc-2457/idents-normalized.rs deleted file mode 100644 index 1023fee37..000000000 --- a/tests/ui/rfc-2457/idents-normalized.rs +++ /dev/null @@ -1,7 +0,0 @@ -// check-pass - -struct Résumé; // ['LATIN SMALL LETTER E WITH ACUTE'] - -fn main() { - let _ = Résumé; // ['LATIN SMALL LETTER E', 'COMBINING ACUTE ACCENT'] -} diff --git a/tests/ui/rfc-2457/mod_file_nonascii_forbidden.rs b/tests/ui/rfc-2457/mod_file_nonascii_forbidden.rs deleted file mode 100644 index e949e2319..000000000 --- a/tests/ui/rfc-2457/mod_file_nonascii_forbidden.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod řųśť; //~ trying to load file for -//~^ file not found for - -fn main() {} diff --git a/tests/ui/rfc-2457/mod_file_nonascii_forbidden.stderr b/tests/ui/rfc-2457/mod_file_nonascii_forbidden.stderr deleted file mode 100644 index 7639ae9f6..000000000 --- a/tests/ui/rfc-2457/mod_file_nonascii_forbidden.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0583]: file not found for module `řųśť` - --> $DIR/mod_file_nonascii_forbidden.rs:1:1 - | -LL | mod řųśť; - | ^^^^^^^^^ - | - = help: to create the module `řųśť`, create file "$DIR/řųśť.rs" or "$DIR/řųśť/mod.rs" - -error[E0754]: trying to load file for module `řųśť` with non-ascii identifier name - --> $DIR/mod_file_nonascii_forbidden.rs:1:5 - | -LL | mod řųśť; - | ^^^^ - | - = help: consider using the `#[path]` attribute to specify filesystem path - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0583, E0754. -For more information about an error, try `rustc --explain E0583`. diff --git a/tests/ui/rfc-2457/mod_file_nonascii_with_path_allowed.rs b/tests/ui/rfc-2457/mod_file_nonascii_with_path_allowed.rs deleted file mode 100644 index 94327846d..000000000 --- a/tests/ui/rfc-2457/mod_file_nonascii_with_path_allowed.rs +++ /dev/null @@ -1,6 +0,0 @@ -// check-pass - -#[path="auxiliary/mod_file_nonascii_with_path_allowed-aux.rs"] -mod řųśť; - -fn main() {} diff --git a/tests/ui/rfc-2457/mod_inline_nonascii_allowed.rs b/tests/ui/rfc-2457/mod_inline_nonascii_allowed.rs deleted file mode 100644 index e1d836b7c..000000000 --- a/tests/ui/rfc-2457/mod_inline_nonascii_allowed.rs +++ /dev/null @@ -1,7 +0,0 @@ -// check-pass - -mod řųśť { - const IS_GREAT: bool = true; -} - -fn main() {} diff --git a/tests/ui/rfc-2457/no_mangle_nonascii_forbidden.rs b/tests/ui/rfc-2457/no_mangle_nonascii_forbidden.rs deleted file mode 100644 index f4c126a6e..000000000 --- a/tests/ui/rfc-2457/no_mangle_nonascii_forbidden.rs +++ /dev/null @@ -1,20 +0,0 @@ -#[no_mangle] -pub fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier - -pub struct Foo; - -impl Foo { - #[no_mangle] - pub fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier -} - -trait Bar { - fn řųśť(); -} - -impl Bar for Foo { - #[no_mangle] - fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier -} - -fn main() {} diff --git a/tests/ui/rfc-2457/no_mangle_nonascii_forbidden.stderr b/tests/ui/rfc-2457/no_mangle_nonascii_forbidden.stderr deleted file mode 100644 index 459d5d6b5..000000000 --- a/tests/ui/rfc-2457/no_mangle_nonascii_forbidden.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0754]: `#[no_mangle]` requires ASCII identifier - --> $DIR/no_mangle_nonascii_forbidden.rs:2:1 - | -LL | pub fn řųśť() {} - | ^^^^^^^^^^^^^ - -error[E0754]: `#[no_mangle]` requires ASCII identifier - --> $DIR/no_mangle_nonascii_forbidden.rs:8:5 - | -LL | pub fn řųśť() {} - | ^^^^^^^^^^^^^ - -error[E0754]: `#[no_mangle]` requires ASCII identifier - --> $DIR/no_mangle_nonascii_forbidden.rs:17:5 - | -LL | fn řųśť() {} - | ^^^^^^^^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0754`. diff --git a/tests/ui/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs b/tests/ui/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs deleted file mode 100644 index d851fac8e..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass - -#![feature(let_chains)] -#![allow(irrefutable_let_patterns)] - -fn main() { - let first = Some(1); - let second = Some(2); - let mut n = 0; - if let x = first && let y = second && 1 == 1 { - assert_eq!(x, first); - assert_eq!(y, second); - n = 1; - } - assert_eq!(n, 1); -} diff --git a/tests/ui/rfc-2497-if-let-chains/ast-pretty-check.rs b/tests/ui/rfc-2497-if-let-chains/ast-pretty-check.rs deleted file mode 100644 index 69bc189dd..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ast-pretty-check.rs +++ /dev/null @@ -1,6 +0,0 @@ -// check-pass -// compile-flags: -Z unpretty=expanded - -fn main() { - if let 0 = 1 {} -} diff --git a/tests/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout b/tests/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout deleted file mode 100644 index e737ef26e..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(prelude_import)] -#![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; -#[macro_use] -extern crate std; -// check-pass -// compile-flags: -Z unpretty=expanded - -fn main() { if let 0 = 1 {} } diff --git a/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs b/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs deleted file mode 100644 index e6dee2a1d..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(let_chains)] - -fn let_or_guard(x: Result, ()>) { - match x { - Ok(opt) if let Some(4) = opt || false => {} - //~^ ERROR `let` expressions are not supported here - _ => {} - } -} - -fn hiding_unsafe_mod(x: Result, ()>) { - match x { - Ok(opt) - if { - unsafe mod a {}; - //~^ ERROR module cannot be declared unsafe - false - } => {} - _ => {} - } -} - -fn main() {} diff --git a/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr b/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr deleted file mode 100644 index 26850998c..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ast-validate-guards.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: `let` expressions are not supported here - --> $DIR/ast-validate-guards.rs:5:20 - | -LL | Ok(opt) if let Some(4) = opt || false => {} - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/ast-validate-guards.rs:5:38 - | -LL | Ok(opt) if let Some(4) = opt || false => {} - | ^^ - -error: module cannot be declared unsafe - --> $DIR/ast-validate-guards.rs:15:17 - | -LL | unsafe mod a {}; - | ^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2497-if-let-chains/chains-without-let.rs b/tests/ui/rfc-2497-if-let-chains/chains-without-let.rs deleted file mode 100644 index e0dded152..000000000 --- a/tests/ui/rfc-2497-if-let-chains/chains-without-let.rs +++ /dev/null @@ -1,20 +0,0 @@ -fn and_chain() { - let z; - if true && { z = 3; true} && z == 3 {} - //~^ ERROR E0381 -} - -fn and_chain_2() { - let z; - true && { z = 3; true} && z == 3; - //~^ ERROR E0381 -} - -fn or_chain() { - let z; - if false || { z = 3; false} || z == 3 {} - //~^ ERROR E0381 -} - -fn main() { -} diff --git a/tests/ui/rfc-2497-if-let-chains/chains-without-let.stderr b/tests/ui/rfc-2497-if-let-chains/chains-without-let.stderr deleted file mode 100644 index 30d5a6779..000000000 --- a/tests/ui/rfc-2497-if-let-chains/chains-without-let.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0381]: used binding `z` is possibly-uninitialized - --> $DIR/chains-without-let.rs:3:34 - | -LL | let z; - | - binding declared here but left uninitialized -LL | if true && { z = 3; true} && z == 3 {} - | ----- ^ `z` used here but it is possibly-uninitialized - | | - | binding initialized here in some conditions - -error[E0381]: used binding `z` is possibly-uninitialized - --> $DIR/chains-without-let.rs:9:31 - | -LL | let z; - | - binding declared here but left uninitialized -LL | true && { z = 3; true} && z == 3; - | ----- ^ `z` used here but it is possibly-uninitialized - | | - | binding initialized here in some conditions - -error[E0381]: used binding `z` is possibly-uninitialized - --> $DIR/chains-without-let.rs:15:36 - | -LL | let z; - | - binding declared here but left uninitialized -LL | if false || { z = 3; false} || z == 3 {} - | ----- ^ `z` used here but it is possibly-uninitialized - | | - | binding initialized here in some conditions - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/tests/ui/rfc-2497-if-let-chains/disallowed-positions.rs b/tests/ui/rfc-2497-if-let-chains/disallowed-positions.rs deleted file mode 100644 index 2a9a5472b..000000000 --- a/tests/ui/rfc-2497-if-let-chains/disallowed-positions.rs +++ /dev/null @@ -1,480 +0,0 @@ -// Here we test that `lowering` behaves correctly wrt. `let $pats = $expr` expressions. -// -// We want to make sure that `let` is banned in situations other than: -// -// expr = -// | ... -// | "if" expr_with_let block {"else" block}? -// | {label ":"}? while" expr_with_let block -// ; -// -// expr_with_let = -// | "let" top_pats "=" expr -// | expr_with_let "&&" expr_with_let -// | "(" expr_with_let ")" -// | expr -// ; -// -// To that end, we check some positions which is not part of the language above. - -#![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test. - -#![allow(irrefutable_let_patterns)] - -use std::ops::Range; - -fn main() {} - -fn _if() { - if (let 0 = 1) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - if (((let 0 = 1))) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - if (let 0 = 1) && true {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - if true && (let 0 = 1) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - if (let 0 = 1) && (let 0 = 1) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - - if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement -} - -fn _while() { - while (let 0 = 1) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - while (((let 0 = 1))) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - while (let 0 = 1) && true {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - while true && (let 0 = 1) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - while (let 0 = 1) && (let 0 = 1) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - - while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement -} - -fn _macros() { - macro_rules! use_expr { - ($e:expr) => { - if $e {} - while $e {} - } - } - use_expr!((let 0 = 1 && 0 == 0)); - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - use_expr!((let 0 = 1)); - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement -} - -fn nested_within_if_expr() { - if &let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - if !let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - if *let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR type `bool` cannot be dereferenced - //~| ERROR expected expression, found `let` statement - if -let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR cannot apply unary operator `-` to type `bool` - //~| ERROR expected expression, found `let` statement - - fn _check_try_binds_tighter() -> Result<(), ()> { - if let 0 = 0? {} - //~^ ERROR the `?` operator can only be applied to values that implement `Try` - Ok(()) - } - if (let 0 = 0)? {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR the `?` operator can only be applied to values that implement `Try` - //~| ERROR the `?` operator can only be used in a function that returns `Result` - //~| ERROR expected expression, found `let` statement - - if true || let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - if (true || let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - if true && (true || let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - if true || (true && let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - let mut x = true; - if x = let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - if true..(let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - if ..(let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - if (let 0 = 0).. {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - // Binds as `(let ... = true)..true &&/|| false`. - if let Range { start: _, end: _ } = true..true && false {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - if let Range { start: _, end: _ } = true..true || false {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - - // Binds as `(let Range { start: F, end } = F)..(|| true)`. - const F: fn() -> bool = || true; - if let Range { start: F, end } = F..|| true {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR mismatched types - - // Binds as `(let Range { start: true, end } = t)..(&&false)`. - let t = &&true; - if let Range { start: true, end } = t..&&false {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR mismatched types - - if let true = let true = true {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement -} - -fn nested_within_while_expr() { - while &let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - while !let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - while *let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR type `bool` cannot be dereferenced - //~| ERROR expected expression, found `let` statement - while -let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR cannot apply unary operator `-` to type `bool` - //~| ERROR expected expression, found `let` statement - - fn _check_try_binds_tighter() -> Result<(), ()> { - while let 0 = 0? {} - //~^ ERROR the `?` operator can only be applied to values that implement `Try` - Ok(()) - } - while (let 0 = 0)? {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR the `?` operator can only be applied to values that implement `Try` - //~| ERROR the `?` operator can only be used in a function that returns `Result` - //~| ERROR expected expression, found `let` statement - - while true || let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - while (true || let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - while true && (true || let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - while true || (true && let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - let mut x = true; - while x = let 0 = 0 {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - while true..(let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - while ..(let 0 = 0) {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - while (let 0 = 0).. {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - // Binds as `(let ... = true)..true &&/|| false`. - while let Range { start: _, end: _ } = true..true && false {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - while let Range { start: _, end: _ } = true..true || false {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - - // Binds as `(let Range { start: F, end } = F)..(|| true)`. - const F: fn() -> bool = || true; - while let Range { start: F, end } = F..|| true {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR mismatched types - - // Binds as `(let Range { start: true, end } = t)..(&&false)`. - let t = &&true; - while let Range { start: true, end } = t..&&false {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR mismatched types - - while let true = let true = true {} - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement -} - -fn not_error_because_clarified_intent() { - if let Range { start: _, end: _ } = (true..true || false) { } - - if let Range { start: _, end: _ } = (true..true && false) { } - - while let Range { start: _, end: _ } = (true..true || false) { } - - while let Range { start: _, end: _ } = (true..true && false) { } -} - -fn outside_if_and_while_expr() { - &let 0 = 0; - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - !let 0 = 0; - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - *let 0 = 0; - //~^ ERROR `let` expressions are not supported here - //~| ERROR type `bool` cannot be dereferenced - //~| ERROR expected expression, found `let` statement - -let 0 = 0; - //~^ ERROR `let` expressions are not supported here - //~| ERROR cannot apply unary operator `-` to type `bool` - //~| ERROR expected expression, found `let` statement - - fn _check_try_binds_tighter() -> Result<(), ()> { - let 0 = 0?; - //~^ ERROR the `?` operator can only be applied to values that implement `Try` - Ok(()) - } - (let 0 = 0)?; - //~^ ERROR `let` expressions are not supported here - //~| ERROR the `?` operator can only be used in a function that returns `Result` - //~| ERROR the `?` operator can only be applied to values that implement `Try` - //~| ERROR expected expression, found `let` statement - - true || let 0 = 0; - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - (true || let 0 = 0); - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - true && (true || let 0 = 0); - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - let mut x = true; - x = let 0 = 0; - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - true..(let 0 = 0); - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - ..(let 0 = 0); - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - (let 0 = 0)..; - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - - (let Range { start: _, end: _ } = true..true || false); - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - - (let true = let true = true); - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - - { - #[cfg(FALSE)] - let x = true && let y = 1; - //~^ ERROR expected expression, found `let` statement - } - - #[cfg(FALSE)] - { - [1, 2, 3][let _ = ()] - //~^ ERROR expected expression, found `let` statement - } - - // Check function tail position. - &let 0 = 0 - //~^ ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement -} - -// Let's make sure that `let` inside const generic arguments are considered. -fn inside_const_generic_arguments() { - struct A; - impl A<{B}> { const O: u32 = 5; } - - if let A::<{ - true && let 1 = 1 - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - }>::O = 5 {} - - while let A::<{ - true && let 1 = 1 - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - }>::O = 5 {} - - if A::<{ - true && let 1 = 1 - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - }>::O == 5 {} - - // In the cases above we have `ExprKind::Block` to help us out. - // Below however, we would not have a block and so an implementation might go - // from visiting expressions to types without banning `let` expressions down the tree. - // This tests ensures that we are not caught by surprise should the parser - // admit non-IDENT expressions in const generic arguments. - - if A::< - true && let 1 = 1 - //~^ ERROR `let` expressions are not supported here - //~| ERROR expressions must be enclosed in braces - //~| ERROR expected expression, found `let` statement - >::O == 5 {} -} - -fn with_parenthesis() { - let opt = Some(Some(1i32)); - - if (let Some(a) = opt && true) { - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - } - - if (let Some(a) = opt) && true { - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - } - if (let Some(a) = opt) && (let Some(b) = a) { - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - } - if let Some(a) = opt && (true && true) { - } - - if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - } - if (let Some(a) = opt && (let Some(b) = a)) && true { - //~^ ERROR `let` expressions are not supported here - //~| ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - } - if (let Some(a) = opt && (true)) && true { - //~^ ERROR `let` expressions are not supported here - //~| ERROR expected expression, found `let` statement - } - - if (true && (true)) && let Some(a) = opt { - } - if (true) && let Some(a) = opt { - } - if true && let Some(a) = opt { - } - - let fun = || true; - if let true = (true && fun()) && (true) { - } - - #[cfg(FALSE)] - let x = (true && let y = 1); - //~^ ERROR expected expression, found `let` statement - - #[cfg(FALSE)] - { - ([1, 2, 3][let _ = ()]) - //~^ ERROR expected expression, found `let` statement - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/tests/ui/rfc-2497-if-let-chains/disallowed-positions.stderr deleted file mode 100644 index 81933173c..000000000 --- a/tests/ui/rfc-2497-if-let-chains/disallowed-positions.stderr +++ /dev/null @@ -1,1911 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:29:9 - | -LL | if (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:33:11 - | -LL | if (((let 0 = 1))) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:37:9 - | -LL | if (let 0 = 1) && true {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:41:17 - | -LL | if true && (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:9 - | -LL | if (let 0 = 1) && (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:24 - | -LL | if (let 0 = 1) && (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:51:35 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:51:48 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:51:61 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:61:12 - | -LL | while (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:65:14 - | -LL | while (((let 0 = 1))) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:69:12 - | -LL | while (let 0 = 1) && true {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:73:20 - | -LL | while true && (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:77:12 - | -LL | while (let 0 = 1) && (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:77:27 - | -LL | while (let 0 = 1) && (let 0 = 1) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:83:38 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:83:51 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:83:64 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:110:9 - | -LL | if &let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:115:9 - | -LL | if !let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:118:9 - | -LL | if *let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:122:9 - | -LL | if -let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:132:9 - | -LL | if (let 0 = 0)? {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:138:16 - | -LL | if true || let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:141:17 - | -LL | if (true || let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:144:25 - | -LL | if true && (true || let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:147:25 - | -LL | if true || (true && let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:152:12 - | -LL | if x = let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:157:15 - | -LL | if true..(let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:161:11 - | -LL | if ..(let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:165:9 - | -LL | if (let 0 = 0).. {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:196:19 - | -LL | if let true = let true = true {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:202:12 - | -LL | while &let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:207:12 - | -LL | while !let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:210:12 - | -LL | while *let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:214:12 - | -LL | while -let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:224:12 - | -LL | while (let 0 = 0)? {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:230:19 - | -LL | while true || let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:233:20 - | -LL | while (true || let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:236:28 - | -LL | while true && (true || let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:239:28 - | -LL | while true || (true && let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:244:15 - | -LL | while x = let 0 = 0 {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:249:18 - | -LL | while true..(let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:253:14 - | -LL | while ..(let 0 = 0) {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:257:12 - | -LL | while (let 0 = 0).. {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:288:22 - | -LL | while let true = let true = true {} - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:304:6 - | -LL | &let 0 = 0; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:308:6 - | -LL | !let 0 = 0; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:311:6 - | -LL | *let 0 = 0; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:315:6 - | -LL | -let 0 = 0; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:325:6 - | -LL | (let 0 = 0)?; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:331:13 - | -LL | true || let 0 = 0; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:334:14 - | -LL | (true || let 0 = 0); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:337:22 - | -LL | true && (true || let 0 = 0); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:342:9 - | -LL | x = let 0 = 0; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:346:12 - | -LL | true..(let 0 = 0); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:349:8 - | -LL | ..(let 0 = 0); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:352:6 - | -LL | (let 0 = 0)..; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:356:6 - | -LL | (let Range { start: _, end: _ } = true..true || false); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:361:6 - | -LL | (let true = let true = true); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:361:17 - | -LL | (let true = let true = true); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:368:25 - | -LL | let x = true && let y = 1; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:374:19 - | -LL | [1, 2, 3][let _ = ()] - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:379:6 - | -LL | &let 0 = 0 - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:391:17 - | -LL | true && let 1 = 1 - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:397:17 - | -LL | true && let 1 = 1 - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:403:17 - | -LL | true && let 1 = 1 - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:415:17 - | -LL | true && let 1 = 1 - | ^^^ - -error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/disallowed-positions.rs:415:9 - | -LL | true && let 1 = 1 - | ^^^^^^^^^^^^^^^^^ - | -help: enclose the `const` expression in braces - | -LL | { true && let 1 = 1 } - | + + - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:425:9 - | -LL | if (let Some(a) = opt && true) { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:430:9 - | -LL | if (let Some(a) = opt) && true { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:434:9 - | -LL | if (let Some(a) = opt) && (let Some(b) = a) { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:434:32 - | -LL | if (let Some(a) = opt) && (let Some(b) = a) { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:443:9 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:443:31 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:449:9 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && true { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:449:31 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && true { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:455:9 - | -LL | if (let Some(a) = opt && (true)) && true { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:472:22 - | -LL | let x = (true && let y = 1); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:477:20 - | -LL | ([1, 2, 3][let _ = ()]) - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:99:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:103:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:29:9 - | -LL | if (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:29:9 - | -LL | if (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:33:11 - | -LL | if (((let 0 = 1))) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:33:11 - | -LL | if (((let 0 = 1))) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:37:9 - | -LL | if (let 0 = 1) && true {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:37:9 - | -LL | if (let 0 = 1) && true {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:41:17 - | -LL | if true && (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:41:17 - | -LL | if true && (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:45:9 - | -LL | if (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:9 - | -LL | if (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:45:24 - | -LL | if (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:24 - | -LL | if (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:51:35 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:51:35 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:51:48 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:51:35 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:51:61 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:51:35 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:61:12 - | -LL | while (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:61:12 - | -LL | while (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:65:14 - | -LL | while (((let 0 = 1))) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:65:14 - | -LL | while (((let 0 = 1))) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:69:12 - | -LL | while (let 0 = 1) && true {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:69:12 - | -LL | while (let 0 = 1) && true {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:73:20 - | -LL | while true && (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:73:20 - | -LL | while true && (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:77:12 - | -LL | while (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:77:12 - | -LL | while (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:77:27 - | -LL | while (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:77:27 - | -LL | while (let 0 = 1) && (let 0 = 1) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:83:38 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:83:38 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:83:51 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:83:38 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:83:64 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:83:38 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:99:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:99:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:99:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:99:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:103:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:103:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:103:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:103:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:110:9 - | -LL | if &let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:115:9 - | -LL | if !let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:118:9 - | -LL | if *let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:122:9 - | -LL | if -let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:132:9 - | -LL | if (let 0 = 0)? {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:132:9 - | -LL | if (let 0 = 0)? {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:138:16 - | -LL | if true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:138:13 - | -LL | if true || let 0 = 0 {} - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:141:17 - | -LL | if (true || let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:141:14 - | -LL | if (true || let 0 = 0) {} - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:144:25 - | -LL | if true && (true || let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:144:22 - | -LL | if true && (true || let 0 = 0) {} - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:147:25 - | -LL | if true || (true && let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:147:17 - | -LL | if true || (true && let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:152:12 - | -LL | if x = let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:157:15 - | -LL | if true..(let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:157:15 - | -LL | if true..(let 0 = 0) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:161:11 - | -LL | if ..(let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:161:11 - | -LL | if ..(let 0 = 0) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:165:9 - | -LL | if (let 0 = 0).. {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:165:9 - | -LL | if (let 0 = 0).. {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:171:8 - | -LL | if let Range { start: _, end: _ } = true..true && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:175:8 - | -LL | if let Range { start: _, end: _ } = true..true || false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:182:8 - | -LL | if let Range { start: F, end } = F..|| true {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:190:8 - | -LL | if let Range { start: true, end } = t..&&false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:196:19 - | -LL | if let true = let true = true {} - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:202:12 - | -LL | while &let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:207:12 - | -LL | while !let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:210:12 - | -LL | while *let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:214:12 - | -LL | while -let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:224:12 - | -LL | while (let 0 = 0)? {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:224:12 - | -LL | while (let 0 = 0)? {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:230:19 - | -LL | while true || let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:230:16 - | -LL | while true || let 0 = 0 {} - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:233:20 - | -LL | while (true || let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:233:17 - | -LL | while (true || let 0 = 0) {} - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:236:28 - | -LL | while true && (true || let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:236:25 - | -LL | while true && (true || let 0 = 0) {} - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:239:28 - | -LL | while true || (true && let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:239:20 - | -LL | while true || (true && let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:244:15 - | -LL | while x = let 0 = 0 {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:249:18 - | -LL | while true..(let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:249:18 - | -LL | while true..(let 0 = 0) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:253:14 - | -LL | while ..(let 0 = 0) {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:253:14 - | -LL | while ..(let 0 = 0) {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:257:12 - | -LL | while (let 0 = 0).. {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:257:12 - | -LL | while (let 0 = 0).. {} - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:263:11 - | -LL | while let Range { start: _, end: _ } = true..true && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:267:11 - | -LL | while let Range { start: _, end: _ } = true..true || false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:274:11 - | -LL | while let Range { start: F, end } = F..|| true {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:282:11 - | -LL | while let Range { start: true, end } = t..&&false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:288:22 - | -LL | while let true = let true = true {} - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:304:6 - | -LL | &let 0 = 0; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:308:6 - | -LL | !let 0 = 0; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:311:6 - | -LL | *let 0 = 0; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:315:6 - | -LL | -let 0 = 0; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:325:6 - | -LL | (let 0 = 0)?; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:325:6 - | -LL | (let 0 = 0)?; - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:331:13 - | -LL | true || let 0 = 0; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:331:10 - | -LL | true || let 0 = 0; - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:334:14 - | -LL | (true || let 0 = 0); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:334:11 - | -LL | (true || let 0 = 0); - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:337:22 - | -LL | true && (true || let 0 = 0); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `||` operators are not supported in let chain expressions - --> $DIR/disallowed-positions.rs:337:19 - | -LL | true && (true || let 0 = 0); - | ^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:342:9 - | -LL | x = let 0 = 0; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:346:12 - | -LL | true..(let 0 = 0); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:346:12 - | -LL | true..(let 0 = 0); - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:349:8 - | -LL | ..(let 0 = 0); - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:349:8 - | -LL | ..(let 0 = 0); - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:352:6 - | -LL | (let 0 = 0)..; - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:352:6 - | -LL | (let 0 = 0)..; - | ^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:356:6 - | -LL | (let Range { start: _, end: _ } = true..true || false); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:361:6 - | -LL | (let true = let true = true); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:361:6 - | -LL | (let true = let true = true); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:379:6 - | -LL | &let 0 = 0 - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:391:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:397:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:403:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:415:17 - | -LL | true && let 1 = 1 - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:425:9 - | -LL | if (let Some(a) = opt && true) { - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:425:9 - | -LL | if (let Some(a) = opt && true) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:430:9 - | -LL | if (let Some(a) = opt) && true { - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:430:9 - | -LL | if (let Some(a) = opt) && true { - | ^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:434:9 - | -LL | if (let Some(a) = opt) && (let Some(b) = a) { - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:434:9 - | -LL | if (let Some(a) = opt) && (let Some(b) = a) { - | ^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:434:32 - | -LL | if (let Some(a) = opt) && (let Some(b) = a) { - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:434:32 - | -LL | if (let Some(a) = opt) && (let Some(b) = a) { - | ^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:443:9 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:443:9 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:443:31 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:443:31 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { - | ^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:449:9 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && true { - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:449:9 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && true { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:449:31 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && true { - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:449:31 - | -LL | if (let Some(a) = opt && (let Some(b) = a)) && true { - | ^^^^^^^^^^^^^^^ - -error: `let` expressions are not supported here - --> $DIR/disallowed-positions.rs:455:9 - | -LL | if (let Some(a) = opt && (true)) && true { - | ^^^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:455:9 - | -LL | if (let Some(a) = opt && (true)) && true { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:110:8 - | -LL | if &let 0 = 0 {} - | ^^^^^^^^^^ expected `bool`, found `&bool` - | -help: consider removing the borrow - | -LL - if &let 0 = 0 {} -LL + if let 0 = 0 {} - | - -error[E0614]: type `bool` cannot be dereferenced - --> $DIR/disallowed-positions.rs:118:8 - | -LL | if *let 0 = 0 {} - | ^^^^^^^^^^ - -error[E0600]: cannot apply unary operator `-` to type `bool` - --> $DIR/disallowed-positions.rs:122:8 - | -LL | if -let 0 = 0 {} - | ^^^^^^^^^^ cannot apply unary operator `-` - -error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:132:8 - | -LL | if (let 0 = 0)? {} - | ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool` - | - = help: the trait `Try` is not implemented for `bool` - -error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/disallowed-positions.rs:132:19 - | -LL | fn nested_within_if_expr() { - | -------------------------- this function should return `Result` or `Option` to accept `?` -... -LL | if (let 0 = 0)? {} - | ^ cannot use the `?` operator in a function that returns `()` - | - = help: the trait `FromResidual<_>` is not implemented for `()` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:152:8 - | -LL | if x = let 0 = 0 {} - | ^^^^^^^^^^^^^ expected `bool`, found `()` - | -help: you might have meant to compare for equality - | -LL | if x == let 0 = 0 {} - | + - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:157:8 - | -LL | if true..(let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:161:8 - | -LL | if ..(let 0 = 0) {} - | ^^^^^^^^^^^^^ expected `bool`, found `RangeTo` - | - = note: expected type `bool` - found struct `RangeTo` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:165:8 - | -LL | if (let 0 = 0).. {} - | ^^^^^^^^^^^^^ expected `bool`, found `RangeFrom` - | - = note: expected type `bool` - found struct `RangeFrom` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:171:12 - | -LL | if let Range { start: _, end: _ } = true..true && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:171:8 - | -LL | if let Range { start: _, end: _ } = true..true && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:175:12 - | -LL | if let Range { start: _, end: _ } = true..true || false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:175:8 - | -LL | if let Range { start: _, end: _ } = true..true || false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:182:12 - | -LL | if let Range { start: F, end } = F..|| true {} - | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` - | | - | expected fn pointer, found `Range<_>` - | - = note: expected fn pointer `fn() -> bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:182:41 - | -LL | if let Range { start: F, end } = F..|| true {} - | ^^^^^^^ expected `bool`, found closure - | - = note: expected type `bool` - found closure `[closure@$DIR/disallowed-positions.rs:182:41: 182:43]` -help: use parentheses to call this closure - | -LL | if let Range { start: F, end } = F..(|| true)() {} - | + +++ - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:182:8 - | -LL | if let Range { start: F, end } = F..|| true {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:190:12 - | -LL | if let Range { start: true, end } = t..&&false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:190:44 - | -LL | if let Range { start: true, end } = t..&&false {} - | ^^^^^^^ expected `bool`, found `&&bool` - | -help: consider removing the `&&` - | -LL - if let Range { start: true, end } = t..&&false {} -LL + if let Range { start: true, end } = t..false {} - | - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:190:8 - | -LL | if let Range { start: true, end } = t..&&false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:128:20 - | -LL | if let 0 = 0? {} - | ^^ the `?` operator cannot be applied to type `{integer}` - | - = help: the trait `Try` is not implemented for `{integer}` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:202:11 - | -LL | while &let 0 = 0 {} - | ^^^^^^^^^^ expected `bool`, found `&bool` - | -help: consider removing the borrow - | -LL - while &let 0 = 0 {} -LL + while let 0 = 0 {} - | - -error[E0614]: type `bool` cannot be dereferenced - --> $DIR/disallowed-positions.rs:210:11 - | -LL | while *let 0 = 0 {} - | ^^^^^^^^^^ - -error[E0600]: cannot apply unary operator `-` to type `bool` - --> $DIR/disallowed-positions.rs:214:11 - | -LL | while -let 0 = 0 {} - | ^^^^^^^^^^ cannot apply unary operator `-` - -error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:224:11 - | -LL | while (let 0 = 0)? {} - | ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool` - | - = help: the trait `Try` is not implemented for `bool` - -error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/disallowed-positions.rs:224:22 - | -LL | fn nested_within_while_expr() { - | ----------------------------- this function should return `Result` or `Option` to accept `?` -... -LL | while (let 0 = 0)? {} - | ^ cannot use the `?` operator in a function that returns `()` - | - = help: the trait `FromResidual<_>` is not implemented for `()` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:244:11 - | -LL | while x = let 0 = 0 {} - | ^^^^^^^^^^^^^ expected `bool`, found `()` - | -help: you might have meant to compare for equality - | -LL | while x == let 0 = 0 {} - | + - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:249:11 - | -LL | while true..(let 0 = 0) {} - | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:253:11 - | -LL | while ..(let 0 = 0) {} - | ^^^^^^^^^^^^^ expected `bool`, found `RangeTo` - | - = note: expected type `bool` - found struct `RangeTo` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:257:11 - | -LL | while (let 0 = 0).. {} - | ^^^^^^^^^^^^^ expected `bool`, found `RangeFrom` - | - = note: expected type `bool` - found struct `RangeFrom` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:263:15 - | -LL | while let Range { start: _, end: _ } = true..true && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:263:11 - | -LL | while let Range { start: _, end: _ } = true..true && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:267:15 - | -LL | while let Range { start: _, end: _ } = true..true || false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:267:11 - | -LL | while let Range { start: _, end: _ } = true..true || false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:274:15 - | -LL | while let Range { start: F, end } = F..|| true {} - | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` - | | - | expected fn pointer, found `Range<_>` - | - = note: expected fn pointer `fn() -> bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:274:44 - | -LL | while let Range { start: F, end } = F..|| true {} - | ^^^^^^^ expected `bool`, found closure - | - = note: expected type `bool` - found closure `[closure@$DIR/disallowed-positions.rs:274:44: 274:46]` -help: use parentheses to call this closure - | -LL | while let Range { start: F, end } = F..(|| true)() {} - | + +++ - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:274:11 - | -LL | while let Range { start: F, end } = F..|| true {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:282:15 - | -LL | while let Range { start: true, end } = t..&&false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:282:47 - | -LL | while let Range { start: true, end } = t..&&false {} - | ^^^^^^^ expected `bool`, found `&&bool` - | -help: consider removing the `&&` - | -LL - while let Range { start: true, end } = t..&&false {} -LL + while let Range { start: true, end } = t..false {} - | - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:282:11 - | -LL | while let Range { start: true, end } = t..&&false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` - | - = note: expected type `bool` - found struct `std::ops::Range` - -error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:220:23 - | -LL | while let 0 = 0? {} - | ^^ the `?` operator cannot be applied to type `{integer}` - | - = help: the trait `Try` is not implemented for `{integer}` - -error[E0614]: type `bool` cannot be dereferenced - --> $DIR/disallowed-positions.rs:311:5 - | -LL | *let 0 = 0; - | ^^^^^^^^^^ - -error[E0600]: cannot apply unary operator `-` to type `bool` - --> $DIR/disallowed-positions.rs:315:5 - | -LL | -let 0 = 0; - | ^^^^^^^^^^ cannot apply unary operator `-` - -error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:325:5 - | -LL | (let 0 = 0)?; - | ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool` - | - = help: the trait `Try` is not implemented for `bool` - -error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) - --> $DIR/disallowed-positions.rs:325:16 - | -LL | fn outside_if_and_while_expr() { - | ------------------------------ this function should return `Result` or `Option` to accept `?` -... -LL | (let 0 = 0)?; - | ^ cannot use the `?` operator in a function that returns `()` - | - = help: the trait `FromResidual<_>` is not implemented for `()` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:356:10 - | -LL | (let Range { start: _, end: _ } = true..true || false); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` - | | - | expected `bool`, found `Range<_>` - | - = note: expected type `bool` - found struct `std::ops::Range<_>` - -error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:379:5 - | -LL | fn outside_if_and_while_expr() { - | - help: try adding a return type: `-> &bool` -... -LL | &let 0 = 0 - | ^^^^^^^^^^ expected `()`, found `&bool` - -error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:321:17 - | -LL | let 0 = 0?; - | ^^ the `?` operator cannot be applied to type `{integer}` - | - = help: the trait `Try` is not implemented for `{integer}` - -error: aborting due to 215 previous errors - -Some errors have detailed explanations: E0277, E0308, E0600, E0614. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs b/tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs deleted file mode 100644 index 2a6c14435..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs +++ /dev/null @@ -1,55 +0,0 @@ -#![feature(let_chains)] - -fn main() { - let opt = Some(1i32); - - let Some(n) = opt else { - return; - }; - let Some(n) = opt && n == 1 else { - //~^ ERROR a `&&` expression cannot be directly assigned in `let...else` - //~| ERROR mismatched types - //~| ERROR mismatched types - return; - }; - let Some(n) = opt && let another = n else { - //~^ ERROR a `&&` expression cannot be directly assigned in `let...else` - //~| ERROR `let` expressions are not supported here - //~| ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR expected expression, found `let` statement - return; - }; - - if let Some(n) = opt else { - //~^ ERROR this `if` expression is missing a block after the condition - return; - }; - if let Some(n) = opt && n == 1 else { - //~^ ERROR this `if` expression is missing a block after the condition - return; - }; - if let Some(n) = opt && let another = n else { - //~^ ERROR this `if` expression is missing a block after the condition - return; - }; - - { - while let Some(n) = opt else { - //~^ ERROR expected `{`, found keyword `else` - return; - }; - } - { - while let Some(n) = opt && n == 1 else { - //~^ ERROR expected `{`, found keyword `else` - return; - }; - } - { - while let Some(n) = opt && let another = n else { - //~^ ERROR expected `{`, found keyword `else` - return; - }; - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr b/tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr deleted file mode 100644 index 9bc3e7541..000000000 --- a/tests/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr +++ /dev/null @@ -1,147 +0,0 @@ -error: a `&&` expression cannot be directly assigned in `let...else` - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:19 - | -LL | let Some(n) = opt && n == 1 else { - | ^^^^^^^^^^^^^ - | -help: wrap the expression in parentheses - | -LL | let Some(n) = (opt && n == 1) else { - | + + - -error: expected expression, found `let` statement - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:26 - | -LL | let Some(n) = opt && let another = n else { - | ^^^ - -error: a `&&` expression cannot be directly assigned in `let...else` - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:19 - | -LL | let Some(n) = opt && let another = n else { - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: wrap the expression in parentheses - | -LL | let Some(n) = (opt && let another = n) else { - | + + - -error: this `if` expression is missing a block after the condition - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:24:5 - | -LL | if let Some(n) = opt else { - | ^^ - | -help: add a block here - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:24:25 - | -LL | if let Some(n) = opt else { - | ^ -help: remove the `if` if you meant to write a `let...else` statement - | -LL - if let Some(n) = opt else { -LL + let Some(n) = opt else { - | - -error: this `if` expression is missing a block after the condition - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:28:5 - | -LL | if let Some(n) = opt && n == 1 else { - | ^^ - | -help: add a block here - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:28:35 - | -LL | if let Some(n) = opt && n == 1 else { - | ^ - -error: this `if` expression is missing a block after the condition - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:32:5 - | -LL | if let Some(n) = opt && let another = n else { - | ^^ - | -help: add a block here - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:32:44 - | -LL | if let Some(n) = opt && let another = n else { - | ^ - -error: expected `{`, found keyword `else` - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:38:33 - | -LL | while let Some(n) = opt else { - | ----- ----------------- ^^^^ expected `{` - | | | - | | this `while` condition successfully parsed - | while parsing the body of this `while` expression - -error: expected `{`, found keyword `else` - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:44:43 - | -LL | while let Some(n) = opt && n == 1 else { - | ----- --------------------------- ^^^^ expected `{` - | | | - | | this `while` condition successfully parsed - | while parsing the body of this `while` expression - -error: expected `{`, found keyword `else` - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:50:52 - | -LL | while let Some(n) = opt && let another = n else { - | ----- ------------------------------------ ^^^^ expected `{` - | | | - | | this `while` condition successfully parsed - | while parsing the body of this `while` expression - -error: `let` expressions are not supported here - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:26 - | -LL | let Some(n) = opt && let another = n else { - | ^^^^^^^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error[E0308]: mismatched types - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:19 - | -LL | let Some(n) = opt && n == 1 else { - | ^^^ expected `bool`, found `Option` - | - = note: expected type `bool` - found enum `Option` - -error[E0308]: mismatched types - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:9 - | -LL | let Some(n) = opt && n == 1 else { - | ^^^^^^^ ------------- this expression has type `bool` - | | - | expected `bool`, found `Option<_>` - | - = note: expected type `bool` - found enum `Option<_>` - -error[E0308]: mismatched types - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:19 - | -LL | let Some(n) = opt && let another = n else { - | ^^^ expected `bool`, found `Option` - | - = note: expected type `bool` - found enum `Option` - -error[E0308]: mismatched types - --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:9 - | -LL | let Some(n) = opt && let another = n else { - | ^^^^^^^ ---------------------- this expression has type `bool` - | | - | expected `bool`, found `Option<_>` - | - = note: expected type `bool` - found enum `Option<_>` - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfc-2497-if-let-chains/feature-gate.rs b/tests/ui/rfc-2497-if-let-chains/feature-gate.rs deleted file mode 100644 index 2b407ef51..000000000 --- a/tests/ui/rfc-2497-if-let-chains/feature-gate.rs +++ /dev/null @@ -1,62 +0,0 @@ -// gate-test-let_chains - -// Here we test feature gating for ´let_chains`. -// See `disallowed-positions.rs` for the grammar -// defining the language for gated allowed positions. - -#![allow(irrefutable_let_patterns)] - -use std::ops::Range; - -fn _if() { - if let 0 = 1 {} // Stable! - - if true && let 0 = 1 {} - //~^ ERROR `let` expressions in this position are unstable [E0658] - - if let 0 = 1 && true {} - //~^ ERROR `let` expressions in this position are unstable [E0658] - - if let Range { start: _, end: _ } = (true..true) && false {} - //~^ ERROR `let` expressions in this position are unstable [E0658] - - if let 1 = 1 && let true = { true } && false { - //~^ ERROR `let` expressions in this position are unstable [E0658] - //~| ERROR `let` expressions in this position are unstable [E0658] - } -} - -fn _while() { - while let 0 = 1 {} // Stable! - - while true && let 0 = 1 {} - //~^ ERROR `let` expressions in this position are unstable [E0658] - - while let 0 = 1 && true {} - //~^ ERROR `let` expressions in this position are unstable [E0658] - - while let Range { start: _, end: _ } = (true..true) && false {} - //~^ ERROR `let` expressions in this position are unstable [E0658] -} - -fn _macros() { - macro_rules! noop_expr { ($e:expr) => {}; } - - noop_expr!((let 0 = 1)); - //~^ ERROR `let` expressions in this position are unstable [E0658] - //~| ERROR expected expression, found `let` statement - - macro_rules! use_expr { - ($e:expr) => { - if $e {} - while $e {} - } - } - #[cfg(FALSE)] (let 0 = 1); - //~^ ERROR `let` expressions in this position are unstable [E0658] - //~| ERROR expected expression, found `let` statement - use_expr!(let 0 = 1); - //~^ ERROR no rules expected the token `let` -} - -fn main() {} diff --git a/tests/ui/rfc-2497-if-let-chains/feature-gate.stderr b/tests/ui/rfc-2497-if-let-chains/feature-gate.stderr deleted file mode 100644 index 7a43b71fc..000000000 --- a/tests/ui/rfc-2497-if-let-chains/feature-gate.stderr +++ /dev/null @@ -1,120 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:55:20 - | -LL | #[cfg(FALSE)] (let 0 = 1); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:45:17 - | -LL | noop_expr!((let 0 = 1)); - | ^^^ - -error: no rules expected the token `let` - --> $DIR/feature-gate.rs:58:15 - | -LL | macro_rules! use_expr { - | --------------------- when calling this macro -... -LL | use_expr!(let 0 = 1); - | ^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr` - --> $DIR/feature-gate.rs:50:10 - | -LL | ($e:expr) => { - | ^^^^^^^ - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:14:16 - | -LL | if true && let 0 = 1 {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:17:8 - | -LL | if let 0 = 1 && true {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:20:8 - | -LL | if let Range { start: _, end: _ } = (true..true) && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:23:8 - | -LL | if let 1 = 1 && let true = { true } && false { - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:23:21 - | -LL | if let 1 = 1 && let true = { true } && false { - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:32:19 - | -LL | while true && let 0 = 1 {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:35:11 - | -LL | while let 0 = 1 && true {} - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:38:11 - | -LL | while let Range { start: _, end: _ } = (true..true) && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:55:20 - | -LL | #[cfg(FALSE)] (let 0 = 1); - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:45:17 - | -LL | noop_expr!((let 0 = 1)); - | ^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error: aborting due to 13 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs b/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs deleted file mode 100644 index a942d1f4c..000000000 --- a/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![feature(let_chains)] - -fn main() { - let _opt = Some(1i32); - - #[cfg(FALSE)] - { - let _ = &&let Some(x) = Some(42); - //~^ ERROR expected expression, found `let` statement - } - #[cfg(FALSE)] - { - if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 { - //~^ ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - true - } - } - - #[cfg(FALSE)] - { - if let Some(elem) = _opt && { - [1, 2, 3][let _ = ()]; - //~^ ERROR expected expression, found `let` statement - true - } { - } - } - - #[cfg(FALSE)] - { - if let Some(elem) = _opt && [1, 2, 3][let _ = ()] = 1 { - //~^ ERROR expected expression, found `let` statement - true - } - } - #[cfg(FALSE)] - { - if let a = 1 && { - let x = let y = 1; - //~^ ERROR expected expression, found `let` statement - } { - } - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr b/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr deleted file mode 100644 index d1ce83c72..000000000 --- a/tests/ui/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/invalid-let-in-a-valid-let-context.rs:8:19 - | -LL | let _ = &&let Some(x) = Some(42); - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/invalid-let-in-a-valid-let-context.rs:13:47 - | -LL | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/invalid-let-in-a-valid-let-context.rs:13:57 - | -LL | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/invalid-let-in-a-valid-let-context.rs:23:23 - | -LL | [1, 2, 3][let _ = ()]; - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/invalid-let-in-a-valid-let-context.rs:32:47 - | -LL | if let Some(elem) = _opt && [1, 2, 3][let _ = ()] = 1 { - | ^^^ - -error: expected expression, found `let` statement - --> $DIR/invalid-let-in-a-valid-let-context.rs:40:21 - | -LL | let x = let y = 1; - | ^^^ - -error: aborting due to 6 previous errors - diff --git a/tests/ui/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr b/tests/ui/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr deleted file mode 100644 index be4a52315..000000000 --- a/tests/ui/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr +++ /dev/null @@ -1,115 +0,0 @@ -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:13:8 - | -LL | if let first = &opt && let Some(ref second) = first && let None = second.start {} - | ^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct -note: the lint level is defined here - --> $DIR/irrefutable-lets.rs:6:30 - | -LL | #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: irrefutable `if let` patterns - --> $DIR/irrefutable-lets.rs:19:8 - | -LL | if let first = &opt && let (a, b) = (1, 2) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match, so the `if let` is useless - = help: consider replacing the `if let` with a `let` - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:22:8 - | -LL | if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} - | ^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:22:87 - | -LL | if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} - | ^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it into the body - -error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:26:37 - | -LL | if let Some(ref first) = opt && let second = first && let _third = second {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match - = help: consider moving them into the body - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:29:8 - | -LL | if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:32:8 - | -LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:35:8 - | -LL | if let first = &opt && let None = Some(1) {} - | ^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match - = help: consider moving it outside of the construct - -error: irrefutable `if let` guard patterns - --> $DIR/irrefutable-lets.rs:44:28 - | -LL | Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match, so the guard is useless - = help: consider removing the guard and adding a `let` inside the match arm - -error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:59:16 - | -LL | && let v = local_end && let w = v => {}, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match - = help: consider moving them into the body - -error: irrefutable `while let` patterns - --> $DIR/irrefutable-lets.rs:68:11 - | -LL | while let first = &opt && let (a, b) = (1, 2) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match, so the loop will never exit - = help: consider instead using a `loop { ... }` with a `let` inside it - -error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:71:40 - | -LL | while let Some(ref first) = opt && let second = first && let _third = second {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: these patterns will always match - = help: consider moving them into the body - -error: aborting due to 12 previous errors - diff --git a/tests/ui/rfc-2497-if-let-chains/irrefutable-lets.rs b/tests/ui/rfc-2497-if-let-chains/irrefutable-lets.rs deleted file mode 100644 index 9afb6853b..000000000 --- a/tests/ui/rfc-2497-if-let-chains/irrefutable-lets.rs +++ /dev/null @@ -1,78 +0,0 @@ -// revisions: allowed disallowed -//[allowed] check-pass - -#![feature(if_let_guard, let_chains)] -#![cfg_attr(allowed, allow(irrefutable_let_patterns))] -#![cfg_attr(disallowed, deny(irrefutable_let_patterns))] - -use std::ops::Range; - -fn main() { - let opt = Some(None..Some(1)); - - if let first = &opt && let Some(ref second) = first && let None = second.start {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain - - // No lint as the irrefutable pattern is surrounded by other stuff - if 4 * 2 == 0 && let first = &opt && let Some(ref second) = first && let None = second.start {} - - if let first = &opt && let (a, b) = (1, 2) {} - //[disallowed]~^ ERROR irrefutable `if let` patterns - - if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain - //[disallowed]~^^ ERROR trailing irrefutable pattern in let chain - - if let Some(ref first) = opt && let second = first && let _third = second {} - //[disallowed]~^ ERROR trailing irrefutable patterns in let chain - - if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain - - if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain - - if let first = &opt && let None = Some(1) {} - //[disallowed]~^ ERROR leading irrefutable pattern in let chain - - if let Some(ref first) = opt - && let Range { start: local_start, end: _ } = first - && let None = local_start { - } - - match opt { - Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, - //[disallowed]~^ ERROR irrefutable `if let` guard patterns - _ => {} - } - - // No error about leading irrefutable patterns: the expr on the rhs might - // use the bindings created by the match. - match opt { - Some(ref first) if let Range { start: local_start, end: _ } = first - && let None = local_start => {}, - _ => {} - } - - match opt { - Some(ref first) if let Range { start: Some(_), end: local_end } = first - && let v = local_end && let w = v => {}, - //[disallowed]~^ ERROR trailing irrefutable patterns in let chain - _ => {} - } - - // No error, despite the prefix being irrefutable: moving out could change the behaviour, - // due to possible side effects of the operation. - while let first = &opt && let Some(ref second) = first && let None = second.start {} - - while let first = &opt && let (a, b) = (1, 2) {} - //[disallowed]~^ ERROR irrefutable `while let` patterns - - while let Some(ref first) = opt && let second = first && let _third = second {} - //[disallowed]~^ ERROR trailing irrefutable patterns in let chain - - while let Some(ref first) = opt - && let Range { start: local_start, end: _ } = first - && let None = local_start { - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/issue-88498.rs b/tests/ui/rfc-2497-if-let-chains/issue-88498.rs deleted file mode 100644 index 3eb8a9ad0..000000000 --- a/tests/ui/rfc-2497-if-let-chains/issue-88498.rs +++ /dev/null @@ -1,16 +0,0 @@ -// check-pass - -pub enum UnOp { - Not(Vec<()>), -} - -pub fn foo() { - if let Some(x) = None { - match x { - UnOp::Not(_) => {} - } - } -} - -fn main() { -} diff --git a/tests/ui/rfc-2497-if-let-chains/issue-90722.rs b/tests/ui/rfc-2497-if-let-chains/issue-90722.rs deleted file mode 100644 index 6b7d88356..000000000 --- a/tests/ui/rfc-2497-if-let-chains/issue-90722.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass - -#![feature(let_chains)] - -fn main() { - let x = Some(vec!["test"]); - - if let Some(v) = x && v.is_empty() { - println!("x == Some([])"); - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/issue-92145.rs b/tests/ui/rfc-2497-if-let-chains/issue-92145.rs deleted file mode 100644 index 7c7e31f4d..000000000 --- a/tests/ui/rfc-2497-if-let-chains/issue-92145.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass - -#![feature(let_chains)] - -fn main() { - let opt = Some("foo bar"); - - if true && let Some(x) = opt { - println!("{}", x); - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/issue-93150.rs b/tests/ui/rfc-2497-if-let-chains/issue-93150.rs deleted file mode 100644 index f90b9ab0d..000000000 --- a/tests/ui/rfc-2497-if-let-chains/issue-93150.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - match true { - _ if let true = true && true => {} - //~^ ERROR `if let` guards are - //~| ERROR `let` expressions in this - _ => {} - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/issue-93150.stderr b/tests/ui/rfc-2497-if-let-chains/issue-93150.stderr deleted file mode 100644 index b25f299a2..000000000 --- a/tests/ui/rfc-2497-if-let-chains/issue-93150.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0658]: `if let` guards are experimental - --> $DIR/issue-93150.rs:3:11 - | -LL | _ if let true = true && true => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/issue-93150.rs:3:14 - | -LL | _ if let true = true && true => {} - | ^^^^^^^^^^^^^^^ - | - = note: see issue #53667 for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2497-if-let-chains/issue-99938.rs b/tests/ui/rfc-2497-if-let-chains/issue-99938.rs deleted file mode 100644 index bd81ce0b1..000000000 --- a/tests/ui/rfc-2497-if-let-chains/issue-99938.rs +++ /dev/null @@ -1,31 +0,0 @@ -// compile-flags: -Zvalidate-mir -C opt-level=3 -// build-pass -#![feature(let_chains)] -struct TupleIter> { - inner: I, -} - -impl> Iterator for TupleIter { - type Item = (T, T, T); - - fn next(&mut self) -> Option { - let inner = &mut self.inner; - - if let Some(first) = inner.next() - && let Some(second) = inner.next() - && let Some(third) = inner.next() - { - Some((first, second, third)) - } else { - None - } - } -} - -fn main() { - let vec: Vec = Vec::new(); - let mut tup_iter = TupleIter { - inner: vec.into_iter(), - }; - tup_iter.next(); -} diff --git a/tests/ui/rfc-2497-if-let-chains/no-double-assigments.rs b/tests/ui/rfc-2497-if-let-chains/no-double-assigments.rs deleted file mode 100644 index 6b91c455e..000000000 --- a/tests/ui/rfc-2497-if-let-chains/no-double-assigments.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-pass - -fn main() { - loop { - // [1][0] should leave top scope - if true && [1][0] == 1 && true { - } - } -} diff --git a/tests/ui/rfc-2497-if-let-chains/protect-precedences.rs b/tests/ui/rfc-2497-if-let-chains/protect-precedences.rs deleted file mode 100644 index fcc09b159..000000000 --- a/tests/ui/rfc-2497-if-let-chains/protect-precedences.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass - -#![allow(irrefutable_let_patterns)] - -fn main() { - let x: bool; - // This should associate as: `(x = (true && false));`. - x = true && false; - assert!(!x); - - fn _f1() -> bool { - // Should associate as `(let _ = (return (true && false)))`. - if let _ = return true && false {}; - //~^ WARNING unreachable block in `if` - } - assert!(!_f1()); -} diff --git a/tests/ui/rfc-2497-if-let-chains/protect-precedences.stderr b/tests/ui/rfc-2497-if-let-chains/protect-precedences.stderr deleted file mode 100644 index 24b35a2ab..000000000 --- a/tests/ui/rfc-2497-if-let-chains/protect-precedences.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: unreachable block in `if` or `while` expression - --> $DIR/protect-precedences.rs:13:41 - | -LL | if let _ = return true && false {}; - | -------------------- ^^ unreachable block in `if` or `while` expression - | | - | any code following this expression is unreachable - | - = note: `#[warn(unreachable_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/rfc-2497-if-let-chains/then-else-blocks.rs b/tests/ui/rfc-2497-if-let-chains/then-else-blocks.rs deleted file mode 100644 index e061174f6..000000000 --- a/tests/ui/rfc-2497-if-let-chains/then-else-blocks.rs +++ /dev/null @@ -1,49 +0,0 @@ -// run-pass - -#![feature(if_let_guard, let_chains)] - -fn check_if_let(opt: Option>>, value: i32) -> bool { - if let Some(first) = opt - && let Some(second) = first - && let Some(third) = second - && third == value - { - true - } - else { - false - } -} - -fn check_let_guard(opt: Option>>, value: i32) -> bool { - match opt { - Some(first) if let Some(second) = first && let Some(third) = second && third == value => { - true - } - _ => { - false - } - } -} - -fn check_while_let(opt: Option>>, value: i32) -> bool { - while let Some(first) = opt - && let Some(second) = first - && let Some(third) = second - && third == value - { - return true; - } - false -} - -fn main() { - assert_eq!(check_if_let(Some(Some(Some(1))), 1), true); - assert_eq!(check_if_let(Some(Some(Some(1))), 9), false); - - assert_eq!(check_let_guard(Some(Some(Some(1))), 1), true); - assert_eq!(check_let_guard(Some(Some(Some(1))), 9), false); - - assert_eq!(check_while_let(Some(Some(Some(1))), 1), true); - assert_eq!(check_while_let(Some(Some(Some(1))), 9), false); -} diff --git a/tests/ui/rfc-2565-param-attrs/attr-without-param.rs b/tests/ui/rfc-2565-param-attrs/attr-without-param.rs deleted file mode 100644 index eeb2191ba..000000000 --- a/tests/ui/rfc-2565-param-attrs/attr-without-param.rs +++ /dev/null @@ -1,16 +0,0 @@ -#[cfg(FALSE)] -impl S { - fn f(#[attr]) {} //~ ERROR expected parameter name, found `)` -} - -#[cfg(FALSE)] -impl T for S { - fn f(#[attr]) {} //~ ERROR expected parameter name, found `)` -} - -#[cfg(FALSE)] -trait T { - fn f(#[attr]); //~ ERROR expected argument name, found `)` -} - -fn main() {} diff --git a/tests/ui/rfc-2565-param-attrs/attr-without-param.stderr b/tests/ui/rfc-2565-param-attrs/attr-without-param.stderr deleted file mode 100644 index 26dff4d4b..000000000 --- a/tests/ui/rfc-2565-param-attrs/attr-without-param.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: expected parameter name, found `)` - --> $DIR/attr-without-param.rs:3:17 - | -LL | fn f(#[attr]) {} - | ^ expected parameter name - -error: expected parameter name, found `)` - --> $DIR/attr-without-param.rs:8:17 - | -LL | fn f(#[attr]) {} - | ^ expected parameter name - -error: expected argument name, found `)` - --> $DIR/attr-without-param.rs:13:17 - | -LL | fn f(#[attr]); - | ^ expected argument name - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs b/tests/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs deleted file mode 100644 index b62cf3120..000000000 --- a/tests/ui/rfc-2565-param-attrs/auxiliary/ident-mac.rs +++ /dev/null @@ -1,11 +0,0 @@ -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn id(_: TokenStream, input: TokenStream) -> TokenStream { input } diff --git a/tests/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs b/tests/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs deleted file mode 100644 index 82c4120b4..000000000 --- a/tests/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs +++ /dev/null @@ -1,43 +0,0 @@ -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -macro_rules! checker { - ($attr_name:ident, $expected:literal) => { - #[proc_macro_attribute] - pub fn $attr_name(attr: TokenStream, input: TokenStream) -> TokenStream { - assert_eq!(input.to_string(), $expected); - TokenStream::new() - } - } -} - -checker!(attr_extern, r#"extern "C" { fn ffi(#[a1] arg1 : i32, #[a2] ...) ; }"#); -checker!(attr_extern_cvar, r#"unsafe extern "C" fn cvar(arg1 : i32, #[a1] mut args : ...) {}"#); -checker!(attr_alias, "type Alias = fn(#[a1] u8, #[a2] ...) ;"); -checker!(attr_free, "fn free(#[a1] arg1 : u8) { let lam = | #[a2] W(x), #[a3] y | () ; }"); -checker!(attr_inherent_1, "fn inherent1(#[a1] self, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_2, "fn inherent2(#[a1] & self, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_3, "fn inherent3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_4, "fn inherent4 < 'a > (#[a1] self : Box < Self >, #[a2] arg1 : u8) {}"); -checker!(attr_inherent_issue_64682, "fn inherent5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) {}"); -checker!(attr_trait_1, "fn trait1(#[a1] self, #[a2] arg1 : u8) ;"); -checker!(attr_trait_2, "fn trait2(#[a1] & self, #[a2] arg1 : u8) ;"); -checker!(attr_trait_3, "fn trait3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) ;"); -checker!(attr_trait_4, r#"fn trait4 < 'a > -(#[a1] self : Box < Self >, #[a2] arg1 : u8, #[a3] Vec < u8 >) ;"#); -checker!(attr_trait_issue_64682, "fn trait5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) ;"); -checker!(rename_params, r#"impl Foo -{ - fn hello(#[angery(true)] a : i32, #[a2] b : i32, #[what = "how"] c : u32) - {} fn - hello2(#[a1] #[a2] a : i32, #[what = "how"] b : i32, #[angery(true)] c : - u32) {} fn - hello_self(#[a1] #[a2] & self, #[a1] #[a2] a : i32, #[what = "how"] b : - i32, #[angery(true)] c : u32) {} -}"#); diff --git a/tests/ui/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs b/tests/ui/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs deleted file mode 100644 index 670303906..000000000 --- a/tests/ui/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs +++ /dev/null @@ -1,21 +0,0 @@ -// aux-build:param-attrs.rs - -// check-pass - -extern crate param_attrs; - -use param_attrs::rename_params; - -#[rename_params(send_help)] -impl Foo { - fn hello(#[angery(true)] a: i32, #[a2] b: i32, #[what = "how"] c: u32) {} - fn hello2(#[a1] #[a2] a: i32, #[what = "how"] b: i32, #[angery(true)] c: u32) {} - fn hello_self( - #[a1] #[a2] &self, - #[a1] #[a2] a: i32, - #[what = "how"] b: i32, - #[angery(true)] c: u32 - ) {} -} - -fn main() {} diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-2018.rs b/tests/ui/rfc-2565-param-attrs/param-attrs-2018.rs deleted file mode 100644 index a6f693bd5..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-2018.rs +++ /dev/null @@ -1,6 +0,0 @@ -// edition:2018 - -trait Trait2015 { fn foo(#[allow(C)] i32); } -//~^ ERROR expected one of `:`, `@`, or `|`, found `)` - -fn main() {} diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-2018.stderr b/tests/ui/rfc-2565-param-attrs/param-attrs-2018.stderr deleted file mode 100644 index 593821bf9..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-2018.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: expected one of `:`, `@`, or `|`, found `)` - --> $DIR/param-attrs-2018.rs:3:41 - | -LL | trait Trait2015 { fn foo(#[allow(C)] i32); } - | ^ expected one of `:`, `@`, or `|` - | - = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) -help: if this is a `self` type, give it a parameter name - | -LL | trait Trait2015 { fn foo(#[allow(C)] self: i32); } - | +++++ -help: if this is a parameter name, give it a type - | -LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); } - | ++++++++++ -help: if this is a type, explicitly ignore the parameter name - | -LL | trait Trait2015 { fn foo(#[allow(C)] _: i32); } - | ++ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-allowed.rs b/tests/ui/rfc-2565-param-attrs/param-attrs-allowed.rs deleted file mode 100644 index a547d09d0..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-allowed.rs +++ /dev/null @@ -1,101 +0,0 @@ -// check-pass -// compile-flags: --cfg something - -#![deny(unused_mut)] - -extern "C" { - fn ffi( - #[allow(unused_mut)] a: i32, - #[cfg(something)] b: i32, - #[cfg_attr(something, cfg(nothing))] c: i32, - #[forbid(unused_mut)] d: i32, - #[deny(unused_mut)] #[warn(unused_mut)] ... - ); -} - -type FnType = fn( - #[allow(unused_mut)] a: i32, - #[cfg(something)] b: i32, - #[cfg_attr(something, cfg(nothing))] c: i32, - #[forbid(unused_mut)] d: i32, - #[deny(unused_mut)] #[warn(unused_mut)] e: i32 -); - -pub fn foo( - #[allow(unused_mut)] a: i32, - #[cfg(something)] b: i32, - #[cfg_attr(something, cfg(nothing))] c: i32, - #[forbid(unused_mut)] d: i32, - #[deny(unused_mut)] #[warn(unused_mut)] _e: i32 -) {} - -// self - -struct SelfStruct {} -impl SelfStruct { - fn foo( - #[allow(unused_mut)] self, - #[cfg(something)] a: i32, - #[cfg_attr(something, cfg(nothing))] - #[deny(unused_mut)] b: i32, - ) {} -} - -struct RefStruct {} -impl RefStruct { - fn foo( - #[allow(unused_mut)] &self, - #[cfg(something)] a: i32, - #[cfg_attr(something, cfg(nothing))] - #[deny(unused_mut)] b: i32, - ) {} -} -trait RefTrait { - fn foo( - #[forbid(unused_mut)] &self, - #[warn(unused_mut)] a: i32 - ) {} -} -impl RefTrait for RefStruct { - fn foo( - #[forbid(unused_mut)] &self, - #[warn(unused_mut)] a: i32 - ) {} -} - -// Box - -struct BoxSelfStruct {} -impl BoxSelfStruct { - fn foo( - #[allow(unused_mut)] self: Box, - #[cfg(something)] a: i32, - #[cfg_attr(something, cfg(nothing))] - #[deny(unused_mut)] b: i32, - ) {} -} -trait BoxSelfTrait { - fn foo( - #[forbid(unused_mut)] self: Box, - #[warn(unused_mut)] a: i32 - ) {} -} -impl BoxSelfTrait for BoxSelfStruct { - fn foo( - #[forbid(unused_mut)] self: Box, - #[warn(unused_mut)] a: i32 - ) {} -} - -fn main() { - let _: unsafe extern "C" fn(_, _, _, ...) = ffi; - let _: fn(_, _, _, _) = foo; - let _: FnType = |_, _, _, _| {}; - let c = | - #[allow(unused_mut)] a: u32, - #[cfg(something)] b: i32, - #[cfg_attr(something, cfg(nothing))] - #[deny(unused_mut)] c: i32, - | {}; - let _ = c(1, 2); -} diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs deleted file mode 100644 index 151659e35..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs +++ /dev/null @@ -1,174 +0,0 @@ -extern "C" { - fn ffi( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ); -} - -type FnType = fn( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - #[test] a: u32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters -); - -pub fn foo( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - #[test] a: u32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters -) {} - -struct SelfStruct {} -impl SelfStruct { - fn foo( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - self, - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Qux - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ) {} - - fn issue_64682_associated_fn( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Qux - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ) {} -} - -struct RefStruct {} -impl RefStruct { - fn foo( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - &self, - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Qux - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ) {} -} -trait RefTrait { - fn foo( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - &self, - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Qux - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ) {} - - fn issue_64682_associated_fn( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Qux - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ) {} -} - -impl RefTrait for RefStruct { - fn foo( - /// Foo - //~^ ERROR documentation comments cannot be applied to function - &self, - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[test] a: i32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Qux - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32, - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - ) {} -} - -fn main() { - let _ = | - /// Foo - //~^ ERROR documentation comments cannot be applied to function - #[test] a: u32, - //~^ ERROR expected non-macro attribute, found attribute macro - /// Bar - //~^ ERROR documentation comments cannot be applied to function - #[must_use] - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - /// Baz - //~^ ERROR documentation comments cannot be applied to function - #[no_mangle] b: i32 - //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - | {}; -} diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr deleted file mode 100644 index 7573e39d8..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr +++ /dev/null @@ -1,386 +0,0 @@ -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:5:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:21:7 - | -LL | #[test] a: u32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:36:7 - | -LL | #[test] a: u32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:56:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:71:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:92:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:111:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:126:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:146:11 - | -LL | #[test] a: i32, - | ^^^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `test` - --> $DIR/param-attrs-builtin-attrs.rs:163:11 - | -LL | #[test] a: u32, - | ^^^^ not a non-macro attribute - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:3:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:7:9 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:9:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:11:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:13:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:19:5 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:23:5 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:25:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:27:5 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:29:5 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:34:5 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:38:5 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:40:5 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:42:5 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:44:5 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:51:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:54:9 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:58:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:60:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:62:9 - | -LL | /// Qux - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:64:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:69:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:73:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:75:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:77:9 - | -LL | /// Qux - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:79:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:87:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:90:9 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:94:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:96:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:98:9 - | -LL | /// Qux - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:100:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:106:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:109:9 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:113:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:115:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:117:9 - | -LL | /// Qux - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:119:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:124:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:128:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:130:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:132:9 - | -LL | /// Qux - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:134:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:141:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:144:9 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:148:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:150:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:152:9 - | -LL | /// Qux - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:154:9 - | -LL | #[no_mangle] b: i32, - | ^^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:161:9 - | -LL | /// Foo - | ^^^^^^^ doc comments are not allowed here - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:165:9 - | -LL | /// Bar - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:167:9 - | -LL | #[must_use] - | ^^^^^^^^^^^ - -error: documentation comments cannot be applied to function parameters - --> $DIR/param-attrs-builtin-attrs.rs:169:9 - | -LL | /// Baz - | ^^^^^^^ doc comments are not allowed here - -error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters - --> $DIR/param-attrs-builtin-attrs.rs:171:9 - | -LL | #[no_mangle] b: i32 - | ^^^^^^^^^^^^ - -error: aborting due to 64 previous errors - diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.rs b/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.rs deleted file mode 100644 index a4d9d32b5..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.rs +++ /dev/null @@ -1,121 +0,0 @@ -// compile-flags: --cfg something -// edition:2018 - -#![feature(async_closure)] -#![deny(unused_variables)] - -extern "C" { - fn ffi( - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - #[cfg_attr(something, cfg(nothing))] c: i32, - #[cfg_attr(nothing, cfg(nothing))] ... - ); -} - -type FnType = fn( - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - #[cfg_attr(nothing, cfg(nothing))] c: i32, - #[cfg_attr(something, cfg(nothing))] d: i32, -); - -async fn foo_async( - #[cfg(something)] a: i32, - //~^ ERROR unused variable: `a` - #[cfg(nothing)] b: i32, -) {} -fn foo( - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, -) {} - -struct RefStruct {} -impl RefStruct { - async fn bar_async( - &self, - #[cfg(something)] a: i32, - //~^ ERROR unused variable: `a` - #[cfg(nothing)] b: i32, - ) {} - fn bar( - &self, - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - ) {} - fn issue_64682_associated_fn( - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - ) {} -} -trait RefTrait { - fn bar( - &self, - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - ) {} - fn issue_64682_associated_fn( - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - ) {} -} -impl RefTrait for RefStruct { - fn bar( - &self, - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - ) {} - fn issue_64682_associated_fn( - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - ) {} -} - -fn main() { - let _: unsafe extern "C" fn(_, ...) = ffi; - let _: fn(_, _) = foo; - let _: FnType = |_, _| {}; - let a = async move | - #[cfg(something)] a: i32, - //~^ ERROR unused variable: `a` - #[cfg(nothing)] b: i32, - | {}; - let c = | - #[cfg(nothing)] a: i32, - #[cfg(something)] b: i32, - //~^ ERROR unused variable: `b` - #[cfg_attr(nothing, cfg(nothing))] c: i32, - //~^ ERROR unused variable: `c` - #[cfg_attr(something, cfg(nothing))] d: i32, - | {}; - let _ = a(1); - let _ = c(1, 2); -} diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr b/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr deleted file mode 100644 index 16e1af460..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-cfg.stderr +++ /dev/null @@ -1,122 +0,0 @@ -error: unused variable: `a` - --> $DIR/param-attrs-cfg.rs:24:23 - | -LL | #[cfg(something)] a: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_a` - | -note: the lint level is defined here - --> $DIR/param-attrs-cfg.rs:5:9 - | -LL | #![deny(unused_variables)] - | ^^^^^^^^^^^^^^^^ - -error: unused variable: `a` - --> $DIR/param-attrs-cfg.rs:41:27 - | -LL | #[cfg(something)] a: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_a` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:30:23 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:32:40 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:48:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:50:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:56:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:58:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:67:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:69:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:75:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:77:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:86:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:88:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:94:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:96:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: unused variable: `a` - --> $DIR/param-attrs-cfg.rs:107:27 - | -LL | #[cfg(something)] a: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_a` - -error: unused variable: `b` - --> $DIR/param-attrs-cfg.rs:113:27 - | -LL | #[cfg(something)] b: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_b` - -error: unused variable: `c` - --> $DIR/param-attrs-cfg.rs:115:44 - | -LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, - | ^ help: if this is intentional, prefix it with an underscore: `_c` - -error: aborting due to 19 previous errors - diff --git a/tests/ui/rfc-2565-param-attrs/param-attrs-pretty.rs b/tests/ui/rfc-2565-param-attrs/param-attrs-pretty.rs deleted file mode 100644 index 1183ac65b..000000000 --- a/tests/ui/rfc-2565-param-attrs/param-attrs-pretty.rs +++ /dev/null @@ -1,61 +0,0 @@ -// aux-build:param-attrs.rs - -// check-pass - -#![feature(c_variadic)] - -extern crate param_attrs; - -use param_attrs::*; - -struct W(u8); - -#[attr_extern] -extern "C" { fn ffi(#[a1] arg1: i32, #[a2] ...); } - -#[attr_extern_cvar] -unsafe extern "C" fn cvar(arg1: i32, #[a1] mut args: ...) {} - -#[attr_alias] -type Alias = fn(#[a1] u8, #[a2] ...); - -#[attr_free] -fn free(#[a1] arg1: u8) { - let lam = |#[a2] W(x), #[a3] y| (); -} - -impl W { - #[attr_inherent_1] - fn inherent1(#[a1] self, #[a2] arg1: u8) {} - - #[attr_inherent_2] - fn inherent2(#[a1] &self, #[a2] arg1: u8) {} - - #[attr_inherent_3] - fn inherent3<'a>(#[a1] &'a mut self, #[a2] arg1: u8) {} - - #[attr_inherent_4] - fn inherent4<'a>(#[a1] self: Box, #[a2] arg1: u8) {} - - #[attr_inherent_issue_64682] - fn inherent5(#[a1] #[a2] arg1: u8, #[a3] arg2: u8) {} -} - -trait A { - #[attr_trait_1] - fn trait1(#[a1] self, #[a2] arg1: u8); - - #[attr_trait_2] - fn trait2(#[a1] &self, #[a2] arg1: u8); - - #[attr_trait_3] - fn trait3<'a>(#[a1] &'a mut self, #[a2] arg1: u8); - - #[attr_trait_4] - fn trait4<'a>(#[a1] self: Box, #[a2] arg1: u8, #[a3] Vec); - - #[attr_trait_issue_64682] - fn trait5(#[a1] #[a2] arg1: u8, #[a3] arg2: u8); -} - -fn main() {} diff --git a/tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs b/tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs deleted file mode 100644 index 54f2f451b..000000000 --- a/tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs +++ /dev/null @@ -1,66 +0,0 @@ -// aux-build:ident-mac.rs - -#![feature(c_variadic)] -#![allow(anonymous_parameters)] - -extern crate ident_mac; -use ident_mac::id; - -struct W(u8); - -extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } -//~^ ERROR expected non-macro attribute, found attribute macro -//~| ERROR expected non-macro attribute, found attribute macro - -unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} -//~^ ERROR expected non-macro attribute, found attribute macro - -type Alias = extern "C" fn(#[id] u8, #[id] ...); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - -fn free(#[id] arg1: u8) { - //~^ ERROR expected non-macro attribute, found attribute macro - let lam = |#[id] W(x), #[id] y: usize| (); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro -} - -impl W { - fn inherent1(#[id] self, #[id] arg1: u8) {} - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn inherent2(#[id] &self, #[id] arg1: u8) {} - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro -} - -trait A { - fn trait1(#[id] self, #[id] arg1: u8); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn trait2(#[id] &self, #[id] arg1: u8); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro - fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); - //~^ ERROR expected non-macro attribute, found attribute macro - //~| ERROR expected non-macro attribute, found attribute macro -} - -fn main() {} diff --git a/tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr b/tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr deleted file mode 100644 index e74d05d49..000000000 --- a/tests/ui/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr +++ /dev/null @@ -1,176 +0,0 @@ -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:11:23 - | -LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:11:40 - | -LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:15:40 - | -LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:18:30 - | -LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:18:40 - | -LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:22:11 - | -LL | fn free(#[id] arg1: u8) { - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:24:18 - | -LL | let lam = |#[id] W(x), #[id] y: usize| (); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:24:30 - | -LL | let lam = |#[id] W(x), #[id] y: usize| (); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:30:20 - | -LL | fn inherent1(#[id] self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:30:32 - | -LL | fn inherent1(#[id] self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:33:20 - | -LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:33:33 - | -LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:36:24 - | -LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:36:44 - | -LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:39:24 - | -LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:39:47 - | -LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:42:40 - | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:42:56 - | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:48:17 - | -LL | fn trait1(#[id] self, #[id] arg1: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:48:29 - | -LL | fn trait1(#[id] self, #[id] arg1: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:51:17 - | -LL | fn trait2(#[id] &self, #[id] arg1: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:51:30 - | -LL | fn trait2(#[id] &self, #[id] arg1: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:54:21 - | -LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:54:41 - | -LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:57:21 - | -LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:57:44 - | -LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:57:60 - | -LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:61:40 - | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); - | ^^ not a non-macro attribute - -error: expected non-macro attribute, found attribute macro `id` - --> $DIR/proc-macro-cannot-be-used.rs:61:56 - | -LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); - | ^^ not a non-macro attribute - -error: aborting due to 29 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs b/tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs deleted file mode 100644 index d7a418959..000000000 --- a/tests/ui/rfc-2627-raw-dylib/dlltool-failed.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Tests that dlltool failing to generate an import library will raise an error. - -// only-gnu -// only-windows -// needs-dlltool -// compile-flags: --crate-type lib --emit link -// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL" -// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE" -#[link(name = "foo", kind = "raw-dylib")] -extern "C" { - // `@1` is an invalid name to export, as it usually indicates that something - // is being exported via ordinal. - #[link_name = "@1"] - fn f(x: i32); -} - -pub fn lib_main() { - unsafe { f(42); } -} diff --git a/tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr b/tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr deleted file mode 100644 index 020ac6a2b..000000000 --- a/tests/ui/rfc-2627-raw-dylib/dlltool-failed.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Dlltool could not create import library: - $DLLTOOL: Syntax error in def file $DEF_FILE:1 - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs deleted file mode 100644 index 7bc44d65b..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.rs +++ /dev/null @@ -1,7 +0,0 @@ -// only-windows -// only-x86 -#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] -//~^ ERROR import name type must be of the form `import_name_type = "string"` -extern "C" { } - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr deleted file mode 100644 index fb70b987f..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: import name type must be of the form `import_name_type = "string"` - --> $DIR/import-name-type-invalid-format.rs:3:42 - | -LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs deleted file mode 100644 index b96f61a26..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.rs +++ /dev/null @@ -1,8 +0,0 @@ -// ignore-tidy-linelength -// only-windows -// only-x86 -#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] -//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute -extern "C" { } - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr deleted file mode 100644 index 953306189..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-multiple.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: multiple `import_name_type` arguments in a single `#[link]` attribute - --> $DIR/import-name-type-multiple.rs:4:74 - | -LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs deleted file mode 100644 index 067e82a17..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.rs +++ /dev/null @@ -1,7 +0,0 @@ -// only-windows -// only-x86 -#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] -//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated -extern "C" { } - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr deleted file mode 100644 index 2bce9758e..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated - --> $DIR/import-name-type-unknown-value.rs:3:42 - | -LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs deleted file mode 100644 index 34e907bde..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs +++ /dev/null @@ -1,15 +0,0 @@ -// only-windows -// only-x86 -#[link(name = "foo", import_name_type = "decorated")] -//~^ ERROR import name type can only be used with link kind `raw-dylib` -extern "C" { } - -#[link(name = "bar", kind = "static", import_name_type = "decorated")] -//~^ ERROR import name type can only be used with link kind `raw-dylib` -extern "C" { } - -// Specifying `import_name_type` before `kind` shouldn't raise an error. -#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")] -extern "C" { } - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr deleted file mode 100644 index 75cadc471..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: import name type can only be used with link kind `raw-dylib` - --> $DIR/import-name-type-unsupported-link-kind.rs:3:22 - | -LL | #[link(name = "foo", import_name_type = "decorated")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: import name type can only be used with link kind `raw-dylib` - --> $DIR/import-name-type-unsupported-link-kind.rs:7:39 - | -LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.rs b/tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.rs deleted file mode 100644 index 346ea18a8..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.rs +++ /dev/null @@ -1,7 +0,0 @@ -// only-windows -// ignore-x86 -#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] -//~^ ERROR import name type is only supported on x86 -extern "C" { } - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.stderr b/tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.stderr deleted file mode 100644 index b56449299..000000000 --- a/tests/ui/rfc-2627-raw-dylib/import-name-type-x86-only.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: import name type is only supported on x86 - --> $DIR/import-name-type-x86-only.rs:3:42 - | -LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs b/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs deleted file mode 100644 index a07be9d92..000000000 --- a/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Tests that failing to run dlltool will raise an error. - -// only-gnu -// only-windows -// compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe -#[link(name = "foo", kind = "raw-dylib")] -extern "C" { - fn f(x: i32); -} - -pub fn lib_main() { - unsafe { f(42); } -} diff --git a/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr b/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr deleted file mode 100644 index 3ae901e0d..000000000 --- a/tests/ui/rfc-2627-raw-dylib/invalid-dlltool.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: Error calling dlltool 'does_not_exit.exe': program not found - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs deleted file mode 100644 index b04c2facb..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[link(name="foo")] -extern "C" { - #[link_name="foo"] - #[link_ordinal(42)] - //~^ ERROR cannot use `#[link_name]` with `#[link_ordinal]` - fn foo(); - #[link_name="foo"] - #[link_ordinal(5)] - //~^ ERROR cannot use `#[link_name]` with `#[link_ordinal]` - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr deleted file mode 100644 index f1e54d378..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-and-name.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: cannot use `#[link_name]` with `#[link_ordinal]` - --> $DIR/link-ordinal-and-name.rs:4:5 - | -LL | #[link_ordinal(42)] - | ^^^^^^^^^^^^^^^^^^^ - -error: cannot use `#[link_name]` with `#[link_ordinal]` - --> $DIR/link-ordinal-and-name.rs:8:5 - | -LL | #[link_ordinal(5)] - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs deleted file mode 100644 index 9b7e8d707..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[link(name = "foo")] -extern "C" { - #[link_ordinal("JustMonika")] - //~^ ERROR illegal ordinal format in `link_ordinal` - fn foo(); - #[link_ordinal("JustMonika")] - //~^ ERROR illegal ordinal format in `link_ordinal` - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr deleted file mode 100644 index 6341e57a0..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: illegal ordinal format in `link_ordinal` - --> $DIR/link-ordinal-invalid-format.rs:3:5 - | -LL | #[link_ordinal("JustMonika")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: an unsuffixed integer value, e.g., `1`, is expected - -error: illegal ordinal format in `link_ordinal` - --> $DIR/link-ordinal-invalid-format.rs:6:5 - | -LL | #[link_ordinal("JustMonika")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: an unsuffixed integer value, e.g., `1`, is expected - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs deleted file mode 100644 index 6b8cd4956..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[link(name = "foo")] -extern "C" { - #[link_ordinal()] - //~^ ERROR incorrect number of arguments to `#[link_ordinal]` - fn foo(); - #[link_ordinal()] - //~^ ERROR incorrect number of arguments to `#[link_ordinal]` - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr deleted file mode 100644 index 1b04bb228..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-missing-argument.rs:3:5 - | -LL | #[link_ordinal()] - | ^^^^^^^^^^^^^^^^^ - | - = note: the attribute requires exactly one argument - -error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-missing-argument.rs:6:5 - | -LL | #[link_ordinal()] - | ^^^^^^^^^^^^^^^^^ - | - = note: the attribute requires exactly one argument - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs deleted file mode 100644 index 8842cb944..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.rs +++ /dev/null @@ -1,12 +0,0 @@ -// only-windows -#[link(name = "foo", kind = "raw-dylib")] -extern "C" { - #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes - #[link_ordinal(2)] - fn foo(); - #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes - #[link_ordinal(2)] - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr deleted file mode 100644 index 2e6cf3761..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-multiple.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: multiple `link_ordinal` attributes - --> $DIR/link-ordinal-multiple.rs:4:5 - | -LL | #[link_ordinal(1)] - | ^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/link-ordinal-multiple.rs:5:5 - | -LL | #[link_ordinal(2)] - | ^^^^^^^^^^^^^^^^^^ - -error: multiple `link_ordinal` attributes - --> $DIR/link-ordinal-multiple.rs:7:5 - | -LL | #[link_ordinal(1)] - | ^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/link-ordinal-multiple.rs:8:5 - | -LL | #[link_ordinal(2)] - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs deleted file mode 100644 index f33a3d62e..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs +++ /dev/null @@ -1,22 +0,0 @@ -#[link_ordinal(123)] -//~^ ERROR attribute should be applied to a foreign function or static -struct Foo {} - -#[link_ordinal(123)] -//~^ ERROR attribute should be applied to a foreign function or static -fn test() {} - -#[link_ordinal(42)] -//~^ ERROR attribute should be applied to a foreign function or static -static mut imported_val: i32 = 123; - -#[link(name = "exporter", kind = "raw-dylib")] -extern { - #[link_ordinal(13)] - fn imported_function(); - - #[link_ordinal(42)] - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr deleted file mode 100644 index 8f2795087..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: attribute should be applied to a foreign function or static - --> $DIR/link-ordinal-not-foreign-fn.rs:1:1 - | -LL | #[link_ordinal(123)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: attribute should be applied to a foreign function or static - --> $DIR/link-ordinal-not-foreign-fn.rs:5:1 - | -LL | #[link_ordinal(123)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: attribute should be applied to a foreign function or static - --> $DIR/link-ordinal-not-foreign-fn.rs:9:1 - | -LL | #[link_ordinal(42)] - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs deleted file mode 100644 index 9d741630f..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[link(name = "foo")] -extern "C" { - #[link_ordinal(72436)] - //~^ ERROR ordinal value in `link_ordinal` is too large: `72436` - fn foo(); - #[link_ordinal(72436)] - //~^ ERROR ordinal value in `link_ordinal` is too large: `72436` - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr deleted file mode 100644 index 811145e77..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: ordinal value in `link_ordinal` is too large: `72436` - --> $DIR/link-ordinal-too-large.rs:3:5 - | -LL | #[link_ordinal(72436)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the value may not exceed `u16::MAX` - -error: ordinal value in `link_ordinal` is too large: `72436` - --> $DIR/link-ordinal-too-large.rs:6:5 - | -LL | #[link_ordinal(72436)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the value may not exceed `u16::MAX` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs deleted file mode 100644 index 9988115fd..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[link(name = "foo")] -extern "C" { - #[link_ordinal(3, 4)] - //~^ ERROR incorrect number of arguments to `#[link_ordinal]` - fn foo(); - #[link_ordinal(3, 4)] - //~^ ERROR incorrect number of arguments to `#[link_ordinal]` - static mut imported_variable: i32; -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr deleted file mode 100644 index d5ce8aff3..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-too-many-arguments.rs:3:5 - | -LL | #[link_ordinal(3, 4)] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: the attribute requires exactly one argument - -error: incorrect number of arguments to `#[link_ordinal]` - --> $DIR/link-ordinal-too-many-arguments.rs:6:5 - | -LL | #[link_ordinal(3, 4)] - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: the attribute requires exactly one argument - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs b/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs deleted file mode 100644 index 14e915d60..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs +++ /dev/null @@ -1,15 +0,0 @@ -#[link(name = "foo")] -extern "C" { - #[link_ordinal(3)] - //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib` - fn foo(); -} - -#[link(name = "bar", kind = "static")] -extern "C" { - #[link_ordinal(3)] - //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib` - fn bar(); -} - -fn main() {} diff --git a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr b/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr deleted file mode 100644 index 200b8f628..000000000 --- a/tests/ui/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: `#[link_ordinal]` is only supported if link kind is `raw-dylib` - --> $DIR/link-ordinal-unsupported-link-kind.rs:3:5 - | -LL | #[link_ordinal(3)] - | ^^^^^^^^^^^^^^^^^^ - -error: `#[link_ordinal]` is only supported if link kind is `raw-dylib` - --> $DIR/link-ordinal-unsupported-link-kind.rs:10:5 - | -LL | #[link_ordinal(3)] - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs b/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs deleted file mode 100644 index b4173f3b6..000000000 --- a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.rs +++ /dev/null @@ -1,18 +0,0 @@ -// only-x86 -// only-windows -// compile-flags: --crate-type lib --emit link -#![allow(clashing_extern_declarations)] -#[link(name = "foo", kind = "raw-dylib")] -extern "C" { - fn f(x: i32); -} - -pub fn lib_main() { - #[link(name = "foo", kind = "raw-dylib")] - extern "stdcall" { - fn f(x: i32); - //~^ ERROR multiple declarations of external function `f` from library `foo.dll` have different calling conventions - } - - unsafe { f(42); } -} diff --git a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr b/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr deleted file mode 100644 index 510108405..000000000 --- a/tests/ui/rfc-2627-raw-dylib/multiple-declarations.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: multiple declarations of external function `f` from library `foo.dll` have different calling conventions - --> $DIR/multiple-declarations.rs:13:9 - | -LL | fn f(x: i32); - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs b/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs deleted file mode 100644 index d4c6658a3..000000000 --- a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs +++ /dev/null @@ -1,5 +0,0 @@ -// ignore-windows -// compile-flags: --crate-type lib -#[link(name = "foo", kind = "raw-dylib")] -//~^ ERROR: link kind `raw-dylib` is only supported on Windows targets -extern "C" {} diff --git a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr b/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr deleted file mode 100644 index b635a09af..000000000 --- a/tests/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0455]: link kind `raw-dylib` is only supported on Windows targets - --> $DIR/raw-dylib-windows-only.rs:3:29 - | -LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0455`. diff --git a/tests/ui/rfc-2627-raw-dylib/unsupported-abi.rs b/tests/ui/rfc-2627-raw-dylib/unsupported-abi.rs deleted file mode 100644 index 2f5a23e47..000000000 --- a/tests/ui/rfc-2627-raw-dylib/unsupported-abi.rs +++ /dev/null @@ -1,12 +0,0 @@ -// only-x86_64 -// only-windows -// compile-flags: --crate-type lib --emit link -#[link(name = "foo", kind = "raw-dylib")] -extern "stdcall" { - fn f(x: i32); - //~^ ERROR ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture -} - -pub fn lib_main() { - unsafe { f(42); } -} diff --git a/tests/ui/rfc-2627-raw-dylib/unsupported-abi.stderr b/tests/ui/rfc-2627-raw-dylib/unsupported-abi.stderr deleted file mode 100644 index f8265ae69..000000000 --- a/tests/ui/rfc-2627-raw-dylib/unsupported-abi.stderr +++ /dev/null @@ -1,8 +0,0 @@ -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/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs b/tests/ui/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs deleted file mode 100644 index 780a510c5..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check-pass -#![feature(const_trait_impl)] - -#[const_trait] -trait Foo { - type Assoc: ~const Foo; - fn foo() {} -} - -const fn foo() { - ::Assoc::foo(); -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs b/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs deleted file mode 100644 index 96790a873..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/assoc-type.rs +++ /dev/null @@ -1,33 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -struct NonConstAdd(i32); - -impl std::ops::Add for NonConstAdd { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - NonConstAdd(self.0 + rhs.0) - } -} - -#[const_trait] -trait Foo { - type Bar: ~const std::ops::Add; -} - -impl const Foo for NonConstAdd { - type Bar = NonConstAdd; -} - -#[const_trait] -trait Baz { - type Qux: std::ops::Add; -} - -impl const Baz for NonConstAdd { - type Qux = NonConstAdd; // OK -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr b/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr deleted file mode 100644 index 0cffae1da..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/assoc-type.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/assoc-type.rs:17:22 - | -LL | type Bar: ~const std::ops::Add; - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/attr-misuse.rs b/tests/ui/rfc-2632-const-trait-impl/attr-misuse.rs deleted file mode 100644 index 01ac74fef..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/attr-misuse.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait A { - #[const_trait] //~ ERROR attribute should be applied - fn foo(self); -} - -#[const_trait] //~ ERROR attribute should be applied -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/attr-misuse.stderr b/tests/ui/rfc-2632-const-trait-impl/attr-misuse.stderr deleted file mode 100644 index b18f33218..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/attr-misuse.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: attribute should be applied to a trait - --> $DIR/attr-misuse.rs:9:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ - -error: attribute should be applied to a trait - --> $DIR/attr-misuse.rs:5:5 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs b/tests/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs deleted file mode 100644 index e73082c11..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs +++ /dev/null @@ -1,23 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -pub trait MyTrait { - fn defaulted_func(&self) {} - fn func(self); -} - -pub struct NonConst; - -impl MyTrait for NonConst { - fn func(self) { - - } -} - -pub struct Const; - -impl const MyTrait for Const { - fn func(self) { - - } -} diff --git a/tests/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs b/tests/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs deleted file mode 100644 index 589e3f024..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/auxiliary/staged-api.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(const_trait_impl)] -#![feature(staged_api)] -#![stable(feature = "rust1", since = "1.0.0")] - -#[stable(feature = "rust1", since = "1.0.0")] -#[const_trait] -pub trait MyTrait { - #[stable(feature = "rust1", since = "1.0.0")] - fn func(); -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Unstable; - -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "unstable", issue = "none")] -impl const MyTrait for Unstable { - fn func() {} -} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs deleted file mode 100644 index dd9933974..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -pub trait Plus { - fn plus(self, rhs: Self) -> Self; -} - -impl const Plus for i32 { - fn plus(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Plus for u32 { - fn plus(self, rhs: Self) -> Self { - self + rhs - } -} - -pub const fn add_i32(a: i32, b: i32) -> i32 { - a.plus(b) // ok -} - -pub const fn add_u32(a: u32, b: u32) -> u32 { - a.plus(b) - //~^ ERROR the trait bound -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr deleted file mode 100644 index 7350909ba..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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` - | -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) - | ^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs deleted file mode 100644 index ae0c2e6bc..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs +++ /dev/null @@ -1,43 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -struct Int(i32); - -impl const std::ops::Add for Int { - type Output = Int; - - fn add(self, rhs: Self) -> Self { - Int(self.0.plus(rhs.0)) - } -} - -impl const PartialEq for Int { - fn eq(&self, rhs: &Self) -> bool { - self.0 == rhs.0 - } - fn ne(&self, other: &Self) -> bool { - !self.eq(other) - } -} - -#[const_trait] -pub trait Plus { - fn plus(self, rhs: Self) -> Self; -} - -impl const Plus for i32 { - fn plus(self, rhs: Self) -> Self { - self + rhs - } -} - -pub const fn add_i32(a: i32, b: i32) -> i32 { - a.plus(b) -} - -const ADD_INT: Int = Int(1i32) + Int(2i32); - -fn main() { - assert!(ADD_INT == Int(3i32)); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr b/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr deleted file mode 100644 index ff53eea11..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/call-const-trait-method-pass.rs:7:12 - | -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 - -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-const-trait-method-pass.rs:15:12 - | -LL | impl const PartialEq 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 - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs deleted file mode 100644 index 5120e6bfb..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs +++ /dev/null @@ -1,15 +0,0 @@ -// known-bug: #110395 -#![feature(const_trait_impl)] - -#[const_trait] -trait MyPartialEq { - fn eq(&self, other: &Self) -> bool; -} - -impl const MyPartialEq for T { - fn eq(&self, other: &Self) -> bool { - PartialEq::eq(self, other) - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr deleted file mode 100644 index 02d53cc78..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-in-impl.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-in-impl.rs:9:16 - | -LL | impl const MyPartialEq for T { - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs deleted file mode 100644 index 3febb328a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! Basic test for calling methods on generic type parameters in `const fn`. - -// known-bug: #110395 - -#![feature(const_trait_impl)] - -struct S; - -impl const PartialEq for S { - fn eq(&self, _: &S) -> bool { - true - } - fn ne(&self, other: &S) -> bool { - !self.eq(other) - } -} - -const fn equals_self(t: &T) -> bool { - *t == *t -} - -const fn equals_self_wrapper(t: &T) -> bool { - equals_self(t) -} - -pub const EQ: bool = equals_self_wrapper(&S); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr deleted file mode 100644 index 529a472e0..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-chain.stderr +++ /dev/null @@ -1,23 +0,0 @@ -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 - | -LL | const fn equals_self(t: &T) -> bool { - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-chain.rs:22:40 - | -LL | const fn equals_self_wrapper(t: &T) -> bool { - | ^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs deleted file mode 100644 index e618160d3..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs +++ /dev/null @@ -1,31 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -struct S; - -impl const PartialEq for S { - fn eq(&self, _: &S) -> bool { - true - } - fn ne(&self, other: &S) -> bool { - !self.eq(other) - } -} - -// This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const -// bound. -const fn equals_self(t: &T) -> bool { - *t == *t -} - -trait A: PartialEq {} -impl A for T {} - -const fn equals_self2(t: &T) -> bool { - *t == *t -} - -pub const EQ: bool = equals_self(&S) && equals_self2(&S); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr deleted file mode 100644 index bdc6ccc8a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr +++ /dev/null @@ -1,23 +0,0 @@ -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 - | -LL | const fn equals_self(t: &T) -> bool { - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-dup-bound.rs:25:37 - | -LL | const fn equals_self2(t: &T) -> bool { - | ^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs deleted file mode 100644 index fe1abbf42..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs +++ /dev/null @@ -1,9 +0,0 @@ -// known-bug: #110395 -#![feature(const_trait_impl)] - -pub const fn equals_self(t: &T) -> bool { - *t == *t - // (remove this) ~^ ERROR can't compare -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr deleted file mode 100644 index 3963f64ad..000000000 --- a/tests/ui/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/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs deleted file mode 100644 index e197c8b73..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass - -struct S; - -impl PartialEq for S { - fn eq(&self, _: &S) -> bool { - true - } -} - -const fn equals_self(t: &T) -> bool { - true -} - -pub const EQ: bool = equals_self(&S); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs deleted file mode 100644 index 414a8c87d..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![feature(const_trait_impl)] - -struct S; - -#[const_trait] -trait Foo { - fn eq(&self, _: &Self) -> bool; -} - -impl Foo for S { - fn eq(&self, _: &S) -> bool { - true - } -} - -const fn equals_self(t: &T) -> bool { - true -} - -// Calling `equals_self` with something that has a non-const impl should throw an error, despite -// it not using the impl. - -pub const EQ: bool = equals_self(&S); -//~^ ERROR - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr deleted file mode 100644 index a28d6ce05..000000000 --- a/tests/ui/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/rfc-2632-const-trait-impl/call-generic-method-pass.rs b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs deleted file mode 100644 index 09f35a277..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! Basic test for calling methods on generic type parameters in `const fn`. - -// known-bug: #110395 - -#![feature(const_trait_impl)] - -struct S; - -impl const PartialEq for S { - fn eq(&self, _: &S) -> bool { - true - } - fn ne(&self, other: &S) -> bool { - !self.eq(other) - } -} - -const fn equals_self(t: &T) -> bool { - *t == *t -} - -pub const EQ: bool = equals_self(&S); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr deleted file mode 100644 index 7fbe89dba..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-pass.stderr +++ /dev/null @@ -1,17 +0,0 @@ -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 - diff --git a/tests/ui/rfc-2632-const-trait-impl/call.rs b/tests/ui/rfc-2632-const-trait-impl/call.rs deleted file mode 100644 index 5f48c2353..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/call.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -#![feature(const_closures, const_trait_impl)] -#![allow(incomplete_features)] - -pub const _: () = { - assert!((const || true)()); -}; - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs b/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs deleted file mode 100644 index 9ba19e800..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.rs +++ /dev/null @@ -1,31 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -pub struct Int(i32); - -impl const std::ops::Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl std::ops::Add for Int { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - Int(self.0 + rhs.0) - } -} - -impl const std::ops::Add for Int { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - Int(self.0 + rhs.0) - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr deleted file mode 100644 index 4f858d61e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/const-and-non-const-impl.rs:7:12 - | -LL | impl const std::ops::Add for i32 { - | ^^^^^^^^^^^^^ - | - = 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 `Add` which is not marked with `#[const_trait]` - --> $DIR/const-and-non-const-impl.rs:23:12 - | -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 - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs b/tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs deleted file mode 100644 index 52984fb6b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(const_trait_impl)] - -struct S; -#[const_trait] -trait T { - fn foo(); -} - -fn non_const() {} - -impl const T for S { - fn foo() { non_const() } - //~^ ERROR cannot call non-const fn -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr deleted file mode 100644 index c8783de4c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0015]: cannot call non-const fn `non_const` in constant functions - --> $DIR/const-check-fns-in-const-impl.rs:12:16 - | -LL | fn foo() { non_const() } - | ^^^^^^^^^^^ - | - = 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/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs b/tests/ui/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs deleted file mode 100644 index 2c99d8bf1..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -#![feature(const_trait_impl, const_closures)] -#![allow(incomplete_features)] - -const fn test() -> impl ~const Fn() { - const move || {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs deleted file mode 100644 index b4cc7a9e1..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs +++ /dev/null @@ -1,20 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -#[const_trait] -trait Tr { - fn a(self) -> i32; -} - -impl Tr for () { - fn a(self) -> i32 { 42 } -} - -const fn need_const_closure i32>(x: T) -> i32 { - x(()) -} - -const _: () = assert!(need_const_closure(Tr::a) == 42); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr deleted file mode 100644 index 112416a35..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ /dev/null @@ -1,16 +0,0 @@ -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 - | -LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` - | -note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/const-closure-trait-method-fail.rs:18:23 - | -LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it appears within the type `fn(()) -> i32 {<() as Tr>::a}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs deleted file mode 100644 index 3e6d19088..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method.rs +++ /dev/null @@ -1,19 +0,0 @@ -// check-pass -#![feature(const_trait_impl)] - -#[const_trait] -trait Tr { - fn a(self) -> i32; -} - -impl const Tr for () { - fn a(self) -> i32 { 42 } -} - -const fn need_const_closure i32>(x: T) -> i32 { - x(()) -} - -const _: () = assert!(need_const_closure(Tr::a) == 42); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closures.rs b/tests/ui/rfc-2632-const-trait-impl/const-closures.rs deleted file mode 100644 index 7c55b51c8..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-closures.rs +++ /dev/null @@ -1,30 +0,0 @@ -// check-pass - -#![feature(const_trait_impl)] - -const fn answer_p1(f: &F) -> u8 - where - F: ~const FnOnce() -> u8, - F: ~const FnMut() -> u8, - F: ~const Fn() -> u8, -{ - f() * 7 -} - -const fn three() -> u8 { - 3 -} - -const fn answer_p2() -> u8 { - answer_p1(&three) -} - -const fn answer u8>(f: &F) -> u8 { - f() + f() -} - -const ANSWER: u8 = answer(&answer_p2); - -fn main() { - assert_eq!(ANSWER, 42) -} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs b/tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs deleted file mode 100644 index 140a06a73..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait ConstDefaultFn: Sized { - fn b(self); - - fn a(self) { - self.b(); - } -} - -struct NonConstImpl; -struct ConstImpl; - -impl ConstDefaultFn for NonConstImpl { - fn b(self) {} -} - -impl const ConstDefaultFn for ConstImpl { - fn b(self) {} -} - -const fn test() { - NonConstImpl.a(); - //~^ ERROR the trait bound - ConstImpl.a(); -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr b/tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr deleted file mode 100644 index f9d0d1f78..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-default-method-bodies.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied - --> $DIR/const-default-method-bodies.rs:24:18 - | -LL | NonConstImpl.a(); - | ^ the trait `~const 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(); - | ^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-bound.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-bound.rs deleted file mode 100644 index 948f0efbc..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-bound.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-pass - -#![feature(const_trait_impl)] -#![feature(const_precise_live_drops)] - -use std::marker::Destruct; - -const fn foo(res: Result) -> Option where E: ~const Destruct { - match res { - Ok(t) => Some(t), - Err(_e) => None, - } -} - -pub struct Foo(T); - -const fn baz(res: Result, Foo>) -> Option> -where - T: ~const Destruct, - E: ~const Destruct, -{ - foo(res) -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr deleted file mode 100644 index 13350a6d1..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail-2.rs:23:25 - | -LL | impl const Drop for ConstDropImplWithBounds { - | ^^^^ - | - = 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/const-drop-fail-2.rs:29:26 - | -LL | const fn check(_: T) {} - | ^^^^^^^^ - -error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail-2.rs:39:25 - | -LL | impl const Drop for ConstDropImplWithNonConstBounds { - | ^^^^ - | - = 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 3 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs deleted file mode 100644 index 3de9d37d4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs +++ /dev/null @@ -1,43 +0,0 @@ -// known-bug: #110395 -#![feature(const_trait_impl)] -#![feature(const_mut_refs)] -#![cfg_attr(precise, feature(const_precise_live_drops))] - -use std::marker::{Destruct, PhantomData}; - -struct NonTrivialDrop; - -impl Drop for NonTrivialDrop { - fn drop(&mut self) { - println!("Non trivial drop"); - } -} - -#[const_trait] -trait A { fn a() { } } - -impl A for NonTrivialDrop {} - -struct ConstDropImplWithBounds(PhantomData); - -impl const Drop for ConstDropImplWithBounds { - fn drop(&mut self) { - T::a(); - } -} - -const fn check(_: T) {} - -const _: () = check::>( - ConstDropImplWithBounds(PhantomData) -); - -struct ConstDropImplWithNonConstBounds(PhantomData); - -impl const Drop for ConstDropImplWithNonConstBounds { - fn drop(&mut self) { - T::a(); - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr deleted file mode 100644 index 375f5d2c5..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 - | -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); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr deleted file mode 100644 index 13350a6d1..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail-2.rs:23:25 - | -LL | impl const Drop for ConstDropImplWithBounds { - | ^^^^ - | - = 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/const-drop-fail-2.rs:29:26 - | -LL | const fn check(_: T) {} - | ^^^^^^^^ - -error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` - --> $DIR/const-drop-fail-2.rs:39:25 - | -LL | impl const Drop for ConstDropImplWithNonConstBounds { - | ^^^^ - | - = 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 3 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr deleted file mode 100644 index e745cbd24..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 - | -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) - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs deleted file mode 100644 index 1c37648ff..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs +++ /dev/null @@ -1,37 +0,0 @@ -// known-bug: #110395 - -// revisions: stock precise -#![feature(const_trait_impl)] -#![feature(const_mut_refs)] -#![cfg_attr(precise, feature(const_precise_live_drops))] - -use std::marker::{Destruct, PhantomData}; - -struct NonTrivialDrop; - -impl Drop for NonTrivialDrop { - fn drop(&mut self) { - println!("Non trivial drop"); - } -} - -struct ConstImplWithDropGlue(NonTrivialDrop); - -impl const Drop for ConstImplWithDropGlue { - fn drop(&mut self) {} -} - -const fn check(_: T) {} - -macro_rules! check_all { - ($($exp:expr),*$(,)?) => {$( - const _: () = check($exp); - )*}; -} - -check_all! { - NonTrivialDrop, - ConstImplWithDropGlue(NonTrivialDrop), -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr deleted file mode 100644 index e745cbd24..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:28:23 - | -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) - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop.rs deleted file mode 100644 index b0fc3adf9..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop.rs +++ /dev/null @@ -1,113 +0,0 @@ -// run-pass -// revisions: stock precise -#![feature(const_trait_impl)] -#![feature(const_mut_refs)] -#![feature(never_type)] -#![cfg_attr(precise, feature(const_precise_live_drops))] - -use std::marker::Destruct; - -struct S<'a>(&'a mut u8); - -impl<'a> const Drop for S<'a> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -const fn a(_: T) {} - -const fn b() -> u8 { - let mut c = 0; - let _ = S(&mut c); - a(S(&mut c)); - c -} - -const C: u8 = b(); - -macro_rules! implements_const_drop { - ($($exp:expr),*$(,)?) => { - $( - const _: () = a($exp); - )* - } -} - -#[allow(dead_code)] -mod t { - pub struct Foo; - pub enum Bar { A } - pub fn foo() {} - pub struct ConstDrop; - - impl const Drop for ConstDrop { - fn drop(&mut self) {} - } - - pub struct HasConstDrop(pub ConstDrop); - pub struct TrivialFields(pub u8, pub i8, pub usize, pub isize); - - #[const_trait] - pub trait SomeTrait { - fn foo(); - } - impl const SomeTrait for () { - fn foo() {} - } - // non-const impl - impl SomeTrait for i32 { - fn foo() {} - } - - pub struct ConstDropWithBound(pub core::marker::PhantomData); - - impl const Drop for ConstDropWithBound { - fn drop(&mut self) { - T::foo(); - } - } - - pub struct ConstDropWithNonconstBound(pub core::marker::PhantomData); - - impl const Drop for ConstDropWithNonconstBound { - fn drop(&mut self) { - // Note: we DON'T use the `T: SomeTrait` bound - } - } -} - -use t::*; - -implements_const_drop! { - 1u8, - 2, - 3.0, - Foo, - Bar::A, - foo, - ConstDrop, - HasConstDrop(ConstDrop), - TrivialFields(1, 2, 3, 4), - &1, - &1 as *const i32, - ConstDropWithBound::<()>, - ConstDropWithNonconstBound::, - Result::::Ok(1), -} - -fn main() { - struct HasDropGlue(#[allow(unused_tuple_struct_fields)] Box); - struct HasDropImpl; - impl Drop for HasDropImpl { - fn drop(&mut self) { - println!("not trivial drop"); - } - } - - // These types should pass because ~const in a non-const context should have no effect. - a(HasDropGlue(Box::new(0))); - a(HasDropImpl); - - assert_eq!(C, 2); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs b/tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs deleted file mode 100644 index bed4e9fd1..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(const_trait_impl)] - -struct Foo; - -const impl Foo { //~ ERROR: expected identifier, found keyword - fn bar() {} -} - -fn main() { - // shouldn't error here because we shouldn't have been able to recover above - Foo::bar(); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr b/tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr deleted file mode 100644 index 603f6b7d2..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-norecover.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected identifier, found keyword `impl` - --> $DIR/const-impl-norecover.rs:5:7 - | -LL | const impl Foo { - | ^^^^ expected identifier, found keyword - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs b/tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs deleted file mode 100644 index 837124db0..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Foo {} - -const impl Foo for i32 {} //~ ERROR: expected identifier, found keyword - -#[const_trait] -trait Bar {} - -const impl Bar for T {} //~ ERROR: expected identifier, found keyword - -const fn still_implements() {} - -const _: () = still_implements::(); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr b/tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr deleted file mode 100644 index 7217fc855..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-recovery.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:6:7 - | -LL | const impl Foo for i32 {} - | ^^^^ expected identifier, found keyword - | -help: you might have meant to write a const trait impl - | -LL - const impl Foo for i32 {} -LL + impl const Foo for i32 {} - | - -error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:11:7 - | -LL | const impl Bar for T {} - | ^^^^ expected identifier, found keyword - | -help: you might have meant to write a const trait impl - | -LL - const impl Bar for T {} -LL + impl const Bar for T {} - | - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs b/tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs deleted file mode 100644 index 2b4963991..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(const_trait_impl)] - -pub trait A {} -//~^ HELP: mark `A` as const - -impl const A for () {} -//~^ ERROR: const `impl` for trait `A` which is not marked with `#[const_trait]` - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr b/tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr deleted file mode 100644 index 478adcf3e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: const `impl` for trait `A` which is not marked with `#[const_trait]` - --> $DIR/const-impl-requires-const-trait.rs:6:12 - | -LL | pub trait A {} - | - help: mark `A` as const: `#[const_trait]` -... -LL | impl const A for () {} - | ^ - | - = 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 - diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs b/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs deleted file mode 100644 index f396deff4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.rs +++ /dev/null @@ -1,55 +0,0 @@ -// known-bug: #110395 -#![allow(incomplete_features)] -#![feature( - associated_type_bounds, - const_trait_impl, - const_cmp, - return_position_impl_trait_in_trait, -)] - -use std::marker::Destruct; - -const fn cmp(a: &impl ~const PartialEq) -> bool { - a == a -} - -const fn wrap(x: impl ~const PartialEq + ~const Destruct) - -> impl ~const PartialEq + ~const Destruct -{ - x -} - -#[const_trait] -trait Foo { - fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; -} - -impl const Foo for () { - fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - 123 - } -} - -const _: () = { - assert!(cmp(&0xDEADBEEFu32)); - assert!(cmp(&())); - assert!(wrap(123) == wrap(123)); - assert!(wrap(123) != wrap(456)); - let x = <() as Foo>::huh(); - assert!(x == x); -}; - -#[const_trait] -trait T {} -struct S; -impl const T for S {} - -const fn rpit() -> impl ~const T { S } - -const fn apit(_: impl ~const T + ~const Destruct) {} - -const fn rpit_assoc_bound() -> impl IntoIterator { Some(S) } - -const fn apit_assoc_bound(_: impl IntoIterator + ~const Destruct) {} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr b/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr deleted file mode 100644 index f9078e227..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const-impl-trait.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0635]: unknown feature `const_cmp` - --> $DIR/const-impl-trait.rs:6:5 - | -LL | const_cmp, - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:12:30 - | -LL | const fn cmp(a: &impl ~const PartialEq) -> bool { - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:16:30 - | -LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:17:20 - | -LL | -> impl ~const PartialEq + ~const Destruct - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:24:29 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:28:29 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^^^^ - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs deleted file mode 100644 index dba3ad7f8..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[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/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr deleted file mode 100644 index 6a81f96d8..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: use of unstable library feature 'derive_const' - --> $DIR/derive-const-gate.rs:1:3 - | -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 - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs deleted file mode 100644 index b575ea8da..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs +++ /dev/null @@ -1,13 +0,0 @@ -// known-bug: #110395 -#![feature(derive_const)] - -pub struct A; - -impl Default for A { - fn default() -> A { A } -} - -#[derive_const(Default)] -pub struct S(A); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr deleted file mode 100644 index 1c69ad431..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: const `impl` for trait `Default` which is not marked with `#[const_trait]` - --> $DIR/derive-const-non-const-type.rs:10: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 previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs deleted file mode 100644 index 69098542b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs +++ /dev/null @@ -1,19 +0,0 @@ -// known-bug: #110395 -#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] - -pub struct A; - -impl const Default for A { - fn default() -> A { A } -} - -impl const PartialEq for A { - fn eq(&self, _: &A) -> bool { true } -} - -#[derive_const(Default, PartialEq)] -pub struct S((), A); - -const _: () = assert!(S((), A) == S::default()); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr deleted file mode 100644 index 88054096e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0635]: unknown feature `const_cmp` - --> $DIR/derive-const-use.rs:2:30 - | -LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] - | ^^^^^^^^^ - -error[E0635]: unknown feature `const_default_impls` - --> $DIR/derive-const-use.rs:2:41 - | -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 - -For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs deleted file mode 100644 index 2a5d0176b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs +++ /dev/null @@ -1,13 +0,0 @@ -// known-bug: #110395 - -#![feature(derive_const)] -#![feature(const_trait_impl)] - -#[derive_const(PartialEq)] -pub struct Reverse(T); - -const fn foo(a: Reverse, b: Reverse) -> bool { - a == b -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr deleted file mode 100644 index fa7832658..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr +++ /dev/null @@ -1,20 +0,0 @@ -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 - | -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 - diff --git a/tests/ui/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs b/tests/ui/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs deleted file mode 100644 index bde8bf20f..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This tests that `const_trait` default methods can -// be called from a const context when used across crates. -// -// check-pass - -#![feature(const_trait_impl)] - -// aux-build: cross-crate.rs -extern crate cross_crate; - -use cross_crate::*; - -const _: () = { - Const.func(); - Const.defaulted_func(); -}; - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr b/tests/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr deleted file mode 100644 index 633b7cc25..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrait` is not satisfied - --> $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 - | -LL | NonConst.func(); - | ^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/cross-crate.rs b/tests/ui/rfc-2632-const-trait-impl/cross-crate.rs deleted file mode 100644 index 6df47022c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/cross-crate.rs +++ /dev/null @@ -1,24 +0,0 @@ -// revisions: stock gated stocknc gatednc -// [gated] check-pass -#![cfg_attr(any(gated, gatednc), feature(const_trait_impl))] - -// aux-build: cross-crate.rs -extern crate cross_crate; - -use cross_crate::*; - -fn non_const_context() { - NonConst.func(); - Const.func(); -} - -const fn const_context() { - #[cfg(any(stocknc, gatednc))] - NonConst.func(); - //[stocknc]~^ ERROR: the trait bound - //[gatednc]~^^ ERROR: the trait bound - Const.func(); - //[stock]~^ ERROR: cannot call -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr deleted file mode 100644 index 22f13a741..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/cross-crate.stock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0015]: cannot call non-const fn `::func` in constant functions - --> $DIR/cross-crate.rs:20:11 - | -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 - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr b/tests/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr deleted file mode 100644 index 9e97d3f11..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `cross_crate::NonConst: cross_crate::MyTrait` is not satisfied - --> $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 - | -LL | NonConst.func(); - | ^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs deleted file mode 100644 index 96acdc300..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Tr {} -impl Tr for () {} - -const fn foo() where T: ~const Tr {} - -#[const_trait] -pub trait Foo { - fn foo() { - foo::<()>(); - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr deleted file mode 100644 index 26644f72c..000000000 --- a/tests/ui/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/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs deleted file mode 100644 index f70ecbc37..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -pub trait Tr { - fn a(&self) {} - - fn b(&self) { - ().a() - //~^ ERROR the trait bound - } -} - -impl Tr for () {} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr deleted file mode 100644 index 21ecddaff..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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 `()` - | -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() - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs deleted file mode 100644 index 1b45cd9aa..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass - -// This was an ICE, because the compiler ensures the -// function to be const when performing const checking, -// but functions marked with the attribute are not const -// *and* subject to const checking. - -#![feature(staged_api)] -#![feature(const_trait_impl)] -#![stable(since = "1", feature = "foo")] - -#[const_trait] -trait Tr { - fn a() {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/do-not-const-check-override.rs b/tests/ui/rfc-2632-const-trait-impl/do-not-const-check-override.rs deleted file mode 100644 index 730e268c0..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/do-not-const-check-override.rs +++ /dev/null @@ -1,19 +0,0 @@ -// check-pass -#![feature(const_trait_impl, rustc_attrs)] - -#[const_trait] -trait Foo { - #[rustc_do_not_const_check] - fn into_iter(&self) { println!("FEAR ME!") } -} - - -impl const Foo for () { - fn into_iter(&self) { - // ^_^ - } -} - -const _: () = Foo::into_iter(&()); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/do-not-const-check.rs b/tests/ui/rfc-2632-const-trait-impl/do-not-const-check.rs deleted file mode 100644 index 3c39c53de..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/do-not-const-check.rs +++ /dev/null @@ -1,18 +0,0 @@ -// check-pass -#![feature(const_trait_impl, rustc_attrs)] - -#[const_trait] -trait IntoIter { - fn into_iter(self); -} - -#[const_trait] -trait Hmm: Sized { - #[rustc_do_not_const_check] - fn chain(self, other: U) where U: IntoIter, - { - other.into_iter() - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr b/tests/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr deleted file mode 100644 index 4c630d33c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/feature-gate.gated.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate.rs:14:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/feature-gate.rs b/tests/ui/rfc-2632-const-trait-impl/feature-gate.rs deleted file mode 100644 index 0b409fbaa..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/feature-gate.rs +++ /dev/null @@ -1,14 +0,0 @@ -// revisions: stock gated -// gate-test-const_trait_impl - -#![cfg_attr(gated, feature(const_trait_impl))] -#![feature(rustc_attrs)] - -struct S; -#[const_trait] //[stock]~ ERROR `const_trait` is a temporary placeholder -trait T {} -impl const T for S {} -//[stock]~^ ERROR const trait impls are experimental - -#[rustc_error] -fn main() {} //[gated]~ ERROR fatal error triggered by #[rustc_error] diff --git a/tests/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr deleted file mode 100644 index 0e938c1c5..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/feature-gate.stock.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:10:6 - | -LL | impl const T for S {} - | ^^^^^ - | - = note: see issue #67792 for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - -error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. - --> $DIR/feature-gate.rs:8:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ - | - = note: see issue #67792 for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs b/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs deleted file mode 100644 index 60790e297..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs +++ /dev/null @@ -1,15 +0,0 @@ -// check-pass -#![feature(const_trait_impl)] - -#[const_trait] -pub trait Test {} - -impl Test for () {} - -pub const fn test() {} - -pub const fn min_by_i32() -> fn() { - test::<()> -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/gate.rs b/tests/ui/rfc-2632-const-trait-impl/gate.rs deleted file mode 100644 index d1c93ab9f..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/gate.rs +++ /dev/null @@ -1,13 +0,0 @@ -// gate-test-const_closures - -fn main() { - (const || {})(); - //~^ ERROR: const closures are experimental -} - -macro_rules! e { - ($e:expr) => {} -} - -e!((const || {})); -//~^ ERROR const closures are experimental diff --git a/tests/ui/rfc-2632-const-trait-impl/gate.stderr b/tests/ui/rfc-2632-const-trait-impl/gate.stderr deleted file mode 100644 index 11cc2cd56..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/gate.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: const closures are experimental - --> $DIR/gate.rs:4:6 - | -LL | (const || {})(); - | ^^^^^ - | - = note: see issue #106003 for more information - = help: add `#![feature(const_closures)]` to the crate attributes to enable - -error[E0658]: const closures are experimental - --> $DIR/gate.rs:12:5 - | -LL | e!((const || {})); - | ^^^^^ - | - = note: see issue #106003 for more information - = help: add `#![feature(const_closures)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs b/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs deleted file mode 100644 index d665c4479..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/generic-bound.rs +++ /dev/null @@ -1,30 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -use std::marker::PhantomData; - -struct S(PhantomData); - -impl Copy for S {} -impl Clone for S { - fn clone(&self) -> Self { - S(PhantomData) - } -} - -impl const std::ops::Add for S { - type Output = Self; - - fn add(self, _: Self) -> Self { - S(std::marker::PhantomData) - } -} - -const fn twice(arg: S) -> S { - arg + arg -} - -fn main() { - let _ = twice(S(PhantomData::)); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr b/tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr deleted file mode 100644 index 1b21d7c0e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/generic-bound.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: const `impl` for trait `Add` which is not marked with `#[const_trait]` - --> $DIR/generic-bound.rs:16:15 - | -LL | impl const std::ops::Add 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: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/hir-const-check.rs b/tests/ui/rfc-2632-const-trait-impl/hir-const-check.rs deleted file mode 100644 index 337c73340..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/hir-const-check.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Regression test for #69615. - -#![feature(const_trait_impl)] - -#[const_trait] -pub trait MyTrait { - fn method(&self) -> Option<()>; -} - -impl const MyTrait for () { - fn method(&self) -> Option<()> { - Some(())?; //~ ERROR `?` is not allowed in a `const fn` - None - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/hir-const-check.stderr b/tests/ui/rfc-2632-const-trait-impl/hir-const-check.stderr deleted file mode 100644 index 6d2be1daa..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/hir-const-check.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `?` is not allowed in a `const fn` - --> $DIR/hir-const-check.rs:12:9 - | -LL | Some(())?; - | ^^^^^^^^^ - | - = note: see issue #74935 for more information - = help: add `#![feature(const_try)]` 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/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs b/tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs deleted file mode 100644 index 05b26465c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(const_trait_impl)] - -struct S; -trait T {} - -impl ~const T for S {} -//~^ ERROR expected a trait, found type - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr b/tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr deleted file mode 100644 index 0a91719e1..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected a trait, found type - --> $DIR/impl-tilde-const-trait.rs:6:6 - | -LL | impl ~const T for S {} - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs b/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs deleted file mode 100644 index 6df9696f2..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Tr { - fn req(&self); - - fn default() {} -} - -struct S; - -impl const Tr for u16 { - fn default() {} -} //~^^ ERROR not all trait items implemented - - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr deleted file mode 100644 index 6c6ca9f5d..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0046]: not all trait items implemented, missing: `req` - --> $DIR/impl-with-default-fn-fail.rs:12:1 - | -LL | fn req(&self); - | -------------- `req` from trait -... -LL | impl const Tr for u16 { - | ^^^^^^^^^^^^^^^^^^^^^ missing `req` in implementation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs b/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs deleted file mode 100644 index ae81421e9..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs +++ /dev/null @@ -1,26 +0,0 @@ -// check-pass - -#![feature(const_trait_impl)] - -#[const_trait] -trait Tr { - fn req(&self); - - fn default() {} -} - -impl const Tr for u8 { - fn req(&self) {} -} - -macro_rules! impl_tr { - ($ty: ty) => { - impl const Tr for $ty { - fn req(&self) {} - } - } -} - -impl_tr!(u64); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs b/tests/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs deleted file mode 100644 index f8ac793e4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs +++ /dev/null @@ -1,22 +0,0 @@ -// check-pass -#![feature(const_trait_impl)] - -struct S; - -#[const_trait] -trait A {} -#[const_trait] -trait B {} - -impl const A for S {} -impl const B for S {} - -impl S { - const fn a() where T: ~const B { - - } -} - -const _: () = S::a::(); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/inherent-impl.rs b/tests/ui/rfc-2632-const-trait-impl/inherent-impl.rs deleted file mode 100644 index afd0d137b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/inherent-impl.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(const_trait_impl)] -#![allow(bare_trait_objects)] - -struct S; -trait T {} - -impl const S {} -//~^ ERROR inherent impls cannot be `const` - -impl const T {} -//~^ ERROR inherent impls cannot be `const` - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/inherent-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/inherent-impl.stderr deleted file mode 100644 index 8c5562703..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/inherent-impl.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: inherent impls cannot be `const` - --> $DIR/inherent-impl.rs:7:12 - | -LL | impl const S {} - | ----- ^ inherent impl for this type - | | - | `const` because of this - | - = note: only trait implementations may be annotated with `const` - -error: inherent impls cannot be `const` - --> $DIR/inherent-impl.rs:10:12 - | -LL | impl const T {} - | ----- ^ inherent impl for this type - | | - | `const` because of this - | - = note: only trait implementations may be annotated with `const` - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-100222.rs b/tests/ui/rfc-2632-const-trait-impl/issue-100222.rs deleted file mode 100644 index 9f3f38ad4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-100222.rs +++ /dev/null @@ -1,39 +0,0 @@ -// revisions: nn ny yn yy -// check-pass -#![feature(const_trait_impl, associated_type_defaults, const_mut_refs)] - -#[cfg_attr(any(yn, yy), const_trait)] -pub trait Index { - type Output; -} - -#[cfg_attr(any(ny, yy), const_trait)] -pub trait IndexMut where Self: Index { - const C: ::Output; - type Assoc = ::Output; - fn foo(&mut self, x: ::Output) -> ::Output; -} - -impl Index for () { type Output = (); } - -#[cfg(not(any(nn, yn)))] -impl const IndexMut for <() as Index>::Output { - const C: ::Output = (); - type Assoc = ::Output; - fn foo(&mut self, x: ::Output) -> ::Output - where ::Output:, - {} -} - -#[cfg(any(nn, yn))] -impl IndexMut for <() as Index>::Output { - const C: ::Output = (); - type Assoc = ::Output; - fn foo(&mut self, x: ::Output) -> ::Output - where ::Output:, - {} -} - -const C: <() as Index>::Output = (); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-102156.rs b/tests/ui/rfc-2632-const-trait-impl/issue-102156.rs deleted file mode 100644 index fe4e91081..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-102156.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(allocator_api)] -#![feature(const_trait_impl)] - -use core::convert::{From, TryFrom}; -//~^ ERROR -//~| ERROR - -use std::pin::Pin; -use std::alloc::Allocator; -impl const From> for Pin> -where - A: 'static, -{} - -pub fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-102156.stderr b/tests/ui/rfc-2632-const-trait-impl/issue-102156.stderr deleted file mode 100644 index 8bf00eaff..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-102156.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/issue-102156.rs:4:5 - | -LL | use core::convert::{From, TryFrom}; - | ^^^^ maybe a missing crate `core`? - | - = help: consider adding `extern crate core` to use the `core` crate - -error[E0433]: failed to resolve: maybe a missing crate `core`? - --> $DIR/issue-102156.rs:4:5 - | -LL | use core::convert::{From, TryFrom}; - | ^^^^ maybe a missing crate `core`? - | - = help: consider adding `extern crate core` to use the `core` crate - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-102985.rs b/tests/ui/rfc-2632-const-trait-impl/issue-102985.rs deleted file mode 100644 index 07d3f51ed..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-102985.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![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 - }], -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-102985.stderr b/tests/ui/rfc-2632-const-trait-impl/issue-102985.stderr deleted file mode 100644 index b98ccbe5d..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-102985.stderr +++ /dev/null @@ -1,41 +0,0 @@ -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 - | -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 - -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-103677.rs b/tests/ui/rfc-2632-const-trait-impl/issue-103677.rs deleted file mode 100644 index d81724a36..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-103677.rs +++ /dev/null @@ -1,5 +0,0 @@ -// check-pass - -const _: fn(&String) = |s| { &*s as &str; }; - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs b/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs deleted file mode 100644 index b604c65d7..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-79450.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(const_fmt_arguments_new)] -#![feature(const_trait_impl)] - -#[const_trait] -trait Tr { - fn req(&self); - - fn prov(&self) { - println!("lul"); //~ ERROR: cannot call non-const fn `_print` in constant functions - self.req(); - } -} - -struct S; - -impl const Tr for S { - fn req(&self) {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr b/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr deleted file mode 100644 index 082c0333f..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-79450.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0015]: cannot call non-const fn `_print` in constant functions - --> $DIR/issue-79450.rs:9:9 - | -LL | println!("lul"); - | ^^^^^^^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `println` (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 E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-88155.rs b/tests/ui/rfc-2632-const-trait-impl/issue-88155.rs deleted file mode 100644 index b132c395a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-88155.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(const_trait_impl)] - -pub trait A { - fn assoc() -> bool; -} - -pub const fn foo() -> bool { - T::assoc() - //~^ ERROR the trait bound - //~| ERROR cannot call non-const fn -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-88155.stderr b/tests/ui/rfc-2632-const-trait-impl/issue-88155.stderr deleted file mode 100644 index 955923505..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-88155.stderr +++ /dev/null @@ -1,24 +0,0 @@ -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 - | -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 - -Some errors have detailed explanations: E0015, E0277. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-90052.rs b/tests/ui/rfc-2632-const-trait-impl/issue-90052.rs deleted file mode 100644 index 21ddf4ab4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-90052.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Bar {} - -fn foo() where T: ~const Bar {} -//~^ ERROR `~const` is not allowed - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-90052.stderr b/tests/ui/rfc-2632-const-trait-impl/issue-90052.stderr deleted file mode 100644 index b2a936537..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-90052.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: `~const` is not allowed here - --> $DIR/issue-90052.rs:6:22 - | -LL | fn foo() where T: ~const Bar {} - | ^^^^^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/issue-90052.rs:6:4 - | -LL | fn foo() where T: ~const Bar {} - | ^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-92111.rs b/tests/ui/rfc-2632-const-trait-impl/issue-92111.rs deleted file mode 100644 index 96a3e386e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-92111.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Regression test for #92111. -// -// check-pass - -#![feature(const_trait_impl)] - -use std::marker::Destruct; - -pub trait Tr {} - -#[allow(drop_bounds)] -impl Tr for T {} - -#[derive(Debug)] -pub struct S(i32); - -impl Tr for S {} - -const fn a(t: T) {} - -fn main() { - a(S(0)); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs b/tests/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs deleted file mode 100644 index 4d3469653..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Regression test for #92230. -// -// check-pass - -#![feature(const_trait_impl)] - -#[const_trait] -pub trait Super {} -#[const_trait] -pub trait Sub: Super {} - -impl const Super for &A where A: ~const Super {} -impl const Sub for &A where A: ~const Sub {} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs b/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs deleted file mode 100644 index 0b423b340..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -#![feature(const_trait_impl, lazy_cell)] - -use std::sync::LazyLock; - -static EXTERN_FLAGS: LazyLock = LazyLock::new(|| { - let x = || String::new(); - x() -}); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs b/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs deleted file mode 100644 index cd8bb5963..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(const_closures, const_trait_impl)] -#![allow(incomplete_features)] - -trait Foo { - fn foo(&self); -} - -impl Foo for () { - fn foo(&self) {} -} - -fn main() { - (const || { (()).foo() })(); - //~^ ERROR: cannot call non-const fn -} diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr b/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr deleted file mode 100644 index 979d7febb..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions - --> $DIR/non-const-op-const-closure-non-const-outer.rs:13:22 - | -LL | (const || { (()).foo() })(); - | ^^^^^ - | - = 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/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs b/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs deleted file mode 100644 index dff8a2444..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs +++ /dev/null @@ -1,18 +0,0 @@ -// known-bug: #110395 - -#![feature(const_trait_impl)] - -#[const_trait] -trait Convert { - fn to(self) -> T; -} - -impl const Convert for A where B: ~const From { - fn to(self) -> B { - B::from(self) - } -} - -const FOO: fn() -> String = || "foo".to(); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr b/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr deleted file mode 100644 index cfdda4713..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/non-const-op-in-closure-in-const.rs:10:51 - | -LL | impl const Convert for A where B: ~const From { - | ^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs deleted file mode 100644 index f31123f16..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs +++ /dev/null @@ -1,58 +0,0 @@ -// 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. - -#![feature(const_trait_impl)] -#![feature(rustc_attrs)] -#![feature(min_specialization)] - -#[rustc_specialization_trait] -trait Specialize {} - -#[const_trait] -trait Foo {} - -#[const_trait] -trait Bar { - fn bar(); -} - -// bgr360: I was only able to exercise the code path that raises the -// "missing ~const qualifier" error by making this base impl non-const, even -// though that doesn't really make sense to do. As seen below, if the base impl -// is made const, rustc fails earlier with an overlapping impl failure. -impl Bar for T -where - T: ~const Foo, -{ - default fn bar() {} -} - -impl Bar for T -where - T: Foo, //~ ERROR missing `~const` qualifier - T: Specialize, -{ - fn bar() {} -} - -#[const_trait] -trait Baz { - fn baz(); -} - -impl const Baz for T -where - T: ~const Foo, -{ - default fn baz() {} -} - -impl const Baz for T //~ ERROR conflicting implementations of trait `Baz` -where - T: Foo, - T: Specialize, -{ - fn baz() {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr deleted file mode 100644 index 057cf4aea..000000000 --- a/tests/ui/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/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs deleted file mode 100644 index 9ddea427c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Tests that a const default trait impl can be specialized by another const -// trait impl and that the specializing impl will be used during const-eval. - -// run-pass - -#![feature(const_trait_impl)] -#![feature(min_specialization)] - -#[const_trait] -trait Value { - fn value() -> u32; -} - -const fn get_value() -> u32 { - T::value() -} - -impl const Value for T { - default fn value() -> u32 { - 0 - } -} - -struct FortyTwo; - -impl const Value for FortyTwo { - fn value() -> u32 { - 42 - } -} - -const ZERO: u32 = get_value::<()>(); - -const FORTY_TWO: u32 = get_value::(); - -fn main() { - assert_eq!(ZERO, 0); - assert_eq!(FORTY_TWO, 42); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs deleted file mode 100644 index a3bb9b3f9..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Tests that specializing trait impls must be at least as const as the default impl. - -#![feature(const_trait_impl)] -#![feature(min_specialization)] - -#[const_trait] -trait Value { - fn value() -> u32; -} - -impl const Value for T { - default fn value() -> u32 { - 0 - } -} - -struct FortyTwo; - -impl Value for FortyTwo { //~ ERROR cannot specialize on const impl with non-const impl - fn value() -> u32 { - println!("You can't do that (constly)"); - 42 - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr b/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr deleted file mode 100644 index 247668047..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: cannot specialize on const impl with non-const impl - --> $DIR/const-default-impl-non-const-specialized-impl.rs:19:1 - | -LL | impl Value for FortyTwo { - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs deleted file mode 100644 index 2aac0a2b4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/default-keyword.rs +++ /dev/null @@ -1,15 +0,0 @@ -// check-pass - -#![feature(const_trait_impl)] -#![feature(min_specialization)] - -#[const_trait] -trait Foo { - fn foo(); -} - -impl const Foo for u32 { - default fn foo() {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs deleted file mode 100644 index 92d8be6bb..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Tests that `~const` trait bounds can be used to specialize const trait impls. - -// check-pass - -#![feature(const_trait_impl)] -#![feature(rustc_attrs)] -#![feature(min_specialization)] - -#[const_trait] -#[rustc_specialization_trait] -trait Specialize {} - -#[const_trait] -trait Foo { - fn foo(); -} - -impl const Foo for T { - default fn foo() {} -} - -impl const Foo for T -where - T: ~const Specialize, -{ - fn foo() {} -} - -#[const_trait] -trait Bar { - fn bar() {} -} - -impl const Bar for T -where - T: ~const Foo, -{ - default fn bar() {} -} - -impl const Bar for T -where - T: ~const Foo, - T: ~const Specialize, -{ - fn bar() {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs deleted file mode 100644 index 51bfaf73b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Tests that `T: ~const Foo` in a specializing impl is treated as equivalent to -// `T: Foo` in the default impl for the purposes of specialization (i.e., it -// does not think that the user is attempting to specialize on trait `Foo`). - -// check-pass - -#![feature(rustc_attrs)] -#![feature(min_specialization)] -#![feature(const_trait_impl)] - -#[rustc_specialization_trait] -trait Specialize {} - -#[const_trait] -trait Foo {} - -#[const_trait] -trait Bar { - fn bar(); -} - -impl Bar for T -where - T: Foo, -{ - default fn bar() {} -} - -impl const Bar for T -where - T: ~const Foo, - T: Specialize, -{ - fn bar() {} -} - -#[const_trait] -trait Baz { - fn baz(); -} - -impl const Baz for T -where - T: Foo, -{ - default fn baz() {} -} - -impl const Baz for T -where - T: ~const Foo, - T: Specialize, -{ - fn baz() {} -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs b/tests/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs deleted file mode 100644 index 35aa52fbd..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -// run-pass - -#![feature(const_trait_impl)] -#![feature(min_specialization)] - -#[const_trait] -trait Value { - fn value() -> u32; -} - -const fn get_value() -> u32 { - T::value() -} - -impl Value for T { - default fn value() -> u32 { - println!("You can't do that (constly)"); - 0 - } -} - -struct FortyTwo; - -impl const Value for FortyTwo { - fn value() -> u32 { - 42 - } -} - -fn main() { - let zero = get_value::<()>(); - assert_eq!(zero, 0); - - const FORTY_TWO: u32 = get_value::(); - assert_eq!(FORTY_TWO, 42); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.rs b/tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.rs deleted file mode 100644 index 633543700..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![feature(const_trait_impl, min_specialization, rustc_attrs)] - -#[rustc_specialization_trait] -#[const_trait] -pub trait Sup {} - -impl const Sup for () {} - -#[const_trait] -pub trait A { - fn a() -> u32; -} - -impl A for T { - default fn a() -> u32 { - 2 - } -} - -impl const A for T { - fn a() -> u32 { - 3 - } -} - -const fn generic() { - ::a(); - //~^ ERROR: the trait bound `T: ~const Sup` is not satisfied -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.stderr b/tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.stderr deleted file mode 100644 index 8923416f4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specializing-constness-2.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `T: ~const Sup` is not satisfied - --> $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() { - | ++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs b/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs deleted file mode 100644 index 5c2a3f801..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![feature(const_trait_impl, min_specialization, rustc_attrs)] - -#[rustc_specialization_trait] -#[const_trait] -pub trait Sup {} - -impl const Sup for () {} - -#[const_trait] -pub trait A { - fn a() -> u32; -} - -#[const_trait] -pub trait Spec {} - -impl const A for T { - default fn a() -> u32 { - 2 - } -} - -impl A for T { -//~^ ERROR: cannot specialize -//~| ERROR: missing `~const` qualifier - fn a() -> u32 { - 3 - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr b/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr deleted file mode 100644 index 1ffdc50e5..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/specializing-constness.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: cannot specialize on const impl with non-const impl - --> $DIR/specializing-constness.rs:23:1 - | -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 - diff --git a/tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.rs b/tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.rs deleted file mode 100644 index fc0d82727..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.rs +++ /dev/null @@ -1,16 +0,0 @@ -// aux-build: staged-api.rs -extern crate staged_api; - -use staged_api::*; - -// Const stability has no impact on usage in non-const contexts. -fn non_const_context() { - Unstable::func(); -} - -const fn stable_const_context() { - Unstable::func(); - //~^ ERROR cannot call non-const fn `::func` in constant functions -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.stderr b/tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.stderr deleted file mode 100644 index d7aa0d95c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/staged-api-user-crate.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0015]: cannot call non-const fn `::func` in constant functions - --> $DIR/staged-api-user-crate.rs:12:5 - | -LL | Unstable::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 - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/staged-api.rs b/tests/ui/rfc-2632-const-trait-impl/staged-api.rs deleted file mode 100644 index 1d79f5adf..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/staged-api.rs +++ /dev/null @@ -1,63 +0,0 @@ -// revisions: stable unstable - -#![cfg_attr(unstable, feature(unstable))] // The feature from the ./auxiliary/staged-api.rs file. -#![feature(const_trait_impl)] -#![feature(staged_api)] -#![stable(feature = "rust1", since = "1.0.0")] - -// aux-build: staged-api.rs -extern crate staged_api; - -use staged_api::*; - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Foo; - -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))] -#[cfg_attr(stable, rustc_const_stable(feature = "foo", since = "1.0.0"))] -impl const MyTrait for Foo { - //[stable]~^ ERROR trait implementations cannot be const stable yet - fn func() {} -} - -// Const stability has no impact on usage in non-const contexts. -fn non_const_context() { - Unstable::func(); - Foo::func(); -} - -#[unstable(feature = "none", issue = "none")] -const fn const_context() { - Unstable::func(); - // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is - // not const-stable. - Foo::func(); - //[unstable]~^ ERROR not yet stable as a const fn - // ^ fails, because the `foo` feature is not active -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))] -pub const fn const_context_not_const_stable() { - //[stable]~^ ERROR function has missing const stability attribute - Unstable::func(); - // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is - // not const-stable. - Foo::func(); - //[unstable]~^ ERROR not yet stable as a const fn - // ^ fails, because the `foo` feature is not active -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_stable(feature = "cheese", since = "1.0.0")] -const fn stable_const_context() { - Unstable::func(); - //[unstable]~^ ERROR not yet stable as a const fn - Foo::func(); - //[unstable]~^ ERROR not yet stable as a const fn - const_context_not_const_stable() - //[unstable]~^ ERROR not yet stable as a const fn -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/staged-api.stable.stderr b/tests/ui/rfc-2632-const-trait-impl/staged-api.stable.stderr deleted file mode 100644 index a1aca762e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/staged-api.stable.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: trait implementations cannot be const stable yet - --> $DIR/staged-api.rs:19:1 - | -LL | / impl const MyTrait for Foo { -LL | | -LL | | fn func() {} -LL | | } - | |_^ - | - = note: see issue #67792 for more information - -error: function has missing const stability attribute - --> $DIR/staged-api.rs:42:1 - | -LL | / pub const fn const_context_not_const_stable() { -LL | | -LL | | Unstable::func(); -LL | | // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is -... | -LL | | // ^ fails, because the `foo` feature is not active -LL | | } - | |_^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/staged-api.unstable.stderr b/tests/ui/rfc-2632-const-trait-impl/staged-api.unstable.stderr deleted file mode 100644 index c38d1a81a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/staged-api.unstable.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: `::func` is not yet stable as a const fn - --> $DIR/staged-api.rs:35:5 - | -LL | Foo::func(); - | ^^^^^^^^^^^ - | - = help: add `#![feature(foo)]` to the crate attributes to enable - -error: `::func` is not yet stable as a const fn - --> $DIR/staged-api.rs:47:5 - | -LL | Foo::func(); - | ^^^^^^^^^^^ - | - = help: add `#![feature(foo)]` to the crate attributes to enable - -error: `::func` is not yet stable as a const fn - --> $DIR/staged-api.rs:55:5 - | -LL | Unstable::func(); - | ^^^^^^^^^^^^^^^^ - | - = help: const-stable functions can only call other const-stable functions - -error: `::func` is not yet stable as a const fn - --> $DIR/staged-api.rs:57:5 - | -LL | Foo::func(); - | ^^^^^^^^^^^ - | - = help: const-stable functions can only call other const-stable functions - -error: `const_context_not_const_stable` is not yet stable as a const fn - --> $DIR/staged-api.rs:59:5 - | -LL | const_context_not_const_stable() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: const-stable functions can only call other const-stable functions - -error: aborting due to 5 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs b/tests/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs deleted file mode 100644 index 4520a3696..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/static-const-trait-bound.rs +++ /dev/null @@ -1,18 +0,0 @@ -// check-pass -pub struct S T = fn() -> T> { - f: F, - x: Option, -} - -impl T> S { - pub const fn new(f: F) -> Self { - Self { f, x: None } - } -} - -#[derive(Default)] -pub struct Foo; - -static LOCKED_CALLSITES: S = S::new(Default::default); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr deleted file mode 100644 index 78aab9469..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0635]: unknown feature `const_default_impls` - --> $DIR/std-impl-gate.rs:6:46 - | -LL | #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs deleted file mode 100644 index e9e5e0235..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This tests feature gates for const impls in the standard library. - -// revisions: stock gated -//[gated] known-bug: #110395 - -#![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] - -fn non_const_context() -> Vec { - Default::default() -} - -const fn const_context() -> Vec { - Default::default() - //[stock]~^ ERROR cannot call non-const fn -} - -fn main() { - const VAL: Vec = const_context(); - - assert_eq!(VAL, non_const_context()); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr deleted file mode 100644 index 6a3396401..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0015]: cannot call non-const fn ` as Default>::default` in constant functions - --> $DIR/std-impl-gate.rs:13:5 - | -LL | Default::default() - | ^^^^^^^^^^^^^^^^^^ - | - = 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 - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr deleted file mode 100644 index 97f346e8c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr deleted file mode 100644 index 97f346e8c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-2.rs:11:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs deleted file mode 100644 index ecb06271c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(const_trait_impl)] - -// revisions: yy yn ny nn - -#[cfg_attr(any(yy, yn), const_trait)] -trait Foo { - fn a(&self); -} - -#[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]` - -const fn foo(x: &T) { - x.a(); - //[yn,yy]~^ ERROR the trait bound -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr deleted file mode 100644 index c9fa19554..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied - --> $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) { - | ++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr deleted file mode 100644 index c9fa19554..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied - --> $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) { - | ++++++++++++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr deleted file mode 100644 index fdc6b8058..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:16:24 - | -LL | const fn foo(x: &T) { - | ^^^ - -error: aborting due to 3 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr deleted file mode 100644 index 7375b8c81..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:12:19 - | -LL | trait Bar: ~const Foo {} - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs deleted file mode 100644 index 8cf64944a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(const_trait_impl)] - -// revisions: yy yn ny nn -//[yy] check-pass - -#[cfg_attr(any(yy, yn), const_trait)] -trait Foo { - fn a(&self); -} - -#[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]` - -const fn foo(x: &T) { - //[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` - x.a(); -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr deleted file mode 100644 index 7a152914b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: ~const can only be applied to `#[const_trait]` traits - --> $DIR/super-traits-fail-3.rs:16:24 - | -LL | const fn foo(x: &T) { - | ^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.rs b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.rs deleted file mode 100644 index 3e2b81368..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Foo { - fn a(&self); -} -#[const_trait] -trait Bar: ~const Foo {} - -struct S; -impl Foo for S { - fn a(&self) {} -} - -impl const Bar for S {} -//~^ ERROR the trait bound - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/super-traits-fail.stderr deleted file mode 100644 index bf12ef1ca..000000000 --- a/tests/ui/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/rfc-2632-const-trait-impl/super-traits.rs b/tests/ui/rfc-2632-const-trait-impl/super-traits.rs deleted file mode 100644 index df96f6fb4..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/super-traits.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-pass -#![feature(const_trait_impl)] - -#[const_trait] -trait Foo { - fn a(&self); -} - -#[const_trait] -trait Bar: ~const Foo {} - -struct S; -impl const Foo for S { - fn a(&self) {} -} - -impl const Bar for S {} - -const fn foo(t: &T) { - t.a(); -} - -const _: () = foo(&S); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/syntax.rs b/tests/ui/rfc-2632-const-trait-impl/syntax.rs deleted file mode 100644 index 7ac2458e3..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/syntax.rs +++ /dev/null @@ -1,8 +0,0 @@ -// compile-flags: -Z parse-only -// check-pass - -#![feature(const_trait_bound_opt_out)] -#![feature(const_trait_impl)] - -// For now, this parses since an error does not occur until AST lowering. -impl ~const T {} diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs b/tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs deleted file mode 100644 index 78a64b901..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs +++ /dev/null @@ -1,34 +0,0 @@ -#![feature(const_trait_impl)] -#![feature(generic_arg_infer)] -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - -struct Foo; - -impl Foo { - fn add(self) -> Foo<{ A::add(N) }> { - Foo - } -} - -#[const_trait] -trait Add42 { - fn add(a: usize) -> usize; -} - -impl const Add42 for () { - fn add(a: usize) -> usize { - a + 42 - } -} - -fn bar(_: Foo) -> Foo<{ A::add(N) }> { - //~^ ERROR `~const` is not allowed here - Foo -} - -fn main() { - let foo = Foo::<0>; - let foo = bar::<(), _>(foo); - let _foo = bar::<(), _>(foo); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr b/tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr deleted file mode 100644 index aae72f36e..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: `~const` is not allowed here - --> $DIR/tilde-const-and-const-params.rs:25: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 - | -LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { - | ^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs b/tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs deleted file mode 100644 index 95f7aaba0..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(const_trait_impl)] -#![feature(associated_type_bounds)] - -struct TildeQuestion(std::marker::PhantomData); -//~^ ERROR `~const` and `?` are mutually exclusive - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr b/tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr deleted file mode 100644 index d20f146df..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: `~const` and `?` are mutually exclusive - --> $DIR/tilde-const-invalid-places.rs:4:25 - | -LL | struct TildeQuestion(std::marker::PhantomData); - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs b/tests/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs deleted file mode 100644 index 9b3c2cf2a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: -Z parse-only -// check-pass - -#![feature(const_trait_impl)] - -struct S< - T: ~const ?for<'a> Tr<'a> + 'static + ~const std::ops::Add, - T: ~const ?for<'a: 'b> m::Trait<'a>, ->; diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-twice.rs b/tests/ui/rfc-2632-const-trait-impl/tilde-twice.rs deleted file mode 100644 index 06e4ede8b..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-twice.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags: -Z parse-only - -#![feature(const_trait_impl)] - -struct S; -//~^ ERROR expected identifier, found `~` diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde-twice.stderr b/tests/ui/rfc-2632-const-trait-impl/tilde-twice.stderr deleted file mode 100644 index 928d23e8a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde-twice.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected identifier, found `~` - --> $DIR/tilde-twice.rs:5:20 - | -LL | struct S; - | ^ expected identifier - -error: aborting due to previous error - diff --git a/tests/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs b/tests/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs deleted file mode 100644 index 285cef571..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass -#![feature(const_trait_impl)] - -#[const_trait] -trait Foo { - fn foo(&self) {} -} - -struct Bar(T); - -impl Bar { - const fn foo(&self) { - self.0.foo() - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs b/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs deleted file mode 100644 index 8d56295e7..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.rs +++ /dev/null @@ -1,50 +0,0 @@ -// known-bug: #110395 - -#![feature(staged_api)] -#![feature(const_trait_impl)] -#![feature(const_t_try)] -#![feature(const_try)] -#![feature(try_trait_v2)] - -#![stable(feature = "foo", since = "1.0")] - -use std::ops::{ControlFlow, FromResidual, Try}; - -#[stable(feature = "foo", since = "1.0")] -pub struct T; - -#[stable(feature = "foo", since = "1.0")] -#[rustc_const_unstable(feature = "const_t_try", issue = "none")] -impl const Try for T { - type Output = T; - type Residual = T; - - fn from_output(t: T) -> T { - t - } - - fn branch(self) -> ControlFlow { - ControlFlow::Continue(self) - } -} - -#[stable(feature = "foo", since = "1.0")] -#[rustc_const_unstable(feature = "const_t_try", issue = "none")] -impl const FromResidual for T { - fn from_residual(t: T) -> T { - t - } -} - -#[stable(feature = "foo", since = "1.0")] -#[const_trait] -pub trait Tr { - #[stable(feature = "foo", since = "1.0")] - fn bar() -> T { - T? - // Should be allowed. - // Must enable unstable features to call this trait fn in const contexts. - } -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr b/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr deleted file mode 100644 index 35dc1ca12..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-default-body-stability.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: const `impl` for trait `Try` which is not marked with `#[const_trait]` - --> $DIR/trait-default-body-stability.rs:18:12 - | -LL | impl const Try for T { - | ^^^ - | - = 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 `FromResidual` which is not marked with `#[const_trait]` - --> $DIR/trait-default-body-stability.rs:33:12 - | -LL | impl const FromResidual for T { - | ^^^^^^^^^^^^ - | - = 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 2 previous errors - diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs b/tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs deleted file mode 100644 index 7d7cb967c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs +++ /dev/null @@ -1,23 +0,0 @@ -// check-pass - -struct LazyLock { - data: (Option, fn() -> T), -} - -impl LazyLock { - pub const fn new(f: fn() -> T) -> LazyLock { - LazyLock { data: (None, f) } - } -} - -struct A(Option); - -impl Default for A { - fn default() -> Self { - A(None) - } -} - -static EMPTY_SET: LazyLock> = LazyLock::new(A::default); - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs b/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs deleted file mode 100644 index bfe98b98c..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Like trait-where-clause.rs, but we are calling from a const context. -// 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)] - -#[const_trait] -trait Bar {} - -#[const_trait] -trait Foo { - fn a(); - fn b() where Self: ~const Bar; - fn c(); -} - -const fn test1() { - T::a(); - T::b(); - //~^ ERROR the trait bound - T::c::(); - //~^ ERROR the trait bound -} - -const fn test2() { - T::a(); - T::b(); - T::c::(); -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr b/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr deleted file mode 100644 index f2846b6a6..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-const.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:19:5 - | -LL | T::b(); - | ^^^^^^ the trait `~const 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 - | -LL | T::b(); - | ^^^^^^ -help: consider further restricting this bound - | -LL | const fn test1() { - | ++++++++++++ - -error[E0277]: the trait bound `T: ~const Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:21:5 - | -LL | T::c::(); - | ^^^^^^^^^^^ the trait `~const 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 - | -LL | T::c::(); - | ^^^^^^^^^^^ -help: consider further restricting this bound - | -LL | const fn test1() { - | ++++++++++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs b/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs deleted file mode 100644 index 4b8b00406..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs +++ /dev/null @@ -1,41 +0,0 @@ -// run-pass - -#![feature(const_trait_impl)] - -#[const_trait] -trait Bar { - fn bar() -> u8; -} - -#[const_trait] -trait Foo { - fn foo() -> u8 where Self: ~const Bar { - ::bar() * 6 - } -} - -struct NonConst; -struct Const; - -impl Bar for NonConst { - fn bar() -> u8 { - 3 - } -} - -impl Foo for NonConst {} - -impl const Bar for Const { - fn bar() -> u8 { - 4 - } -} - -impl const Foo for Const {} - -fn main() { - const ANS1: u8 = Const::foo(); - let ans2 = NonConst::foo(); - - assert_eq!(ANS1 + ans2, 42); -} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs b/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs deleted file mode 100644 index 3b028ac48..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs +++ /dev/null @@ -1,24 +0,0 @@ -// check-pass - -#![feature(const_trait_impl)] - -#[const_trait] -trait Foo { - fn bar() where Self: ~const Foo; -} - -struct S; - -impl Foo for S { - fn bar() {} -} - -fn baz() { - T::bar(); -} - -const fn qux() { - T::bar(); -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause.rs b/tests/ui/rfc-2632-const-trait-impl/trait-where-clause.rs deleted file mode 100644 index 85ca5fc90..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Bar {} - -trait Foo { - fn a(); - fn b() where Self: ~const Bar; - fn c(); -} - -fn test1() { - T::a(); - T::b(); - //~^ ERROR the trait bound - T::c::(); - //~^ ERROR the trait bound -} - -fn test2() { - T::a(); - T::b(); - T::c::(); -} - -fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr b/tests/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr deleted file mode 100644 index 11f0c4016..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/trait-where-clause.rs:14:5 - | -LL | T::b(); - | ^^^^ the trait `Bar` is not implemented for `T` - | -note: required by a bound in `Foo::b` - --> $DIR/trait-where-clause.rs:8:24 - | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` -help: consider further restricting this bound - | -LL | fn test1() { - | +++++ - -error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/trait-where-clause.rs:16:12 - | -LL | T::c::(); - | ^ the trait `Bar` is not implemented for `T` - | -note: required by a bound in `Foo::c` - --> $DIR/trait-where-clause.rs:9:13 - | -LL | fn c(); - | ^^^^^^^^^^ required by this bound in `Foo::c` -help: consider further restricting this bound - | -LL | fn test1() { - | +++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/without-tilde.rs b/tests/ui/rfc-2632-const-trait-impl/without-tilde.rs deleted file mode 100644 index d63381b5f..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/without-tilde.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags: -Z parse-only - -#![feature(const_trait_impl)] - -struct S; -//~^ ERROR const bounds must start with `~` diff --git a/tests/ui/rfc-2632-const-trait-impl/without-tilde.stderr b/tests/ui/rfc-2632-const-trait-impl/without-tilde.stderr deleted file mode 100644 index 31300354a..000000000 --- a/tests/ui/rfc-2632-const-trait-impl/without-tilde.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: const bounds must start with `~` - --> $DIR/without-tilde.rs:5:13 - | -LL | struct S; - | -^^^^ - | | - | help: add `~`: `~` - -error: aborting due to previous error - diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs new file mode 100644 index 000000000..1e086160f --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs @@ -0,0 +1,19 @@ +// Adaptation of existing ui test (from way back in +// rust-lang/rust#2329), that starts passing with this feature in +// place. + +// run-pass + +use std::sync::mpsc::channel; + +fn main() { + let (tx, rx) = channel(); + let x = Some(rx); + tx.send(false).unwrap(); + tx.send(false).unwrap(); + match x { + Some(z) if z.recv().unwrap() => { panic!() }, + Some(z) => { assert!(!z.recv().unwrap()); }, + None => panic!() + } +} diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs new file mode 100644 index 000000000..3161d6fbb --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/former-E0008-now-pass.rs @@ -0,0 +1,11 @@ +// This test used to emit E0008 but now passed since `bind_by_move_pattern_guards` +// have been stabilized. + +// check-pass + +fn main() { + match Some("hi".to_string()) { + Some(s) if s.len() == 0 => {}, + _ => {}, + } +} diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs new file mode 100644 index 000000000..b716fc870 --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs @@ -0,0 +1,43 @@ +// run-pass + +struct A { a: Box } + +impl A { + fn get(&self) -> i32 { *self.a } +} + +fn foo(n: i32) -> i32 { + let x = A { a: Box::new(n) }; + let y = match x { + A { a: v } if *v == 42 => v, + _ => Box::new(0), + }; + *y +} + +fn bar(n: i32) -> i32 { + let x = A { a: Box::new(n) }; + let y = match x { + A { a: v } if x.get() == 42 => v, + _ => Box::new(0), + }; + *y +} + +fn baz(n: i32) -> i32 { + let x = A { a: Box::new(n) }; + let y = match x { + A { a: v } if *v.clone() == 42 => v, + _ => Box::new(0), + }; + *y +} + +fn main() { + assert_eq!(foo(107), 0); + assert_eq!(foo(42), 42); + assert_eq!(bar(107), 0); + assert_eq!(bar(42), 42); + assert_eq!(baz(107), 0); + assert_eq!(baz(42), 42); +} diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs new file mode 100644 index 000000000..6f0d2b045 --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs @@ -0,0 +1,24 @@ +#![feature(if_let_guard)] + +enum VecWrapper { A(Vec) } + +fn if_guard(x: VecWrapper) -> usize { + match x { + VecWrapper::A(v) if { drop(v); false } => 1, + //~^ ERROR cannot move out of `v` in pattern guard + VecWrapper::A(v) => v.len() + } +} + +fn if_let_guard(x: VecWrapper) -> usize { + match x { + VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, + //~^ ERROR cannot move out of `v` in pattern guard + VecWrapper::A(v) => v.len() + } +} + +fn main() { + if_guard(VecWrapper::A(vec![107])); + if_let_guard(VecWrapper::A(vec![107])); +} diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr new file mode 100644 index 000000000..a749361bf --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr @@ -0,0 +1,19 @@ +error[E0507]: cannot move out of `v` in pattern guard + --> $DIR/rfc-reject-double-move-across-arms.rs:7:36 + | +LL | VecWrapper::A(v) if { drop(v); false } => 1, + | ^ move occurs because `v` has type `Vec`, which does not implement the `Copy` trait + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error[E0507]: cannot move out of `v` in pattern guard + --> $DIR/rfc-reject-double-move-across-arms.rs:15:51 + | +LL | VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, + | ^ move occurs because `v` has type `Vec`, which does not implement the `Copy` trait + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs new file mode 100644 index 000000000..827335f6a --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs @@ -0,0 +1,26 @@ +#![feature(if_let_guard)] + +struct A { a: Box } + +fn if_guard(n: i32) { + let x = A { a: Box::new(n) }; + let _y = match x { + A { a: v } if { drop(v); true } => v, + //~^ ERROR cannot move out of `v` in pattern guard + _ => Box::new(0), + }; +} + +fn if_let_guard(n: i32) { + let x = A { a: Box::new(n) }; + let _y = match x { + A { a: v } if let Some(()) = { drop(v); Some(()) } => v, + //~^ ERROR cannot move out of `v` in pattern guard + _ => Box::new(0), + }; +} + +fn main() { + if_guard(107); + if_let_guard(107); +} diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr new file mode 100644 index 000000000..9285492b2 --- /dev/null +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr @@ -0,0 +1,19 @@ +error[E0507]: cannot move out of `v` in pattern guard + --> $DIR/rfc-reject-double-move-in-first-arm.rs:8:30 + | +LL | A { a: v } if { drop(v); true } => v, + | ^ move occurs because `v` has type `Box`, which does not implement the `Copy` trait + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error[E0507]: cannot move out of `v` in pattern guard + --> $DIR/rfc-reject-double-move-in-first-arm.rs:17:45 + | +LL | A { a: v } if let Some(()) = { drop(v); Some(()) } => v, + | ^ move occurs because `v` has type `Box`, which does not implement the `Copy` trait + | + = note: variables bound in patterns cannot be moved from until after the end of the pattern guard + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/rfcs/rfc-1014-2.rs b/tests/ui/rfcs/rfc-1014-2.rs deleted file mode 100644 index 7dd65701f..000000000 --- a/tests/ui/rfcs/rfc-1014-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -// run-pass -#![allow(dead_code)] - -#![feature(rustc_private)] - -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; -type BOOL = i32; - -#[cfg(windows)] -extern "system" { - fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; -} - -#[cfg(windows)] -fn close_stdout() { - const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; - unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } -} - -#[cfg(windows)] -fn main() { - close_stdout(); - println!("hello"); - println!("world"); -} - -#[cfg(not(windows))] -fn main() {} diff --git a/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs new file mode 100644 index 000000000..7dd65701f --- /dev/null +++ b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs @@ -0,0 +1,31 @@ +// run-pass +#![allow(dead_code)] + +#![feature(rustc_private)] + +extern crate libc; + +type DWORD = u32; +type HANDLE = *mut u8; +type BOOL = i32; + +#[cfg(windows)] +extern "system" { + fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; +} + +#[cfg(windows)] +fn close_stdout() { + const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; + unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } +} + +#[cfg(windows)] +fn main() { + close_stdout(); + println!("hello"); + println!("world"); +} + +#[cfg(not(windows))] +fn main() {} diff --git a/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs new file mode 100644 index 000000000..c454dfa4e --- /dev/null +++ b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs @@ -0,0 +1,34 @@ +// run-pass +#![allow(dead_code)] +// ignore-wasm32-bare no libc +// ignore-sgx no libc + +#![feature(rustc_private)] + +extern crate libc; + +type DWORD = u32; +type HANDLE = *mut u8; + +#[cfg(windows)] +extern "system" { + fn GetStdHandle(which: DWORD) -> HANDLE; + fn CloseHandle(handle: HANDLE) -> i32; +} + +#[cfg(windows)] +fn close_stdout() { + const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; + unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } +} + +#[cfg(not(windows))] +fn close_stdout() { + unsafe { libc::close(1); } +} + +fn main() { + close_stdout(); + println!("hello"); + println!("world"); +} diff --git a/tests/ui/rfcs/rfc-1014.rs b/tests/ui/rfcs/rfc-1014.rs deleted file mode 100644 index c454dfa4e..000000000 --- a/tests/ui/rfcs/rfc-1014.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass -#![allow(dead_code)] -// ignore-wasm32-bare no libc -// ignore-sgx no libc - -#![feature(rustc_private)] - -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; - -#[cfg(windows)] -extern "system" { - fn GetStdHandle(which: DWORD) -> HANDLE; - fn CloseHandle(handle: HANDLE) -> i32; -} - -#[cfg(windows)] -fn close_stdout() { - const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; - unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } -} - -#[cfg(not(windows))] -fn close_stdout() { - unsafe { libc::close(1); } -} - -fn main() { - close_stdout(); - println!("hello"); - println!("world"); -} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs new file mode 100644 index 000000000..1914e1554 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs @@ -0,0 +1,26 @@ +// Test explores how `#[structral_match]` behaves in tandem with +// `*const` and `*mut` pointers. + +// run-pass + +#![warn(pointer_structural_match)] + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive +// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapEmbedded(*const NoDerive); + +const WRAP_UNSAFE_EMBEDDED: WrapEmbedded = WrapEmbedded(std::ptr::null()); + +fn main() { + match WRAP_UNSAFE_EMBEDDED { + WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); } + _ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs new file mode 100644 index 000000000..e713b003b --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs @@ -0,0 +1,26 @@ +// Test explores how `#[structral_match]` behaves in tandem with +// `*const` and `*mut` pointers. + +// run-pass + +#![warn(pointer_structural_match)] + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive +// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapParam(*const X); + +const WRAP_UNSAFE_PARAM: WrapParam = WrapParam(std::ptr::null()); + +fn main() { + match WRAP_UNSAFE_PARAM { + WRAP_UNSAFE_PARAM => { println!("WRAP_UNSAFE_PARAM correctly matched itself"); } + _ => { panic!("WRAP_UNSAFE_PARAM did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs new file mode 100644 index 000000000..04da14c54 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs @@ -0,0 +1,26 @@ +// Test explores how `#[structral_match]` behaves in tandem with +// `*const` and `*mut` pointers. + +// run-pass + +#![warn(pointer_structural_match)] + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive +// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapEmbedded(*const NoDerive); + +const WRAP_UNSAFE_EMBEDDED: & &WrapEmbedded = & &WrapEmbedded(std::ptr::null()); + +fn main() { + match WRAP_UNSAFE_EMBEDDED { + WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); } + _ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs new file mode 100644 index 000000000..8313c25e7 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs @@ -0,0 +1,26 @@ +// Test explores how `#[structral_match]` behaves in tandem with +// `*const` and `*mut` pointers. + +// run-pass + +#![warn(pointer_structural_match)] + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive +// (which doesn't matter here because `<*const T>::eq` won't recur on `T`). +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapParam(*const X); + +const WRAP_UNSAFE_PARAM: & &WrapParam = & &WrapParam(std::ptr::null()); + +fn main() { + match WRAP_UNSAFE_PARAM { + WRAP_UNSAFE_PARAM => { println!("WRAP_UNSAFE_PARAM correctly matched itself"); } + _ => { panic!("WRAP_UNSAFE_PARAM did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs new file mode 100644 index 000000000..dca8aaef1 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-use-behind-cousin-variant.rs @@ -0,0 +1,59 @@ +// rust-lang/rust#62614: we want to allow matching on constants of types that +// have non-structural-match variants, *if* the constant itself does not use +// any such variant. + +// NOTE: for now, deliberately leaving the lint `indirect_structural_match` set +// to its default, so that we will not issue a diangostic even if +// rust-lang/rust#62614 remains an open issue. + +// run-pass + +struct Sum(u32, u32); + +impl PartialEq for Sum { + fn eq(&self, other: &Self) -> bool { self.0 + self.1 == other.0 + other.1 } +} + +impl Eq for Sum { } + +#[derive(PartialEq, Eq)] +enum Eek { + TheConst, + UnusedByTheConst(Sum) +} + +const THE_CONST: Eek = Eek::TheConst; +const SUM_THREE: Eek = Eek::UnusedByTheConst(Sum(3,0)); + +const EEK_ZERO: &[Eek] = &[]; +const EEK_ONE: &[Eek] = &[THE_CONST]; + +pub fn main() { + match Eek::UnusedByTheConst(Sum(1,2)) { + ref sum if sum == &SUM_THREE => { println!("Hello 0"); } + _ => { println!("Gbye"); } + } + + match Eek::TheConst { + THE_CONST => { println!("Hello 1"); } + _ => { println!("Gbye"); } + } + + + match & &Eek::TheConst { + & & THE_CONST => { println!("Hello 2"); } + _ => { println!("Gbye"); } + } + + match & & &[][..] { + & & EEK_ZERO => { println!("Hello 3"); } + & & EEK_ONE => { println!("Gbye"); } + _ => { println!("Gbye"); } + } + + match & & &[Eek::TheConst][..] { + & & EEK_ZERO => { println!("Gby"); } + & & EEK_ONE => { println!("Hello 4"); } + _ => { println!("Gbye"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs new file mode 100644 index 000000000..7623839fd --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs @@ -0,0 +1,26 @@ +// This is part of a set of tests exploring the different ways a +// structural-match ADT might try to hold a +// non-structural-match in hidden manner that lets matches +// through that we had intended to reject. +// +// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive. +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapInline(NoDerive); + +const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0)); + +fn main() { + match WRAP_DIRECT_INLINE { + WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => { println!("WRAP_DIRECT_INLINE did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr new file mode 100644 index 000000000..f08ba522a --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9 + | +LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } + | ^^^^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs new file mode 100644 index 000000000..93022a23d --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.rs @@ -0,0 +1,26 @@ +// This is part of a set of tests exploring the different ways a +// structural-match ADT might try to hold a +// non-structural-match in hidden manner that lets matches +// through that we had intended to reject. +// +// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 +#![warn(indirect_structural_match)] +struct NoDerive(i32); + +// This impl makes NoDerive irreflexive. +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapParam(T); + +const WRAP_DIRECT_PARAM: WrapParam = WrapParam(NoDerive(0)); + +fn main() { + match WRAP_DIRECT_PARAM { + WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => { println!("WRAP_DIRECT_PARAM did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr new file mode 100644 index 000000000..012ccab17 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/cant-hide-behind-direct-struct-param.rs:22:9 + | +LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } + | ^^^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs new file mode 100644 index 000000000..894739ff7 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs @@ -0,0 +1,29 @@ +// This is part of a set of tests exploring the different ways a +// structural-match ADT might try to hold a +// non-structural-match in hidden manner that lets matches +// through that we had intended to reject. +// +// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 +#![warn(indirect_structural_match)] +// run-pass + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive. +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapInline<'a>(&'a &'a NoDerive); + +const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)); + +fn main() { + match WRAP_DOUBLY_INDIRECT_INLINE { + WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } + //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted + _ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr new file mode 100644 index 000000000..94ee2216e --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr @@ -0,0 +1,18 @@ +warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:24:9 + | +LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #62411 + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details +note: the lint level is defined here + --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:7:9 + | +LL | #![warn(indirect_structural_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs new file mode 100644 index 000000000..1699dae46 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs @@ -0,0 +1,29 @@ +// This is part of a set of tests exploring the different ways a +// structural-match ADT might try to hold a +// non-structural-match in hidden manner that lets matches +// through that we had intended to reject. +// +// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 +#![warn(indirect_structural_match)] +// run-pass + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive. +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapParam<'a, T>(&'a &'a T); + +const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam = & &WrapParam(& & NoDerive(0)); + +fn main() { + match WRAP_DOUBLY_INDIRECT_PARAM { + WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } + //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted + _ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr new file mode 100644 index 000000000..666b7b95e --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr @@ -0,0 +1,18 @@ +warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/cant-hide-behind-doubly-indirect-param.rs:24:9 + | +LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 #62411 + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details +note: the lint level is defined here + --> $DIR/cant-hide-behind-doubly-indirect-param.rs:7:9 + | +LL | #![warn(indirect_structural_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs new file mode 100644 index 000000000..2672bdd9e --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs @@ -0,0 +1,29 @@ +// This is part of a set of tests exploring the different ways a +// structural-match ADT might try to hold a +// non-structural-match in hidden manner that lets matches +// through that we had intended to reject. +// +// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 +#![warn(indirect_structural_match)] +// run-pass + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive. +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapInline(NoDerive); + +const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0)); + +fn main() { + match WRAP_INDIRECT_INLINE { + WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } + //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted + _ => { println!("WRAP_INDIRECT_INLINE did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr new file mode 100644 index 000000000..ecbe83f3d --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr @@ -0,0 +1,18 @@ +warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:24:9 + | +LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); } + | ^^^^^^^^^^^^^^^^^^^^ + | + = 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 #62411 + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details +note: the lint level is defined here + --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:7:9 + | +LL | #![warn(indirect_structural_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs new file mode 100644 index 000000000..3489995ae --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs @@ -0,0 +1,29 @@ +// This is part of a set of tests exploring the different ways a +// structural-match ADT might try to hold a +// non-structural-match in hidden manner that lets matches +// through that we had intended to reject. +// +// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 +#![warn(indirect_structural_match)] +// run-pass + +struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); + +// This impl makes NoDerive irreflexive. +impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } + +impl Eq for NoDerive { } + +#[derive(PartialEq, Eq)] +struct WrapParam(T); + +const WRAP_INDIRECT_PARAM: & &WrapParam = & &WrapParam(NoDerive(0)); + +fn main() { + match WRAP_INDIRECT_PARAM { + WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } + //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted + _ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr new file mode 100644 index 000000000..211990801 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr @@ -0,0 +1,18 @@ +warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/cant-hide-behind-indirect-struct-param.rs:24:9 + | +LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); } + | ^^^^^^^^^^^^^^^^^^^ + | + = 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 #62411 + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details +note: the lint level is defined here + --> $DIR/cant-hide-behind-indirect-struct-param.rs:7:9 + | +LL | #![warn(indirect_structural_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr new file mode 100644 index 000000000..bd2940479 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.no_gate.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'structural_match' + --> $DIR/feature-gate.rs:29:6 + | +LL | impl std::marker::StructuralPartialEq for Foo { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #31434 for more information + = help: add `#![feature(structural_match)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'structural_match' + --> $DIR/feature-gate.rs:31:6 + | +LL | impl std::marker::StructuralEq for Foo { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #31434 for more information + = help: add `#![feature(structural_match)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.rs new file mode 100644 index 000000000..ee6674097 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.rs @@ -0,0 +1,39 @@ +// Test that use of structural-match traits is only permitted with a feature gate, +// and that if a feature gate is supplied, it permits the type to be +// used in a match. + +// revisions: with_gate no_gate + +// gate-test-structural_match + +#![allow(unused)] +#![feature(rustc_attrs)] +#![cfg_attr(with_gate, feature(structural_match))] + + +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +#[rustc_error] +fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error] + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} + +impl std::marker::StructuralPartialEq for Foo { } +//[no_gate]~^ ERROR use of unstable library feature 'structural_match' +impl std::marker::StructuralEq for Foo { } +//[no_gate]~^ ERROR use of unstable library feature 'structural_match' + +impl PartialEq for Foo { + fn eq(&self, other: &Self) -> bool { + self.x == other.x + } +} +impl Eq for Foo { } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr new file mode 100644 index 000000000..623fd585a --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/feature-gate.with_gate.stderr @@ -0,0 +1,8 @@ +error: fatal error triggered by #[rustc_error] + --> $DIR/feature-gate.rs:21:1 + | +LL | fn main() { + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs new file mode 100644 index 000000000..2b3fbd2a4 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/fn-ptr-is-structurally-matchable.rs @@ -0,0 +1,135 @@ +// run-pass + +// This file checks that fn ptrs are considered structurally matchable. +// See also rust-lang/rust#63479. + +fn main() { + let mut count = 0; + + // A type which is not structurally matchable: + struct NotSM; + + // And one that is: + #[derive(PartialEq, Eq)] + struct SM; + + fn trivial() {} + + fn sm_to(_: SM) {} + fn not_sm_to(_: NotSM) {} + fn to_sm() -> SM { SM } + fn to_not_sm() -> NotSM { NotSM } + + // To recreate the scenario of interest in #63479, we need to add + // a ref-level-of-indirection so that we descend into the type. + + fn r_sm_to(_: &SM) {} + fn r_not_sm_to(_: &NotSM) {} + fn r_to_r_sm(_: &()) -> &SM { &SM } + fn r_to_r_not_sm(_: &()) -> &NotSM { &NotSM } + + #[derive(PartialEq, Eq)] + struct Wrap(T); + + // In the code below, we put the match input into a local so that + // we can assign it an explicit type that is an fn ptr instead of + // a singleton type of the fn itself that the type inference would + // otherwise assign. + + // Check that fn() is structural-match + const CFN1: Wrap = Wrap(trivial); + let input: Wrap = Wrap(trivial); + match Wrap(input) { + Wrap(CFN1) => count += 1, + Wrap(_) => {} + }; + + // Check that fn(T) is structural-match when T is too. + const CFN2: Wrap = Wrap(sm_to); + let input: Wrap = Wrap(sm_to); + match Wrap(input) { + Wrap(CFN2) => count += 1, + Wrap(_) => {} + }; + + // Check that fn() -> T is structural-match when T is too. + const CFN3: Wrap SM> = Wrap(to_sm); + let input: Wrap SM> = Wrap(to_sm); + match Wrap(input) { + Wrap(CFN3) => count += 1, + Wrap(_) => {} + }; + + // Check that fn(T) is structural-match even if T is not. + const CFN4: Wrap = Wrap(not_sm_to); + let input: Wrap = Wrap(not_sm_to); + match Wrap(input) { + Wrap(CFN4) => count += 1, + Wrap(_) => {} + }; + + // Check that fn() -> T is structural-match even if T is not. + const CFN5: Wrap NotSM> = Wrap(to_not_sm); + let input: Wrap NotSM> = Wrap(to_not_sm); + match Wrap(input) { + Wrap(CFN5) => count += 1, + Wrap(_) => {} + }; + + // Check that fn(&T) is structural-match when T is too. + const CFN6: Wrap = Wrap(r_sm_to); + let input: Wrap = Wrap(r_sm_to); + match Wrap(input) { + Wrap(CFN6) => count += 1, + Wrap(_) => {} + }; + + // Check that fn() -> &T is structural-match when T is too. + const CFN7: Wrap &SM> = Wrap(r_to_r_sm); + let input: Wrap &SM> = Wrap(r_to_r_sm); + match Wrap(input) { + Wrap(CFN7) => count += 1, + Wrap(_) => {} + }; + + // Check that fn(T) is structural-match even if T is not. + const CFN8: Wrap = Wrap(r_not_sm_to); + let input: Wrap = Wrap(r_not_sm_to); + match Wrap(input) { + Wrap(CFN8) => count += 1, + Wrap(_) => {} + }; + + // Check that fn() -> T is structural-match even if T is not. + const CFN9: Wrap &NotSM> = Wrap(r_to_r_not_sm); + let input: Wrap &NotSM> = Wrap(r_to_r_not_sm); + match Wrap(input) { + Wrap(CFN9) => count += 1, + Wrap(_) => {} + }; + + // Check that a type which has fn ptrs is structural-match. + #[derive(PartialEq, Eq)] + struct Foo { + alpha: fn(NotSM), + beta: fn() -> NotSM, + gamma: fn(SM), + delta: fn() -> SM, + } + + const CFOO: Foo = Foo { + alpha: not_sm_to, + beta: to_not_sm, + gamma: sm_to, + delta: to_sm, + }; + + let input = Foo { alpha: not_sm_to, beta: to_not_sm, gamma: sm_to, delta: to_sm }; + match input { + CFOO => count += 1, + Foo { .. } => {} + }; + + // Final count must be 10 now if all + assert_eq!(count, 10); +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs new file mode 100644 index 000000000..2a915d61e --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.rs @@ -0,0 +1,19 @@ +// Issue 61188 pointed out a case where we hit an ICE during code gen: +// the compiler assumed that `PartialEq` was always implemented on any +// use of a `const` item in a pattern context, but the pre-existing +// structural-match checking was too shallow +// (see rust-lang/rust#62307), and so we hit cases where we were +// trying to dispatch to `PartialEq` on types that did not implement +// that trait. + +struct B(i32); + +const A: &[B] = &[]; + +pub fn main() { + match &[][..] { + A => (), + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => (), + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr new file mode 100644 index 000000000..46600e7b2 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9 + | +LL | A => (), + | ^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs new file mode 100644 index 000000000..46d8ee3b6 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.rs @@ -0,0 +1,43 @@ +// RFC 1445 introduced `#[structural_match]`; this attribute must +// appear on the `struct`/`enum` definition for any `const` used in a +// pattern. +// +// This is our (forever-unstable) way to mark a datatype as having a +// `PartialEq` implementation that is equivalent to recursion over its +// substructure. This avoids (at least in the short term) any need to +// resolve the question of what semantics is used for such matching. +// (See RFC 1445 for more details and discussion.) + +// Issue 62307 pointed out a case where the structural-match checking +// was too shallow. +#![warn(indirect_structural_match, nontrivial_structural_match)] +// run-pass + +#[derive(Debug)] +struct B(i32); + +// Overriding `PartialEq` to use this strange notion of "equality" exposes +// whether `match` is using structural-equality or method-dispatch +// under the hood, which is the antithesis of rust-lang/rfcs#1445 +impl PartialEq for B { + fn eq(&self, other: &B) -> bool { std::cmp::min(self.0, other.0) == 0 } +} + +fn main() { + const RR_B0: & & B = & & B(0); + const RR_B1: & & B = & & B(1); + + match RR_B0 { + RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } + //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted + _ => { } + } + + match RR_B1 { + RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } + //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARN this was previously accepted + _ => { } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr new file mode 100644 index 000000000..435812306 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr @@ -0,0 +1,29 @@ +warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:31:9 + | +LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); } + | ^^^^^ + | + = 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 #62411 + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details +note: the lint level is defined here + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9 + | +LL | #![warn(indirect_structural_match, nontrivial_structural_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:38:9 + | +LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); } + | ^^^^^ + | + = 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 #62411 + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +warning: 2 warnings emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs new file mode 100644 index 000000000..567685950 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.rs @@ -0,0 +1,40 @@ +// run-pass + +// The actual regression test from #63479. (Including this because my +// first draft at fn-ptr-is-structurally-matchable.rs failed to actually +// cover the case this hit; I've since expanded it accordingly, but the +// experience left me wary of leaving this regression test out.) + +#![warn(pointer_structural_match)] + +#[derive(Eq)] +struct A { + a: i64 +} + +impl PartialEq for A { + #[inline] + fn eq(&self, other: &Self) -> bool { + self.a.eq(&other.a) + } +} + +type Fn = fn(&[A]); + +fn my_fn(_args: &[A]) { + println!("hello world"); +} + +const TEST: Fn = my_fn; + +struct B(Fn); + +fn main() { + let s = B(my_fn); + match s { + B(TEST) => println!("matched"), + //~^ WARN pointers in patterns behave unpredictably + //~| WARN this was previously accepted by the compiler but is being phased out + _ => panic!("didn't match") + }; +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr new file mode 100644 index 000000000..d6afc0255 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-63479-match-fnptr.stderr @@ -0,0 +1,16 @@ +warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. + --> $DIR/issue-63479-match-fnptr.rs:35:7 + | +LL | B(TEST) => println!("matched"), + | ^^^^ + | + = 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 #62411 +note: the lint level is defined here + --> $DIR/issue-63479-match-fnptr.rs:8:9 + | +LL | #![warn(pointer_structural_match)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.rs new file mode 100644 index 000000000..0260caa82 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.rs @@ -0,0 +1,21 @@ +// Matching against NaN should result in a warning + +#![allow(unused)] +#![deny(illegal_floating_point_literal_pattern)] + +const NAN: f64 = f64::NAN; + +fn main() { + let x = NAN; + match x { + NAN => {}, //~ ERROR floating-point types cannot be used + //~| WARN this was previously accepted by the compiler but is being phased out + _ => {}, + }; + + match [x, 1.0] { + [NAN, _] => {}, //~ ERROR floating-point types cannot be used + //~| WARN this was previously accepted by the compiler but is being phased out + _ => {}, + }; +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr new file mode 100644 index 000000000..f37255d08 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/issue-6804.stderr @@ -0,0 +1,25 @@ +error: floating-point types cannot be used in patterns + --> $DIR/issue-6804.rs:11:9 + | +LL | NAN => {}, + | ^^^ + | + = 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 #41620 +note: the lint level is defined here + --> $DIR/issue-6804.rs:4:9 + | +LL | #![deny(illegal_floating_point_literal_pattern)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: floating-point types cannot be used in patterns + --> $DIR/issue-6804.rs:17:10 + | +LL | [NAN, _] => {}, + | ^^^ + | + = 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 #41620 + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs new file mode 100644 index 000000000..7ba0f3a9e --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-empty-array-allowed-without-eq-issue-62336.rs @@ -0,0 +1,17 @@ +// Pre-existing behavior has been to reject patterns with consts +// denoting non-empty arrays of non-`Eq` types, but *accept* empty +// arrays of such types. +// +// See rust-lang/rust#62336. + +// run-pass + +#[derive(PartialEq, Debug)] +struct B(i32); + +fn main() { + const FOO: [B; 0] = []; + match [] { + FOO => { } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs new file mode 100644 index 000000000..59a22c337 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.rs @@ -0,0 +1,23 @@ +#[derive(PartialEq)] +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => { } + } + + let x = 0.0; + match x { + f32::INFINITY => { } + //~^ WARNING floating-point types cannot be used in patterns + //~| WARNING this was previously accepted by the compiler but is being phased out + _ => { } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr new file mode 100644 index 000000000..1c4fb9146 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr @@ -0,0 +1,21 @@ +error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/match-forbidden-without-eq.rs:11:9 + | +LL | FOO => { } + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +warning: floating-point types cannot be used in patterns + --> $DIR/match-forbidden-without-eq.rs:18:9 + | +LL | f32::INFINITY => { } + | ^^^^^^^^^^^^^ + | + = 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 #41620 + = note: `#[warn(illegal_floating_point_literal_pattern)]` on by default + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs new file mode 100644 index 000000000..151a475c9 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.rs @@ -0,0 +1,19 @@ +// Issue 62307 pointed out a case where the structural-match checking +// was too shallow. +// +// Here we check similar behavior for non-empty arrays of types that +// do not derive `Eq`. +// +// (Current behavior for empty arrays differs and thus is not tested +// here; see rust-lang/rust#62336.) + +#[derive(PartialEq, Debug)] +struct B(i32); + +fn main() { + const FOO: [B; 1] = [B(0)]; + match [B(1)] { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr new file mode 100644 index 000000000..6adebada0 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/match-nonempty-array-forbidden-without-eq.rs:16:9 + | +LL | FOO => { } + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs new file mode 100644 index 000000000..a8deb8a75 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.rs @@ -0,0 +1,21 @@ +#[derive(Eq)] +struct Foo { + x: u32 +} + +impl PartialEq for Foo { + fn eq(&self, _: &Foo) -> bool { + false // ha ha! + } +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => { } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr new file mode 100644 index 000000000..f5b10f062 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr @@ -0,0 +1,11 @@ +error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/match-requires-both-partialeq-and-eq.rs:17:9 + | +LL | FOO => { } + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs new file mode 100644 index 000000000..50f91420c --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/phantom-data-is-structurally-matchable.rs @@ -0,0 +1,53 @@ +// run-pass + +// This file checks that `PhantomData` is considered structurally matchable. + +use std::marker::PhantomData; + +fn main() { + let mut count = 0; + + // A type which is not structurally matchable: + struct NotSM; + + // And one that is: + #[derive(PartialEq, Eq)] + struct SM; + + // Check that SM is structural-match: + const CSM: SM = SM; + match SM { + CSM => count += 1, + }; + + // Check that PhantomData is structural-match even if T is not. + const CPD1: PhantomData = PhantomData; + match PhantomData { + CPD1 => count += 1, + }; + + // Check that PhantomData is structural-match when T is. + const CPD2: PhantomData = PhantomData; + match PhantomData { + CPD2 => count += 1, + }; + + // Check that a type which has a PhantomData is structural-match. + #[derive(PartialEq, Eq, Default)] + struct Foo { + alpha: PhantomData, + beta: PhantomData, + } + + const CFOO: Foo = Foo { + alpha: PhantomData, + beta: PhantomData, + }; + + match Foo::default() { + CFOO => count += 1, + }; + + // Final count must be 4 now if all + assert_eq!(count, 4); +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match-on-ty-in-macro.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match-on-ty-in-macro.rs new file mode 100644 index 000000000..17174e22c --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match-on-ty-in-macro.rs @@ -0,0 +1,23 @@ +// run-pass +#![allow(dead_code)] + +macro_rules! foo { + (#[$attr:meta] $x:ident) => { + #[$attr] + struct $x { + x: u32 + } + } +} + +foo! { #[derive(PartialEq, Eq)] Foo } + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match.rs new file mode 100644 index 000000000..405a69c94 --- /dev/null +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/rfc1445/eq-allows-match.rs @@ -0,0 +1,17 @@ +// run-pass +#![allow(dead_code)] + +#[derive(PartialEq, Eq)] +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-2.rs b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.rs new file mode 100644 index 000000000..c0e13a5f5 --- /dev/null +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.rs @@ -0,0 +1,99 @@ +#![allow(dead_code)] + +fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { + a +} + +// The incorrect case without `for<'a>` is tested for in `rfc1623-2.rs` +static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = + &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); + +struct SomeStruct<'x, 'y, 'z: 'x> { + foo: &'x Foo<'z>, + bar: &'x Bar<'z>, + f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>, +} + +// Without this, the wf-check will fail early so we'll never see the +// error in SOME_STRUCT's body. +unsafe impl<'x, 'y, 'z: 'x> Sync for SomeStruct<'x, 'y, 'z> {} + +fn id(t: T) -> T { + t +} + +static SOME_STRUCT: &SomeStruct = &SomeStruct { + foo: &Foo { bools: &[false, true] }, + bar: &Bar { bools: &[true, true] }, + f: &id, + //~^ ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR implementation of `FnOnce` is not general enough + //~| ERROR implementation of `FnOnce` is not general enough +}; + +// very simple test for a 'static static with default lifetime +static STATIC_STR: &'static str = "&'static str"; +const CONST_STR: &'static str = "&'static str"; + +// this should be the same as without default: +static EXPLICIT_STATIC_STR: &'static str = "&'static str"; +const EXPLICIT_CONST_STR: &'static str = "&'static str"; + +// a function that elides to an unbound lifetime for both in- and output +fn id_u8_slice(arg: &[u8]) -> &[u8] { + arg +} + +// one with a function, argument elided +static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); +const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); + +// this should be the same as without elision +static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); +const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); + +// another function that elides, each to a different unbound lifetime +fn multi_args(a: &u8, b: &u8, c: &u8) {} + +static STATIC_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); +const CONST_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); + +struct Foo<'a> { + bools: &'a [bool], +} + +static STATIC_FOO: Foo<'static> = Foo { bools: &[true, false] }; +const CONST_FOO: Foo<'static> = Foo { bools: &[true, false] }; + +type Bar<'a> = Foo<'a>; + +static STATIC_BAR: Bar<'static> = Bar { bools: &[true, false] }; +const CONST_BAR: Bar<'static> = Bar { bools: &[true, false] }; + +type Baz<'a> = fn(&'a [u8]) -> Option; + +fn baz(e: &[u8]) -> Option { + e.first().map(|x| *x) +} + +static STATIC_BAZ: &'static Baz<'static> = &(baz as Baz); +const CONST_BAZ: &'static Baz<'static> = &(baz as Baz); + +static BYTES: &'static [u8] = &[1, 2, 3]; + +fn main() { + let x = &[1u8, 2, 3]; + let y = x; + + // this works, so lifetime < `'static` is valid + assert_eq!(Some(1), STATIC_BAZ(y)); + assert_eq!(Some(1), CONST_BAZ(y)); + + let y = &[1u8, 2, 3]; + + STATIC_BAZ(BYTES); // BYTES has static lifetime + CONST_BAZ(y); // interestingly this does not get reported +} diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr new file mode 100644 index 000000000..d183eaaa6 --- /dev/null +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-2.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/rfc1623-2.rs:28:8 + | +LL | f: &id, + | ^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>` + found trait `Fn<(&Foo<'_>,)>` + +error[E0308]: mismatched types + --> $DIR/rfc1623-2.rs:28:8 + | +LL | f: &id, + | ^^^ one type is more general than the other + | + = note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>` + found trait `Fn<(&Foo<'_>,)>` + +error: implementation of `FnOnce` is not general enough + --> $DIR/rfc1623-2.rs:28:8 + | +LL | f: &id, + | ^^^ implementation of `FnOnce` is not general enough + | + = note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` + +error: implementation of `FnOnce` is not general enough + --> $DIR/rfc1623-2.rs:28:8 + | +LL | f: &id, + | ^^^ implementation of `FnOnce` is not general enough + | + = note: `fn(&Foo<'2>) -> &Foo<'2> {id::<&Foo<'2>>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&Foo<'2>,)>`, for some specific lifetime `'2` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs new file mode 100644 index 000000000..26fa6fdb5 --- /dev/null +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.rs @@ -0,0 +1,14 @@ +#![allow(dead_code)] + +fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { + a +} + +// the boundaries of elision +static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = +//~^ ERROR missing lifetime specifier [E0106] + &(non_elidable as fn(&u8, &u8) -> &u8); + //~^ ERROR missing lifetime specifier [E0106] + //~| ERROR non-primitive cast + +fn main() {} diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr new file mode 100644 index 000000000..77fc3f041 --- /dev/null +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623-3.stderr @@ -0,0 +1,35 @@ +error[E0106]: missing lifetime specifier + --> $DIR/rfc1623-3.rs:8:42 + | +LL | static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = + | --- --- ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the type lifetime-generic with a new `'a` lifetime + | +LL | static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = + | +++++++ ++ ++ ++ + +error[E0106]: missing lifetime specifier + --> $DIR/rfc1623-3.rs:10:39 + | +LL | &(non_elidable as fn(&u8, &u8) -> &u8); + | --- --- ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 +help: consider making the type lifetime-generic with a new `'a` lifetime + | +LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); + | +++++++ ++ ++ ++ + +error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` + --> $DIR/rfc1623-3.rs:10:6 + | +LL | &(non_elidable as fn(&u8, &u8) -> &u8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0106, E0605. +For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/rfcs/rfc-1623-static/rfc1623.rs b/tests/ui/rfcs/rfc-1623-static/rfc1623.rs new file mode 100644 index 000000000..adaf25c6b --- /dev/null +++ b/tests/ui/rfcs/rfc-1623-static/rfc1623.rs @@ -0,0 +1,75 @@ +// run-pass +#![allow(unused_variables)] +#![allow(non_upper_case_globals)] + +#![allow(dead_code)] + +// very simple test for a 'static static with default lifetime +static STATIC_STR: &str = "&'static str"; +const CONST_STR: &str = "&'static str"; + +// this should be the same as without default: +static EXPLICIT_STATIC_STR: &'static str = "&'static str"; +const EXPLICIT_CONST_STR: &'static str = "&'static str"; + +// a function that elides to an unbound lifetime for both in- and output +fn id_u8_slice(arg: &[u8]) -> &[u8] { + arg +} + +// one with a function, argument elided +static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); +const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); + +// this should be the same as without elision +static STATIC_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); +const CONST_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); + +// another function that elides, each to a different unbound lifetime +fn multi_args(a: &u8, b: &u8, c: &u8) {} + +static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); +const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); + +struct Foo<'a> { + bools: &'a [bool], +} + +static STATIC_FOO: Foo = Foo { bools: &[true, false] }; +const CONST_FOO: Foo = Foo { bools: &[true, false] }; + +type Bar<'a> = Foo<'a>; + +static STATIC_BAR: Bar = Bar { bools: &[true, false] }; +const CONST_BAR: Bar = Bar { bools: &[true, false] }; + +type Baz<'a> = fn(&'a [u8]) -> Option; + +fn baz(e: &[u8]) -> Option { + e.first().map(|x| *x) +} + +static STATIC_BAZ: &Baz = &(baz as Baz); +const CONST_BAZ: &Baz = &(baz as Baz); + +static BYTES: &[u8] = &[1, 2, 3]; + +fn main() { + // make sure that the lifetime is actually elided (and not defaulted) + let x = &[1u8, 2, 3]; + STATIC_SIMPLE_FN(x); + CONST_SIMPLE_FN(x); + + STATIC_BAZ(BYTES); // neees static lifetime + CONST_BAZ(BYTES); + + // make sure this works with different lifetimes + let a = &1; + { + let b = &2; + let c = &3; + CONST_MULTI_FN(a, b, c); + } +} diff --git a/tests/ui/rfcs/rfc-1717-dllimport/1717-dllimport/library-override.rs b/tests/ui/rfcs/rfc-1717-dllimport/1717-dllimport/library-override.rs new file mode 100644 index 000000000..014ccac31 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/1717-dllimport/library-override.rs @@ -0,0 +1,14 @@ +// run-pass +// ignore-wasm32-bare no libc to test ffi with +// compile-flags: -lstatic=wronglibrary:rust_test_helpers + +#[link(name = "wronglibrary", kind = "dylib")] +extern "C" { + pub fn rust_dbg_extern_identity_u32(x: u32) -> u32; +} + +fn main() { + unsafe { + rust_dbg_extern_identity_u32(42); + } +} diff --git a/tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.rs b/tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.rs new file mode 100644 index 000000000..b46d85160 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.rs @@ -0,0 +1,4 @@ +// compile-flags: -l foo:bar +// error-pattern: renaming of the library `foo` was specified + +#![crate_type = "lib"] diff --git a/tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.stderr b/tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.stderr new file mode 100644 index 000000000..d4410e147 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/missing-link-attr.stderr @@ -0,0 +1,4 @@ +error: renaming of the library `foo` was specified, however this crate contains no `#[link(...)]` attributes referencing this library + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.rs b/tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.rs new file mode 100644 index 000000000..106f196b4 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.rs @@ -0,0 +1,7 @@ +// compile-flags: -l foo:bar -l foo:baz +// error-pattern: multiple renamings were specified for library + +#![crate_type = "lib"] + +#[link(name = "foo")] +extern "C" {} diff --git a/tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.stderr b/tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.stderr new file mode 100644 index 000000000..a6fec9c4e --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/multiple-renames.stderr @@ -0,0 +1,4 @@ +error: multiple renamings were specified for library `foo` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.rs b/tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.rs new file mode 100644 index 000000000..30f4db718 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.rs @@ -0,0 +1,9 @@ +// compile-flags: -l dylib=foo:bar +// error-pattern: overriding linking modifiers from command line is not supported + +#![feature(native_link_modifiers_as_needed)] + +#![crate_type = "lib"] + +#[link(name = "foo", kind = "dylib", modifiers = "-as-needed")] +extern "C" {} diff --git a/tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.stderr b/tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.stderr new file mode 100644 index 000000000..bee639bf2 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/rename-modifiers.stderr @@ -0,0 +1,8 @@ +error: overriding linking modifiers from command line is not supported + --> $DIR/rename-modifiers.rs:9:1 + | +LL | extern "C" {} + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.rs b/tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.rs new file mode 100644 index 000000000..9356c4129 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.rs @@ -0,0 +1,7 @@ +// compile-flags: -l foo: +// error-pattern: an empty renaming target was specified for library + +#![crate_type = "lib"] + +#[link(name = "foo")] +extern "C" {} diff --git a/tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.stderr b/tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.stderr new file mode 100644 index 000000000..aca839d80 --- /dev/null +++ b/tests/ui/rfcs/rfc-1717-dllimport/rename-to-empty.stderr @@ -0,0 +1,4 @@ +error: an empty renaming target was specified for library `foo` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1857-stabilize-drop-order/drop-order.rs b/tests/ui/rfcs/rfc-1857-stabilize-drop-order/drop-order.rs new file mode 100644 index 000000000..4c4816c2f --- /dev/null +++ b/tests/ui/rfcs/rfc-1857-stabilize-drop-order/drop-order.rs @@ -0,0 +1,224 @@ +// run-pass +// needs-unwind + +#![allow(dead_code, unreachable_code)] + +use std::cell::RefCell; +use std::rc::Rc; +use std::panic::{self, AssertUnwindSafe, UnwindSafe}; + +// This struct is used to record the order in which elements are dropped +struct PushOnDrop { + vec: Rc>>, + val: u32 +} + +impl PushOnDrop { + fn new(val: u32, vec: Rc>>) -> PushOnDrop { + PushOnDrop { vec, val } + } +} + +impl Drop for PushOnDrop { + fn drop(&mut self) { + self.vec.borrow_mut().push(self.val) + } +} + +impl UnwindSafe for PushOnDrop { } + +// Structs +struct TestStruct { + x: PushOnDrop, + y: PushOnDrop, + z: PushOnDrop +} + +// Tuple structs +struct TestTupleStruct(PushOnDrop, PushOnDrop, PushOnDrop); + +// Enum variants +enum TestEnum { + Tuple(PushOnDrop, PushOnDrop, PushOnDrop), + Struct { x: PushOnDrop, y: PushOnDrop, z: PushOnDrop } +} + +fn test_drop_tuple() { + // Tuple fields are dropped in the same order they are declared + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_tuple = (PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone())); + drop(test_tuple); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // Panic during construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + (PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D")); + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn test_drop_struct() { + // Struct fields are dropped in the same order they are declared + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_struct = TestStruct { + x: PushOnDrop::new(1, dropped_fields.clone()), + y: PushOnDrop::new(2, dropped_fields.clone()), + z: PushOnDrop::new(3, dropped_fields.clone()), + }; + drop(test_struct); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // The same holds for tuple structs + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_tuple_struct = TestTupleStruct(PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())); + drop(test_tuple_struct); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // Panic during struct construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestStruct { + x: PushOnDrop::new(2, cloned.clone()), + y: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // Test with different initialization order + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestStruct { + y: PushOnDrop::new(2, cloned.clone()), + x: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // The same holds for tuple structs + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestTupleStruct(PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D")); + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn test_drop_enum() { + // Enum variants are dropped in the same order they are declared + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_struct_enum = TestEnum::Struct { + x: PushOnDrop::new(1, dropped_fields.clone()), + y: PushOnDrop::new(2, dropped_fields.clone()), + z: PushOnDrop::new(3, dropped_fields.clone()) + }; + drop(test_struct_enum); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // The same holds for tuple enum variants + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_tuple_enum = TestEnum::Tuple(PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())); + drop(test_tuple_enum); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // Panic during enum construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestEnum::Struct { + x: PushOnDrop::new(2, cloned.clone()), + y: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // Test with different initialization order + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestEnum::Struct { + y: PushOnDrop::new(2, cloned.clone()), + x: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // The same holds for tuple enum variants + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestEnum::Tuple(PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D")); + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn test_drop_list() { + // Elements in a Vec are dropped in the same order they are pushed + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let xs = vec![PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())]; + drop(xs); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // The same holds for arrays + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let xs = [PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())]; + drop(xs); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // Panic during vec construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + vec![ + PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D") + ]; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // The same holds for arrays + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + [ + PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D") + ]; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn main() { + test_drop_tuple(); + test_drop_struct(); + test_drop_enum(); + test_drop_list(); +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.rs b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.rs new file mode 100644 index 000000000..a75c91cc9 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.rs @@ -0,0 +1,11 @@ +// Check that we don't blindly emit a diagnostic claiming that "`main` has an invalid return type" +// if we encounter a type that doesn't implement `std::process::Termination` and is not actually +// the return type of the program entry `main`. + +fn receive(_: impl std::process::Termination) {} + +struct Something; + +fn main() { + receive(Something); //~ ERROR the trait bound `Something: Termination` is not satisfied +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.stderr new file mode 100644 index 000000000..409dede1a --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-1.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-1.rs:10:13 + | +LL | receive(Something); + | ------- ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | | + | required by a bound introduced by this call + | +note: required by a bound in `receive` + --> $DIR/issue-103052-1.rs:5:20 + | +LL | fn receive(_: impl std::process::Termination) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `receive` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.current.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.current.stderr new file mode 100644 index 000000000..f72b3ab02 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.current.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-2.rs:15:22 + | +LL | fn main() -> Something { + | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | +note: required by a bound in `Main::main::{opaque#0}` + --> $DIR/issue-103052-2.rs:9:27 + | +LL | fn main() -> impl std::process::Termination; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::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-1937-termination-trait/issue-103052-2.next.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.next.stderr new file mode 100644 index 000000000..8b01941b4 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-2.rs:15: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:9: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-1937-termination-trait/issue-103052-2.rs b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs new file mode 100644 index 000000000..ca5fa6df2 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.rs @@ -0,0 +1,22 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] +#![allow(incomplete_features)] + +mod child { + trait Main { + fn main() -> impl std::process::Termination; + } + + struct Something; + + impl Main for () { + fn main() -> Something { + //~^ ERROR the trait bound `Something: Termination` is not satisfied + Something + } + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-err.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-err.rs new file mode 100644 index 000000000..10dc6115d --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-err.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:returned Box from main() +// failure-status: 1 +// ignore-emscripten no processes + +use std::error::Error; +use std::io; + +fn main() -> Result<(), Box> { + Err(Box::new(io::Error::new(io::ErrorKind::Other, "returned Box from main()"))) +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-ok.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-ok.rs new file mode 100644 index 000000000..e98582cbc --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error-ok.rs @@ -0,0 +1,6 @@ +// run-pass +use std::error::Error; + +fn main() -> Result<(), Box> { + Ok(()) +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs deleted file mode 100644 index e98582cbc..000000000 --- a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs +++ /dev/null @@ -1,6 +0,0 @@ -// run-pass -use std::error::Error; - -fn main() -> Result<(), Box> { - Ok(()) -} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-never.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-never.rs new file mode 100644 index 000000000..faf2526c8 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-never.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:oh, dear +// ignore-emscripten no processes + +fn main() -> ! { + panic!("oh, dear"); +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs new file mode 100644 index 000000000..6a625fb05 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:returned Box from main() +// failure-status: 1 +// ignore-emscripten no processes + +use std::io::{Error, ErrorKind}; + +fn main() -> Result<(), Box> { + Err(Box::new(Error::new(ErrorKind::Other, "returned Box from main()"))) +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-err.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-err.rs new file mode 100644 index 000000000..94f16c6fd --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-err.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern: An error message for you +// failure-status: 1 +// ignore-emscripten no processes + +fn main() -> Result<(), &'static str> { + Err("An error message for you") +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-ok.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-ok.rs new file mode 100644 index 000000000..f0591c38c --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str-ok.rs @@ -0,0 +1,4 @@ +// run-pass +fn main() -> Result<(), &'static str> { + Ok(()) +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs deleted file mode 100644 index f0591c38c..000000000 --- a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs +++ /dev/null @@ -1,4 +0,0 @@ -// run-pass -fn main() -> Result<(), &'static str> { - Ok(()) -} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.rs new file mode 100644 index 000000000..3b60cbc57 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.rs @@ -0,0 +1,3 @@ +// Tests that an `impl Trait` that is not `impl Termination` will not work. +fn main() -> impl Copy { } +//~^ ERROR `main` has invalid return type `impl Copy` diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.stderr new file mode 100644 index 000000000..5ee6d127e --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-impl-trait.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `impl Copy` + --> $DIR/termination-trait-impl-trait.rs:2:14 + | +LL | fn main() -> impl Copy { } + | ^^^^^^^^^ `main` can only return types that implement `Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs new file mode 100644 index 000000000..96808a3ed --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.rs @@ -0,0 +1,15 @@ +// compile-flags: --test + +#![feature(test)] + +extern crate test; +use std::num::ParseIntError; +use test::Bencher; + +#[test] +#[should_panic] +fn not_a_num() -> Result<(), ParseIntError> { + //~^ ERROR functions using `#[should_panic]` must return `()` + let _: u32 = "abc".parse()?; + Ok(()) +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr new file mode 100644 index 000000000..7f6749fc9 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test-should-panic.stderr @@ -0,0 +1,12 @@ +error: functions using `#[should_panic]` must return `()` + --> $DIR/termination-trait-in-test-should-panic.rs:11:1 + | +LL | / fn not_a_num() -> Result<(), ParseIntError> { +LL | | +LL | | let _: u32 = "abc".parse()?; +LL | | Ok(()) +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs new file mode 100644 index 000000000..43888cece --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs @@ -0,0 +1,28 @@ +// compile-flags: --test +// run-pass +// needs-unwind + + +#![feature(test)] + +extern crate test; +use std::num::ParseIntError; +use test::Bencher; + +#[test] +fn is_a_num() -> Result<(), ParseIntError> { + let _: u32 = "22".parse()?; + Ok(()) +} + +#[bench] +fn test_a_positive_bench(_: &mut Bencher) -> Result<(), ParseIntError> { + Ok(()) +} + +#[bench] +#[should_panic] +fn test_a_neg_bench(_: &mut Bencher) -> Result<(), ParseIntError> { + let _: u32 = "abc".parse()?; + Ok(()) +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.rs new file mode 100644 index 000000000..10f7d2215 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.rs @@ -0,0 +1,6 @@ +fn main() -> i32 { +//~^ ERROR `main` has invalid return type `i32` +//~| NOTE `main` can only return types that implement `Termination` +//~| HELP consider using `()`, or a `Result` + 0 +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.stderr new file mode 100644 index 000000000..53779d365 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-i32.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `i32` + --> $DIR/termination-trait-main-i32.rs:1:14 + | +LL | fn main() -> i32 { + | ^^^ `main` can only return types that implement `Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs new file mode 100644 index 000000000..687d5f144 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.rs @@ -0,0 +1,3 @@ +fn main() -> char { //~ ERROR + ' ' +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr new file mode 100644 index 000000000..bc8fd92ce --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-main-wrong-type.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `char` + --> $DIR/termination-trait-main-wrong-type.rs:1:14 + | +LL | fn main() -> char { + | ^^^^ `main` can only return types that implement `Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.rs new file mode 100644 index 000000000..4c6168abb --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.rs @@ -0,0 +1,5 @@ +struct ReturnType {} + +fn main() -> ReturnType { //~ ERROR `main` has invalid return type `ReturnType` + ReturnType {} +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr new file mode 100644 index 000000000..cb329548d --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `ReturnType` + --> $DIR/termination-trait-not-satisfied.rs:3:14 + | +LL | fn main() -> ReturnType { + | ^^^^^^^^^^ `main` can only return types that implement `Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs new file mode 100644 index 000000000..193a523ae --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.rs @@ -0,0 +1,8 @@ +// compile-flags: --test + +use std::num::ParseFloatError; + +#[test] +fn can_parse_zero_as_f32() -> Result { //~ ERROR + "0".parse() +} diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr new file mode 100644 index 000000000..a19750cc7 --- /dev/null +++ b/tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `f32: Termination` is not satisfied + --> $DIR/termination-trait-test-wrong-type.rs:6:31 + | +LL | #[test] + | ------- in this procedural macro expansion +LL | fn can_parse_zero_as_f32() -> Result { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Termination` is not implemented for `f32` + | + = note: required for `Result` to implement `Termination` +note: required by a bound in `assert_test_result` + --> $SRC_DIR/test/src/lib.rs:LL:COL + = note: this error originates in the attribute macro `test` (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 E0277`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs new file mode 100644 index 000000000..54ab9f0ad --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.rs @@ -0,0 +1,24 @@ +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub struct Foo { +} + +impl Foo { + fn get(&self) -> Option<&Result> { + None + } + + fn mutate(&mut self) { } +} + +fn main() { + let mut foo = Foo { }; + + // foo.get() returns type Option<&Result>, so + // using `string` keeps borrow of `foo` alive. Hence calling + // `foo.mutate()` should be an error. + while let Some(Ok(string)) = foo.get() { + foo.mutate(); + //~^ ERROR cannot borrow `foo` as mutable + println!("foo={:?}", *string); + } +} 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 new file mode 100644 index 000000000..b7c0b0bb6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr @@ -0,0 +1,14 @@ +error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-issue-49631.rs:20:9 + | +LL | while let Some(Ok(string)) = foo.get() { + | --------- immutable borrow occurs here +LL | foo.mutate(); + | ^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("foo={:?}", *string); + | ------- immutable borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs new file mode 100644 index 000000000..93df88040 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.rs @@ -0,0 +1,17 @@ +// FIXME(tschottdorf): this test should pass. + +#[derive(PartialEq, Eq)] +struct Foo { + bar: i32, +} + +const FOO: Foo = Foo{bar: 5}; + +fn main() { + let f = Foo{bar:6}; + + match &f { + FOO => {}, //~ ERROR mismatched types + _ => panic!(), + } +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr new file mode 100644 index 000000000..fc06de90a --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/const.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/const.rs:14:9 + | +LL | const FOO: Foo = Foo{bar: 5}; + | -------------- constant defined here +... +LL | match &f { + | -- this expression has type `&Foo` +LL | FOO => {}, + | ^^^ + | | + | expected `&Foo`, found `Foo` + | `FOO` is interpreted as a constant, not a new binding + | help: introduce a new binding instead: `other_foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs new file mode 100644 index 000000000..52fbb90ed --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum-ok.rs @@ -0,0 +1,45 @@ +// run-pass +enum Wrapper { + Wrap(i32), +} + +use Wrapper::Wrap; + +pub fn main() { + let Wrap(x) = &Wrap(3); + println!("{}", *x); + + let Wrap(x) = &mut Wrap(3); + println!("{}", *x); + + if let Some(x) = &Some(3) { + println!("{}", *x); + } else { + panic!(); + } + + if let Some(x) = &mut Some(3) { + println!("{}", *x); + } else { + panic!(); + } + + if let Some(x) = &mut Some(3) { + *x += 1; + } else { + panic!(); + } + + while let Some(x) = &Some(3) { + println!("{}", *x); + break; + } + while let Some(x) = &mut Some(3) { + println!("{}", *x); + break; + } + while let Some(x) = &mut Some(3) { + *x += 1; + break; + } +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs index 52fbb90ed..4e57769d6 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs @@ -1,4 +1,3 @@ -// run-pass enum Wrapper { Wrap(i32), } @@ -7,39 +6,17 @@ use Wrapper::Wrap; pub fn main() { let Wrap(x) = &Wrap(3); - println!("{}", *x); + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference - let Wrap(x) = &mut Wrap(3); - println!("{}", *x); if let Some(x) = &Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - *x += 1; + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference } else { panic!(); } while let Some(x) = &Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - *x += 1; + *x += 1; //~ ERROR cannot assign to `*x`, which is behind a `&` reference break; } } diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr new file mode 100644 index 000000000..21e3d3d27 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.stderr @@ -0,0 +1,21 @@ +error[E0594]: cannot assign to `*x`, which is behind a `&` reference + --> $DIR/enum.rs:9:5 + | +LL | *x += 1; + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + +error[E0594]: cannot assign to `*x`, which is behind a `&` reference + --> $DIR/enum.rs:13:9 + | +LL | *x += 1; + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + +error[E0594]: cannot assign to `*x`, which is behind a `&` reference + --> $DIR/enum.rs:19:9 + | +LL | *x += 1; + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs new file mode 100644 index 000000000..b8fde2208 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.rs @@ -0,0 +1,28 @@ +// Verify the binding mode shifts - only when no `&` are auto-dereferenced is the +// final default binding mode mutable. + +fn main() { + match &&Some(5i32) { + Some(n) => { + *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference + let _ = n; + } + None => {}, + }; + + match &mut &Some(5i32) { + Some(n) => { + *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference + let _ = n; + } + None => {}, + }; + + match &&mut Some(5i32) { + Some(n) => { + *n += 1; //~ ERROR cannot assign to `*n`, which is behind a `&` reference + let _ = n; + } + None => {}, + }; +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr new file mode 100644 index 000000000..c3f64f65a --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/explicit-mut.stderr @@ -0,0 +1,21 @@ +error[E0594]: cannot assign to `*n`, which is behind a `&` reference + --> $DIR/explicit-mut.rs:7:13 + | +LL | *n += 1; + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + +error[E0594]: cannot assign to `*n`, which is behind a `&` reference + --> $DIR/explicit-mut.rs:15:13 + | +LL | *n += 1; + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + +error[E0594]: cannot assign to `*n`, which is behind a `&` reference + --> $DIR/explicit-mut.rs:23:13 + | +LL | *n += 1; + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0594`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs new file mode 100644 index 000000000..a5a24a806 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for-ok.rs @@ -0,0 +1,20 @@ +// run-pass +pub fn main() { + let mut tups = vec![(0u8, 1u8)]; + + for (n, m) in &tups { + let _: &u8 = n; + let _: &u8 = m; + } + + for (n, m) in &mut tups { + *n += 1; + *m += 2; + } + + assert_eq!(tups, vec![(1u8, 3u8)]); + + for (n, m) in tups { + println!("{} {}", m, n); + } +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs index a5a24a806..d6c5a13b1 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.rs @@ -1,20 +1,9 @@ -// run-pass -pub fn main() { - let mut tups = vec![(0u8, 1u8)]; - - for (n, m) in &tups { - let _: &u8 = n; - let _: &u8 = m; - } +struct Foo {} - for (n, m) in &mut tups { - *n += 1; - *m += 2; - } - - assert_eq!(tups, vec![(1u8, 3u8)]); - - for (n, m) in tups { - println!("{} {}", m, n); +pub fn main() { + let mut tups = vec![(Foo {}, Foo {})]; + // The below desugars to &(ref n, mut m). + for (n, mut m) in &tups { + //~^ ERROR cannot move out of a shared reference } } diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr new file mode 100644 index 000000000..07991af6e --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/for.stderr @@ -0,0 +1,17 @@ +error[E0507]: cannot move out of a shared reference + --> $DIR/for.rs:6:23 + | +LL | for (n, mut m) in &tups { + | ----- ^^^^^ + | | + | data moved here + | move occurs because `m` has type `Foo`, which does not implement the `Copy` trait + | +help: consider borrowing the pattern binding + | +LL | for (n, ref mut m) in &tups { + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs new file mode 100644 index 000000000..b4a0d8145 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.rs @@ -0,0 +1,10 @@ +// FIXME(tschottdorf): This should compile. See #44912. + +pub fn main() { + let x = &Some((3, 3)); + let _: &i32 = match x { + Some((x, 3)) | &Some((ref x, 5)) => x, + //~^ ERROR is bound inconsistently + _ => &5i32, + }; +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr new file mode 100644 index 000000000..e1e1bf7f6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/issue-44912-or.stderr @@ -0,0 +1,9 @@ +error[E0409]: variable `x` is bound inconsistently across alternatives separated by `|` + --> $DIR/issue-44912-or.rs:6:35 + | +LL | Some((x, 3)) | &Some((ref x, 5)) => x, + | - first binding ^ bound in different ways + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0409`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs new file mode 100644 index 000000000..937975359 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit-ok.rs @@ -0,0 +1,34 @@ +// run-pass +#![allow(dead_code)] +fn with_u8() { + let s = 5u8; + let r = match &s { + 4 => false, + 5 => true, + _ => false, + }; + assert!(r); +} + +// A string literal isn't mistaken for a non-ref pattern (in which case we'd +// deref `s` and mess things up). +fn with_str() { + let s: &'static str = "abc"; + match s { + "abc" => true, + _ => panic!(), + }; +} + +// Ditto with byte strings. +fn with_bytes() { + let s: &'static [u8] = b"abc"; + match s { + b"abc" => true, + _ => panic!(), + }; +} + +pub fn main() { + with_str(); +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs index 937975359..ce79cfbdc 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.rs @@ -1,34 +1,24 @@ -// run-pass -#![allow(dead_code)] -fn with_u8() { - let s = 5u8; - let r = match &s { - 4 => false, - 5 => true, - _ => false, - }; - assert!(r); -} +// FIXME(tschottdorf): we want these to compile, but they don't. -// A string literal isn't mistaken for a non-ref pattern (in which case we'd -// deref `s` and mess things up). fn with_str() { let s: &'static str = "abc"; - match s { - "abc" => true, + + match &s { + "abc" => true, //~ ERROR mismatched types _ => panic!(), }; } -// Ditto with byte strings. fn with_bytes() { let s: &'static [u8] = b"abc"; - match s { - b"abc" => true, + + match &s { + b"abc" => true, //~ ERROR mismatched types _ => panic!(), }; } pub fn main() { with_str(); + with_bytes(); } diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr new file mode 100644 index 000000000..181f57899 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/lit.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/lit.rs:7:13 + | +LL | match &s { + | -- this expression has type `&&str` +LL | "abc" => true, + | ^^^^^ expected `&&str`, found `&str` + | + = note: expected reference `&&str` + found reference `&'static str` + +error[E0308]: mismatched types + --> $DIR/lit.rs:16:9 + | +LL | match &s { + | -- this expression has type `&&[u8]` +LL | b"abc" => true, + | ^^^^^^ expected `&&[u8]`, found `&[u8; 3]` + | + = note: expected reference `&&[u8]` + found reference `&'static [u8; 3]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs new file mode 100644 index 000000000..46fdfd678 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.rs @@ -0,0 +1,11 @@ +// Without caching type lookups in FnCtxt.resolve_ty_and_def_ufcs +// the error below would be reported twice (once when checking +// for a non-ref pattern, once when processing the pattern). + +fn main() { + let foo = 22; + match foo { + u32::XXX => { } //~ ERROR no associated item named + _ => { } + } +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr new file mode 100644 index 000000000..c672acee0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/no-double-error.stderr @@ -0,0 +1,9 @@ +error[E0599]: no associated item named `XXX` found for type `u32` in the current scope + --> $DIR/no-double-error.rs:8:14 + | +LL | u32::XXX => { } + | ^^^ associated item not found in `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs new file mode 100644 index 000000000..33229a205 --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice-ok.rs @@ -0,0 +1,25 @@ +// run-pass + +fn slice_pat() { + let sl: &[u8] = b"foo"; + + match sl { + [first, remainder @ ..] => { + let _: &u8 = first; + assert_eq!(first, &b'f'); + assert_eq!(remainder, b"oo"); + } + [] => panic!(), + } +} + +fn slice_pat_omission() { + match &[0, 1, 2] { + [..] => {} + }; +} + +fn main() { + slice_pat(); + slice_pat_omission(); +} diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs index 33229a205..363a0e3e6 100644 --- a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.rs @@ -1,25 +1,7 @@ -// run-pass - -fn slice_pat() { +pub fn main() { let sl: &[u8] = b"foo"; - match sl { - [first, remainder @ ..] => { - let _: &u8 = first; - assert_eq!(first, &b'f'); - assert_eq!(remainder, b"oo"); - } - [] => panic!(), - } -} - -fn slice_pat_omission() { - match &[0, 1, 2] { - [..] => {} - }; -} - -fn main() { - slice_pat(); - slice_pat_omission(); + match sl { //~ ERROR non-exhaustive patterns + [first, remainder @ ..] => {}, + }; } diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr new file mode 100644 index 000000000..5b51dc5ac --- /dev/null +++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/slice.stderr @@ -0,0 +1,16 @@ +error[E0004]: non-exhaustive patterns: `&[]` not covered + --> $DIR/slice.rs:4:11 + | +LL | match sl { + | ^^ pattern `&[]` not covered + | + = note: the matched value is of type `&[u8]` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ [first, remainder @ ..] => {}, +LL ~ &[] => todo!(), + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs new file mode 100644 index 000000000..cb2b585ab --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs @@ -0,0 +1,44 @@ +#![crate_type = "rlib"] + +#[non_exhaustive] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 }, +} + +#[non_exhaustive] +pub enum NestedNonExhaustive { + A(NonExhaustiveEnum), + B, + C, +} + +#[non_exhaustive] +pub enum EmptyNonExhaustiveEnum {} + +pub enum VariantNonExhaustive { + #[non_exhaustive] + Bar { + x: u32, + y: u64, + }, + Baz(u32, u16), +} + +#[non_exhaustive] +pub enum NonExhaustiveSingleVariant { + A(bool), +} + +#[repr(u8)] +pub enum FieldLessWithNonExhaustiveVariant { + A, + B, + #[non_exhaustive] + C, +} + +impl Default for FieldLessWithNonExhaustiveVariant { + fn default() -> Self { Self::A } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/monovariants.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/monovariants.rs new file mode 100644 index 000000000..5f86db86d --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/monovariants.rs @@ -0,0 +1,8 @@ +#[non_exhaustive] +pub enum NonExhaustiveMonovariant { + Variant(u32), +} + +pub enum ExhaustiveMonovariant { + Variant(u32), +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs new file mode 100644 index 000000000..78db6b170 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs @@ -0,0 +1,41 @@ +#[derive(Default)] +#[non_exhaustive] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +pub struct UnitStruct; + +#[non_exhaustive] +pub struct TupleStruct(pub u16, pub u16); + +#[derive(Debug)] +#[non_exhaustive] +pub struct FunctionalRecord { + pub first_field: u16, + pub second_field: u16, + pub third_field: bool, +} + +impl Default for FunctionalRecord { + fn default() -> FunctionalRecord { + FunctionalRecord { first_field: 640, second_field: 480, third_field: false } + } +} + +#[derive(Default)] +#[non_exhaustive] +pub struct NestedStruct { + pub foo: u16, + pub bar: NormalStruct, +} + +#[derive(Default)] +#[non_exhaustive] +pub struct MixedVisFields { + pub a: u16, + pub b: bool, + pub(crate) foo: bool, +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/unstable.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/unstable.rs new file mode 100644 index 000000000..11df44461 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/unstable.rs @@ -0,0 +1,60 @@ +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[non_exhaustive] +pub enum UnstableEnum { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Stable, + #[stable(feature = "stable_test_feature", since = "1.0.0")] + Stable2, + #[unstable(feature = "unstable_test_feature", issue = "none")] + Unstable, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[non_exhaustive] +pub enum OnlyUnstableEnum { + #[unstable(feature = "unstable_test_feature", issue = "none")] + Unstable, + #[unstable(feature = "unstable_test_feature", issue = "none")] + Unstable2, +} + +impl OnlyUnstableEnum { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new() -> Self { + Self::Unstable + } +} + +#[derive(Default)] +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[non_exhaustive] +pub struct UnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub stable: bool, + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub stable2: usize, + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub unstable: u8, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[non_exhaustive] +pub struct OnlyUnstableStruct { + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub unstable: u8, + #[unstable(feature = "unstable_test_feature", issue = "none")] + pub unstable2: bool, +} + +impl OnlyUnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + pub fn new() -> Self { + Self { + unstable: 0, + unstable2: false, + } + } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs new file mode 100644 index 000000000..02672d545 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs @@ -0,0 +1,7 @@ +#![crate_type = "rlib"] + +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + #[non_exhaustive] Tuple(u32), + #[non_exhaustive] Struct { field: u32 } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs new file mode 100644 index 000000000..b9ff24c76 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-exhaustive.rs @@ -0,0 +1,44 @@ +// Test that the borrow checker doesn't consider checking an exhaustive pattern +// as an access. + +// check-pass + +#![allow(dropping_references)] + +// aux-build:monovariants.rs +extern crate monovariants; + +use monovariants::ExhaustiveMonovariant; + +enum Local { + Variant(u32), +} + +#[non_exhaustive] +enum LocalNonExhaustive { + Variant(u32), +} + +fn main() { + let mut x = ExhaustiveMonovariant::Variant(1); + let y = &mut x; + match x { + ExhaustiveMonovariant::Variant(_) => {}, + _ => {}, + } + drop(y); + let mut x = Local::Variant(1); + let y = &mut x; + match x { + Local::Variant(_) => {}, + _ => {}, + } + drop(y); + let mut x = LocalNonExhaustive::Variant(1); + let y = &mut x; + match x { + LocalNonExhaustive::Variant(_) => {}, + _ => {}, + } + drop(y); +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs new file mode 100644 index 000000000..2ad92b794 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.rs @@ -0,0 +1,18 @@ +// Test that the borrow checker considers `#[non_exhaustive]` when checking +// whether a match contains a discriminant read. + +// aux-build:monovariants.rs +extern crate monovariants; + +use monovariants::NonExhaustiveMonovariant; + +fn main() { + let mut x = NonExhaustiveMonovariant::Variant(1); + let y = &mut x; + match x { + //~^ ERROR cannot use `x` because it was mutably borrowed + NonExhaustiveMonovariant::Variant(_) => {}, + _ => {}, + } + drop(y); +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr new file mode 100644 index 000000000..ad84ebe3a --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/borrowck-non-exhaustive.stderr @@ -0,0 +1,14 @@ +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-non-exhaustive.rs:12:11 + | +LL | let y = &mut x; + | ------ `x` is borrowed here +LL | match x { + | ^ use of borrowed `x` +... +LL | drop(y); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0503`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.rs new file mode 100644 index 000000000..5dce8180f --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.rs @@ -0,0 +1,11 @@ +// aux-build:enums.rs + +extern crate enums; + +use enums::FieldLessWithNonExhaustiveVariant; + +fn main() { + let e = FieldLessWithNonExhaustiveVariant::default(); + let d = e as u8; //~ ERROR casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid [E0606] + assert_eq!(d, 0); +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.stderr new file mode 100644 index 000000000..a61dcf839 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum-as-cast.stderr @@ -0,0 +1,11 @@ +error[E0606]: casting `FieldLessWithNonExhaustiveVariant` as `u8` is invalid + --> $DIR/enum-as-cast.rs:9:13 + | +LL | let d = e as u8; + | ^^^^^^^ + | + = note: cannot cast an enum with a non-exhaustive variant when it's defined in another crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0606`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.rs new file mode 100644 index 000000000..9d2855f5c --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.rs @@ -0,0 +1,69 @@ +// aux-build:enums.rs +extern crate enums; + +use enums::{EmptyNonExhaustiveEnum, NonExhaustiveEnum}; + +fn empty(x: EmptyNonExhaustiveEnum) { + match x {} //~ ERROR type `EmptyNonExhaustiveEnum` is non-empty + match x { + _ => {}, // ok + } +} + +fn main() { + let enum_unit = NonExhaustiveEnum::Unit; + + match enum_unit { + //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] + NonExhaustiveEnum::Unit => "first", + NonExhaustiveEnum::Tuple(_) => "second", + NonExhaustiveEnum::Struct { .. } => "third" + }; + + match enum_unit {}; + //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] + + // Everything below this is expected to compile successfully. + + let enum_unit = NonExhaustiveEnum::Unit; + + match enum_unit { + NonExhaustiveEnum::Unit => 1, + NonExhaustiveEnum::Tuple(_) => 2, + // This particular arm tests that an enum marked as non-exhaustive + // will not error if its variants are matched exhaustively. + NonExhaustiveEnum::Struct { field } => field, + _ => 0 // no error with wildcard + }; + + match enum_unit { + _ => "no error with only wildcard" + }; + + // #53549: Check that variant constructors can still be called normally. + match NonExhaustiveEnum::Unit { + NonExhaustiveEnum::Unit => {}, + _ => {} + }; + + match NonExhaustiveEnum::Tuple(2) { + NonExhaustiveEnum::Tuple(2) => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Unit {}) { + NonExhaustiveEnum::Unit {} => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Tuple { 0: 2 }) { + NonExhaustiveEnum::Tuple { 0: 2 } => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Struct { field: 2 }) { + NonExhaustiveEnum::Struct { field: 2 } => {}, + _ => {} + }; + +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr new file mode 100644 index 000000000..872cb9b8b --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum.stderr @@ -0,0 +1,59 @@ +error[E0004]: non-exhaustive patterns: type `EmptyNonExhaustiveEnum` is non-empty + --> $DIR/enum.rs:7:11 + | +LL | match x {} + | ^ + | +note: `EmptyNonExhaustiveEnum` defined here + --> $DIR/auxiliary/enums.rs:18:1 + | +LL | pub enum EmptyNonExhaustiveEnum {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `EmptyNonExhaustiveEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/enum.rs:16:11 + | +LL | match enum_unit { + | ^^^^^^^^^ pattern `_` not covered + | +note: `NonExhaustiveEnum` defined here + --> $DIR/auxiliary/enums.rs:4:1 + | +LL | pub enum NonExhaustiveEnum { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ NonExhaustiveEnum::Struct { .. } => "third", +LL + _ => todo!() + | + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/enum.rs:23:11 + | +LL | match enum_unit {}; + | ^^^^^^^^^ pattern `_` not covered + | +note: `NonExhaustiveEnum` defined here + --> $DIR/auxiliary/enums.rs:4:1 + | +LL | pub enum NonExhaustiveEnum { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ match enum_unit { +LL + _ => todo!(), +LL ~ }; + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate.rs new file mode 100644 index 000000000..54e42917f --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate.rs @@ -0,0 +1,18 @@ +// run-pass + +#[non_exhaustive] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 } +} + +fn main() { + let enum_unit = NonExhaustiveEnum::Unit; + + match enum_unit { + NonExhaustiveEnum::Unit => "first", + NonExhaustiveEnum::Tuple(_) => "second", + NonExhaustiveEnum::Struct { .. } => "third", + }; +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs new file mode 100644 index 000000000..69a283c31 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.rs @@ -0,0 +1,37 @@ +#![deny(unreachable_patterns)] + +#[non_exhaustive] +pub enum NonExhaustiveEnum { + Unit, + //~^ not covered + Tuple(u32), + //~^ not covered + Struct { field: u32 } + //~^ not covered +} + +pub enum NormalEnum { + Unit, + //~^ not covered + Tuple(u32), + //~^ not covered + Struct { field: u32 } + //~^ not covered +} + +#[non_exhaustive] +pub enum EmptyNonExhaustiveEnum {} + +fn empty_non_exhaustive(x: EmptyNonExhaustiveEnum) { + match x {} + match x { + _ => {} //~ ERROR unreachable pattern + } +} + +fn main() { + match NonExhaustiveEnum::Unit {} + //~^ ERROR `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered [E0004] + match NormalEnum::Unit {} + //~^ ERROR `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered [E0004] +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr new file mode 100644 index 000000000..de1bf8be8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr @@ -0,0 +1,69 @@ +error: unreachable pattern + --> $DIR/enum_same_crate_empty_match.rs:28:9 + | +LL | _ => {} + | ^ + | +note: the lint level is defined here + --> $DIR/enum_same_crate_empty_match.rs:1:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0004]: non-exhaustive patterns: `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered + --> $DIR/enum_same_crate_empty_match.rs:33:11 + | +LL | match NonExhaustiveEnum::Unit {} + | ^^^^^^^^^^^^^^^^^^^^^^^ patterns `NonExhaustiveEnum::Unit`, `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered + | +note: `NonExhaustiveEnum` defined here + --> $DIR/enum_same_crate_empty_match.rs:5:5 + | +LL | pub enum NonExhaustiveEnum { + | ----------------- +LL | Unit, + | ^^^^ not covered +LL | +LL | Tuple(u32), + | ^^^^^ not covered +LL | +LL | Struct { field: u32 } + | ^^^^^^ not covered + = note: the matched value is of type `NonExhaustiveEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match NonExhaustiveEnum::Unit { +LL + NonExhaustiveEnum::Unit | NonExhaustiveEnum::Tuple(_) | NonExhaustiveEnum::Struct { .. } => todo!(), +LL + } + | + +error[E0004]: non-exhaustive patterns: `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered + --> $DIR/enum_same_crate_empty_match.rs:35:11 + | +LL | match NormalEnum::Unit {} + | ^^^^^^^^^^^^^^^^ patterns `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered + | +note: `NormalEnum` defined here + --> $DIR/enum_same_crate_empty_match.rs:14:5 + | +LL | pub enum NormalEnum { + | ---------- +LL | Unit, + | ^^^^ not covered +LL | +LL | Tuple(u32), + | ^^^^^ not covered +LL | +LL | Struct { field: u32 } + | ^^^^^^ not covered + = note: the matched value is of type `NormalEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match NormalEnum::Unit { +LL + NormalEnum::Unit | NormalEnum::Tuple(_) | NormalEnum::Struct { .. } => todo!(), +LL + } + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs new file mode 100644 index 000000000..d6251fcb7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/auxiliary/types.rs @@ -0,0 +1,29 @@ +#[non_exhaustive] +#[repr(C)] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 } +} + +#[non_exhaustive] +#[repr(C)] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +#[repr(C)] +pub struct UnitStruct; + +#[non_exhaustive] +#[repr(C)] +pub struct TupleStruct (pub u16, pub u16); + +#[repr(C)] +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + #[non_exhaustive] Tuple(u32), + #[non_exhaustive] Struct { field: u32 } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs new file mode 100644 index 000000000..15c0c695f --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.rs @@ -0,0 +1,24 @@ +// aux-build:types.rs +#![deny(improper_ctypes)] + +extern crate types; + +// This test checks that non-exhaustive types with `#[repr(C)]` from an extern crate are considered +// improper. + +use types::{NonExhaustiveEnum, NonExhaustiveVariants, NormalStruct, TupleStruct, UnitStruct}; + +extern "C" { + pub fn non_exhaustive_enum(_: NonExhaustiveEnum); + //~^ ERROR `extern` block uses type `NonExhaustiveEnum`, which is not FFI-safe + pub fn non_exhaustive_normal_struct(_: NormalStruct); + //~^ ERROR `extern` block uses type `NormalStruct`, which is not FFI-safe + pub fn non_exhaustive_unit_struct(_: UnitStruct); + //~^ ERROR `extern` block uses type `UnitStruct`, which is not FFI-safe + pub fn non_exhaustive_tuple_struct(_: TupleStruct); + //~^ ERROR `extern` block uses type `TupleStruct`, which is not FFI-safe + pub fn non_exhaustive_variant(_: NonExhaustiveVariants); + //~^ ERROR `extern` block uses type `NonExhaustiveVariants`, which is not FFI-safe +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr new file mode 100644 index 000000000..43c8e1015 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/extern_crate_improper.stderr @@ -0,0 +1,47 @@ +error: `extern` block uses type `NonExhaustiveEnum`, which is not FFI-safe + --> $DIR/extern_crate_improper.rs:12:35 + | +LL | pub fn non_exhaustive_enum(_: NonExhaustiveEnum); + | ^^^^^^^^^^^^^^^^^ not FFI-safe + | + = note: this enum is non-exhaustive +note: the lint level is defined here + --> $DIR/extern_crate_improper.rs:2:9 + | +LL | #![deny(improper_ctypes)] + | ^^^^^^^^^^^^^^^ + +error: `extern` block uses type `NormalStruct`, which is not FFI-safe + --> $DIR/extern_crate_improper.rs:14:44 + | +LL | pub fn non_exhaustive_normal_struct(_: NormalStruct); + | ^^^^^^^^^^^^ not FFI-safe + | + = note: this struct is non-exhaustive + +error: `extern` block uses type `UnitStruct`, which is not FFI-safe + --> $DIR/extern_crate_improper.rs:16:42 + | +LL | pub fn non_exhaustive_unit_struct(_: UnitStruct); + | ^^^^^^^^^^ not FFI-safe + | + = note: this struct is non-exhaustive + +error: `extern` block uses type `TupleStruct`, which is not FFI-safe + --> $DIR/extern_crate_improper.rs:18:43 + | +LL | pub fn non_exhaustive_tuple_struct(_: TupleStruct); + | ^^^^^^^^^^^ not FFI-safe + | + = note: this struct is non-exhaustive + +error: `extern` block uses type `NonExhaustiveVariants`, which is not FFI-safe + --> $DIR/extern_crate_improper.rs:20:38 + | +LL | pub fn non_exhaustive_variant(_: NonExhaustiveVariants); + | ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe + | + = note: this enum has non-exhaustive variants + +error: aborting due to 5 previous errors + diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs new file mode 100644 index 000000000..fe4ae345d --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/improper_ctypes/same_crate_proper.rs @@ -0,0 +1,48 @@ +// check-pass +#![deny(improper_ctypes)] + +// This test checks that non-exhaustive types with `#[repr(C)]` are considered proper within +// the defining crate. + +#[non_exhaustive] +#[repr(C)] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 }, +} + +#[non_exhaustive] +#[repr(C)] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +#[repr(C)] +pub struct UnitStruct; + +#[non_exhaustive] +#[repr(C)] +pub struct TupleStruct(pub u16, pub u16); + +#[repr(C)] +pub enum NonExhaustiveVariants { + #[non_exhaustive] + Unit, + #[non_exhaustive] + Tuple(u32), + #[non_exhaustive] + Struct { field: u32 }, +} + +extern "C" { + // Unit structs aren't tested here because they will trigger `improper_ctypes` anyway. + pub fn non_exhaustive_enum(_: NonExhaustiveEnum); + pub fn non_exhaustive_normal_struct(_: NormalStruct); + pub fn non_exhaustive_tuple_struct(_: TupleStruct); + pub fn non_exhaustive_variant(_: NonExhaustiveVariants); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs new file mode 100644 index 000000000..143f9a300 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs @@ -0,0 +1,16 @@ +#[non_exhaustive(anything)] +//~^ ERROR malformed `non_exhaustive` attribute +struct Foo; + +#[non_exhaustive] +//~^ ERROR attribute should be applied to a struct or enum [E0701] +trait Bar { } + +#[non_exhaustive] +//~^ ERROR attribute should be applied to a struct or enum [E0701] +union Baz { + f1: u16, + f2: u16 +} + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr new file mode 100644 index 000000000..136cd763b --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr @@ -0,0 +1,30 @@ +error: malformed `non_exhaustive` attribute input + --> $DIR/invalid-attribute.rs:1:1 + | +LL | #[non_exhaustive(anything)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[non_exhaustive]` + +error[E0701]: attribute should be applied to a struct or enum + --> $DIR/invalid-attribute.rs:5:1 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ +LL | +LL | trait Bar { } + | ------------- not a struct or enum + +error[E0701]: attribute should be applied to a struct or enum + --> $DIR/invalid-attribute.rs:9:1 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ +LL | +LL | / union Baz { +LL | | f1: u16, +LL | | f2: u16 +LL | | } + | |_- not a struct or enum + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0701`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs new file mode 100644 index 000000000..3482af747 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.rs @@ -0,0 +1,211 @@ +// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly. + +#![feature(non_exhaustive_omitted_patterns_lint, unstable_test_feature)] + +// aux-build:enums.rs +extern crate enums; +// aux-build:unstable.rs +extern crate unstable; +// aux-build:structs.rs +extern crate structs; + +use enums::{ + EmptyNonExhaustiveEnum, NestedNonExhaustive, NonExhaustiveEnum, NonExhaustiveSingleVariant, + VariantNonExhaustive, +}; +use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct}; +use structs::{FunctionalRecord, MixedVisFields, NestedStruct, NormalStruct}; + +#[non_exhaustive] +#[derive(Default)] +pub struct Foo { + a: u8, + b: usize, + c: String, +} + +#[non_exhaustive] +pub enum Bar { + A, + B, + C, +} + +fn main() { + let enumeration = Bar::A; + + // Ok: this is a crate local non_exhaustive enum + match enumeration { + Bar::A => {} + Bar::B => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + + let non_enum = NonExhaustiveEnum::Unit; + + // Ok: without the attribute + match non_enum { + NonExhaustiveEnum::Unit => {} + NonExhaustiveEnum::Tuple(_) => {} + _ => {} + } + + match non_enum { + NonExhaustiveEnum::Unit => {} + NonExhaustiveEnum::Tuple(_) => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + //~^^ some variants are not matched explicitly + + match non_enum { + NonExhaustiveEnum::Unit | NonExhaustiveEnum::Struct { .. } => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + //~^^ some variants are not matched explicitly + + let x = 5; + match non_enum { + NonExhaustiveEnum::Unit if x > 10 => {} + NonExhaustiveEnum::Tuple(_) => {} + NonExhaustiveEnum::Struct { .. } => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + //~^^ some variants are not matched explicitly + + // Ok: all covered and not `unreachable-patterns` + #[deny(unreachable_patterns)] + match non_enum { + NonExhaustiveEnum::Unit => {} + NonExhaustiveEnum::Tuple(_) => {} + NonExhaustiveEnum::Struct { .. } => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + + #[deny(non_exhaustive_omitted_patterns)] + match NestedNonExhaustive::B { + NestedNonExhaustive::A(NonExhaustiveEnum::Unit) => {} + NestedNonExhaustive::A(_) => {} + NestedNonExhaustive::B => {} + _ => {} + } + //~^^ some variants are not matched explicitly + //~^^^^^ some variants are not matched explicitly + + #[warn(non_exhaustive_omitted_patterns)] + match VariantNonExhaustive::Baz(1, 2) { + VariantNonExhaustive::Baz(_, _) => {} + VariantNonExhaustive::Bar { x, .. } => {} + } + //~^^ some fields are not explicitly listed + + #[warn(non_exhaustive_omitted_patterns)] + let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default(); + //~^ some fields are not explicitly listed + + // Ok: this is local + #[warn(non_exhaustive_omitted_patterns)] + let Foo { a, b, .. } = Foo::default(); + + #[warn(non_exhaustive_omitted_patterns)] + let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); + //~^ some fields are not explicitly listed + //~^^ some fields are not explicitly listed + + // Ok: this tests https://github.com/rust-lang/rust/issues/89382 + #[warn(non_exhaustive_omitted_patterns)] + let MixedVisFields { a, b, .. } = MixedVisFields::default(); + + // Ok: because this only has 1 variant + #[deny(non_exhaustive_omitted_patterns)] + match NonExhaustiveSingleVariant::A(true) { + NonExhaustiveSingleVariant::A(true) => {} + _ => {} + } + + #[deny(non_exhaustive_omitted_patterns)] + match NonExhaustiveSingleVariant::A(true) { + _ => {} + } + //~^^ some variants are not matched explicitly + + // Ok: we don't lint on `if let` expressions + #[deny(non_exhaustive_omitted_patterns)] + if let NonExhaustiveEnum::Tuple(_) = non_enum {} + + match UnstableEnum::Stable { + UnstableEnum::Stable => {} + UnstableEnum::Stable2 => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + //~^^ some variants are not matched explicitly + + // Ok: the feature is on and all variants are matched + #[deny(non_exhaustive_omitted_patterns)] + match UnstableEnum::Stable { + UnstableEnum::Stable => {} + UnstableEnum::Stable2 => {} + UnstableEnum::Unstable => {} + _ => {} + } + + // Ok: the feature is on and both variants are matched + #[deny(non_exhaustive_omitted_patterns)] + match OnlyUnstableEnum::Unstable { + OnlyUnstableEnum::Unstable => {} + OnlyUnstableEnum::Unstable2 => {} + _ => {} + } + + #[deny(non_exhaustive_omitted_patterns)] + match OnlyUnstableEnum::Unstable { + OnlyUnstableEnum::Unstable => {} + _ => {} + } + //~^^ some variants are not matched explicitly + + #[warn(non_exhaustive_omitted_patterns)] + let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new(); + //~^ some fields are not explicitly listed + + // OK: both unstable fields are matched with feature on + #[warn(non_exhaustive_omitted_patterns)] + let OnlyUnstableStruct { unstable, unstable2, .. } = OnlyUnstableStruct::new(); + + #[warn(non_exhaustive_omitted_patterns)] + let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); + //~^ some fields are not explicitly listed + + // OK: both unstable and stable fields are matched with feature on + #[warn(non_exhaustive_omitted_patterns)] + let UnstableStruct { stable, stable2, unstable, .. } = UnstableStruct::default(); + + // Ok: local bindings are allowed + #[deny(non_exhaustive_omitted_patterns)] + let local = NonExhaustiveEnum::Unit; + + // Ok: missing patterns will be blocked by the pattern being refutable + #[deny(non_exhaustive_omitted_patterns)] + let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; + //~^ refutable pattern in local binding + + // Check that matching on a reference results in a correctly spanned diagnostic + #[deny(non_exhaustive_omitted_patterns)] + match &non_enum { + NonExhaustiveEnum::Unit => {} + NonExhaustiveEnum::Tuple(_) => {} + _ => {} + } + //~^^ some variants are not matched explicitly +} + +#[deny(non_exhaustive_omitted_patterns)] +// Ok: Pattern in a param is always wildcard +pub fn takes_non_exhaustive(_: NonExhaustiveEnum) { + let _closure = |_: NonExhaustiveEnum| {}; +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr new file mode 100644 index 000000000..923394474 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr @@ -0,0 +1,217 @@ +warning: some fields are not explicitly listed + --> $DIR/omitted-patterns.rs:102:9 + | +LL | VariantNonExhaustive::Bar { x, .. } => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `y` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `VariantNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:99:12 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: some fields are not explicitly listed + --> $DIR/omitted-patterns.rs:107:9 + | +LL | let FunctionalRecord { first_field, second_field, .. } = FunctionalRecord::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `third_field` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `FunctionalRecord` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:106:12 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: some fields are not explicitly listed + --> $DIR/omitted-patterns.rs:115:29 + | +LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `second_field` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `NormalStruct` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:114:12 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: some fields are not explicitly listed + --> $DIR/omitted-patterns.rs:115:9 + | +LL | let NestedStruct { bar: NormalStruct { first_field, .. }, .. } = NestedStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `foo` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `NestedStruct` and the `non_exhaustive_omitted_patterns` attribute was found + +warning: some fields are not explicitly listed + --> $DIR/omitted-patterns.rs:173:9 + | +LL | let OnlyUnstableStruct { unstable, .. } = OnlyUnstableStruct::new(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable2` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `OnlyUnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:172:12 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: some fields are not explicitly listed + --> $DIR/omitted-patterns.rs:181:9 + | +LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `unstable` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `UnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:180:12 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:58:9 + | +LL | _ => {} + | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:57:16 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:65:9 + | +LL | _ => {} + | ^ pattern `NonExhaustiveEnum::Tuple(_)` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:64:16 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:75:9 + | +LL | _ => {} + | ^ pattern `NonExhaustiveEnum::Unit` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:74:16 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:92:32 + | +LL | NestedNonExhaustive::A(_) => {} + | ^ patterns `NonExhaustiveEnum::Tuple(_)` and `NonExhaustiveEnum::Struct { .. }` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:89:12 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:94:9 + | +LL | _ => {} + | ^ pattern `NestedNonExhaustive::C` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NestedNonExhaustive` and the `non_exhaustive_omitted_patterns` attribute was found + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:132:9 + | +LL | _ => {} + | ^ pattern `NonExhaustiveSingleVariant::A(_)` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveSingleVariant` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:130:12 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:144:9 + | +LL | _ => {} + | ^ pattern `UnstableEnum::Unstable` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:143:16 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:168:9 + | +LL | _ => {} + | ^ pattern `OnlyUnstableEnum::Unstable2` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `OnlyUnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:165:12 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0005]: refutable pattern in local binding + --> $DIR/omitted-patterns.rs:194:9 + | +LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; + | ^^^^^^^^^^^^^^^ pattern `_` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `NonExhaustiveEnum` +help: you might want to use `let else` to handle the variant that isn't matched + | +LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit else { todo!() }; + | ++++++++++++++++ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:202:9 + | +LL | _ => {} + | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:198:12 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors; 6 warnings emitted + +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs new file mode 100644 index 000000000..82ee68687 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.rs @@ -0,0 +1,45 @@ +// Test that the `non_exhaustive_omitted_patterns` lint is triggered correctly with variants +// marked stable and unstable. + +#![feature(non_exhaustive_omitted_patterns_lint)] + +// aux-build:unstable.rs +extern crate unstable; + +use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct}; + +fn main() { + // OK: this matches all the stable variants + match UnstableEnum::Stable { + UnstableEnum::Stable => {} + UnstableEnum::Stable2 => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + + match UnstableEnum::Stable { + UnstableEnum::Stable => {} + #[deny(non_exhaustive_omitted_patterns)] + _ => {} + } + //~^^ some variants are not matched explicitly + + // Ok: although this is a bit odd, we don't have anything to report + // since there is no stable variants and the feature is off + #[deny(non_exhaustive_omitted_patterns)] + match OnlyUnstableEnum::new() { + _ => {} + } + + // Ok: Same as the above enum (no fields can be matched on) + #[warn(non_exhaustive_omitted_patterns)] + let OnlyUnstableStruct { .. } = OnlyUnstableStruct::new(); + + #[warn(non_exhaustive_omitted_patterns)] + let UnstableStruct { stable, .. } = UnstableStruct::default(); + //~^ some fields are not explicitly listed + + // OK: stable field is matched + #[warn(non_exhaustive_omitted_patterns)] + let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr new file mode 100644 index 000000000..f38368590 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/stable-omitted-patterns.stderr @@ -0,0 +1,30 @@ +warning: some fields are not explicitly listed + --> $DIR/stable-omitted-patterns.rs:39:9 + | +LL | let UnstableStruct { stable, .. } = UnstableStruct::default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ field `stable2` not listed + | + = help: ensure that all fields are mentioned explicitly by adding the suggested fields + = note: the pattern is of type `UnstableStruct` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/stable-omitted-patterns.rs:38:12 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: some variants are not matched explicitly + --> $DIR/stable-omitted-patterns.rs:23:9 + | +LL | _ => {} + | ^ pattern `UnstableEnum::Stable2` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `UnstableEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/stable-omitted-patterns.rs:22:16 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs new file mode 100644 index 000000000..07e093c15 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.rs @@ -0,0 +1,49 @@ +// aux-build:structs.rs +extern crate structs; + +use structs::{NormalStruct, UnitStruct, TupleStruct, FunctionalRecord}; + +fn main() { + let fr = FunctionalRecord { + //~^ ERROR cannot create non-exhaustive struct + first_field: 1920, + second_field: 1080, + ..FunctionalRecord::default() + }; + + let ns = NormalStruct { first_field: 640, second_field: 480 }; + //~^ ERROR cannot create non-exhaustive struct + + let NormalStruct { first_field, second_field } = ns; + //~^ ERROR `..` required with struct marked as non-exhaustive + + let ts = TupleStruct(640, 480); + //~^ ERROR cannot initialize a tuple struct which contains private fields [E0423] + + let ts_explicit = structs::TupleStruct(640, 480); + //~^ ERROR tuple struct constructor `TupleStruct` is private [E0603] + + let TupleStruct { 0: first_field, 1: second_field } = ts; + //~^ ERROR `..` required with struct marked as non-exhaustive + + let us = UnitStruct; + //~^ ERROR expected value, found struct `UnitStruct` [E0423] + + let us_explicit = structs::UnitStruct; + //~^ ERROR unit struct `UnitStruct` is private [E0603] + + let UnitStruct { } = us; + //~^ ERROR `..` required with struct marked as non-exhaustive +} + +// Everything below this is expected to compile successfully. + +// We only test matching here as we cannot create non-exhaustive +// structs from another crate. ie. they'll never pass in run-pass tests. +fn match_structs(ns: NormalStruct, ts: TupleStruct, us: UnitStruct) { + let NormalStruct { first_field, second_field, .. } = ns; + + let TupleStruct { 0: first, 1: second, .. } = ts; + + let UnitStruct { .. } = us; +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr new file mode 100644 index 000000000..39b1ef1e0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/struct.stderr @@ -0,0 +1,95 @@ +error[E0423]: expected value, found struct `UnitStruct` + --> $DIR/struct.rs:29:14 + | +LL | let us = UnitStruct; + | ^^^^^^^^^^ constructor is not visible here due to private fields + +error[E0603]: tuple struct constructor `TupleStruct` is private + --> $DIR/struct.rs:23:32 + | +LL | let ts_explicit = structs::TupleStruct(640, 480); + | ^^^^^^^^^^^ private tuple struct constructor + | +note: the tuple struct constructor `TupleStruct` is defined here + --> $DIR/auxiliary/structs.rs:12:1 + | +LL | #[non_exhaustive] + | ----------------- cannot be constructed because it is `#[non_exhaustive]` +LL | pub struct TupleStruct(pub u16, pub u16); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: unit struct `UnitStruct` is private + --> $DIR/struct.rs:32:32 + | +LL | let us_explicit = structs::UnitStruct; + | ^^^^^^^^^^ private unit struct + | +note: the unit struct `UnitStruct` is defined here + --> $DIR/auxiliary/structs.rs:9:1 + | +LL | #[non_exhaustive] + | ----------------- cannot be constructed because it is `#[non_exhaustive]` +LL | pub struct UnitStruct; + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0639]: cannot create non-exhaustive struct using struct expression + --> $DIR/struct.rs:7:14 + | +LL | let fr = FunctionalRecord { + | ______________^ +LL | | +LL | | first_field: 1920, +LL | | second_field: 1080, +LL | | ..FunctionalRecord::default() +LL | | }; + | |_____^ + +error[E0639]: cannot create non-exhaustive struct using struct expression + --> $DIR/struct.rs:14:14 + | +LL | let ns = NormalStruct { first_field: 640, second_field: 480 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0638]: `..` required with struct marked as non-exhaustive + --> $DIR/struct.rs:17:9 + | +LL | let NormalStruct { first_field, second_field } = ns; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add `..` at the end of the field list to ignore all other fields + | +LL | let NormalStruct { first_field, second_field , .. } = ns; + | ~~~~~~ + +error[E0423]: cannot initialize a tuple struct which contains private fields + --> $DIR/struct.rs:20:14 + | +LL | let ts = TupleStruct(640, 480); + | ^^^^^^^^^^^ + +error[E0638]: `..` required with struct marked as non-exhaustive + --> $DIR/struct.rs:26:9 + | +LL | let TupleStruct { 0: first_field, 1: second_field } = ts; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add `..` at the end of the field list to ignore all other fields + | +LL | let TupleStruct { 0: first_field, 1: second_field , .. } = ts; + | ~~~~~~ + +error[E0638]: `..` required with struct marked as non-exhaustive + --> $DIR/struct.rs:35:9 + | +LL | let UnitStruct { } = us; + | ^^^^^^^^^^^^^^ + | +help: add `..` at the end of the field list to ignore all other fields + | +LL | let UnitStruct { .. } = us; + | ~~~~ + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0423, E0603, E0638, E0639. +For more information about an error, try `rustc --explain E0423`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs new file mode 100644 index 000000000..5f76b0cb2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs @@ -0,0 +1,32 @@ +// run-pass + +#![allow(unused_variables)] + +#[non_exhaustive] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +pub struct UnitStruct; + +#[non_exhaustive] +pub struct TupleStruct (pub u16, pub u16); + +fn main() { + let ns = NormalStruct { first_field: 640, second_field: 480 }; + + let NormalStruct { first_field, second_field } = ns; + + let ts = TupleStruct { 0: 340, 1: 480 }; + let ts_constructor = TupleStruct(340, 480); + + let TupleStruct { 0: first, 1: second } = ts; + let TupleStruct(first, second) = ts_constructor; + + let us = UnitStruct {}; + let us_constructor = UnitStruct; + + let UnitStruct { } = us; +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs new file mode 100644 index 000000000..a2735d4cb --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs @@ -0,0 +1,32 @@ +#![crate_type = "rlib"] +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +pub enum PartiallyInhabitedVariants { + Tuple(u8), + #[non_exhaustive] Struct { x: ! } +} + +pub struct IndirectUninhabitedEnum(UninhabitedEnum); + +pub struct IndirectUninhabitedStruct(UninhabitedStruct); + +pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + +pub struct IndirectUninhabitedVariants(UninhabitedVariants); diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs new file mode 100644 index 000000000..80b9dc4c1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.rs @@ -0,0 +1,38 @@ +// aux-build:uninhabited.rs +#![feature(never_type)] + +extern crate uninhabited; + +use uninhabited::{ + UninhabitedEnum, + UninhabitedStruct, + UninhabitedTupleStruct, + UninhabitedVariants, +}; + +// This test checks that uninhabited non-exhaustive types cannot coerce to any type, as the never +// type can. + +struct A; + +fn can_coerce_never_type_to_anything(x: !) -> A { + x +} + +fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { + x //~ ERROR mismatched types +} + +fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + x //~ ERROR mismatched types +} + +fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { + x //~ ERROR mismatched types +} + +fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { + x //~ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr new file mode 100644 index 000000000..c209caab5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions.stderr @@ -0,0 +1,35 @@ +error[E0308]: mismatched types + --> $DIR/coercions.rs:23:5 + | +LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedEnum` + +error[E0308]: mismatched types + --> $DIR/coercions.rs:27:5 + | +LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedTupleStruct` + +error[E0308]: mismatched types + --> $DIR/coercions.rs:31:5 + | +LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedStruct` + +error[E0308]: mismatched types + --> $DIR/coercions.rs:35:5 + | +LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedVariants` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs new file mode 100644 index 000000000..6b911dd98 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs @@ -0,0 +1,45 @@ +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +struct A; + +// This test checks that uninhabited non-exhaustive types defined in the same crate cannot coerce +// to any type, as the never type can. + +fn can_coerce_never_type_to_anything(x: !) -> A { + x +} + +fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { + x //~ ERROR mismatched types +} + +fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + x //~ ERROR mismatched types +} + +fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { + x //~ ERROR mismatched types +} + +fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { + x //~ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr new file mode 100644 index 000000000..289433edf --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr @@ -0,0 +1,35 @@ +error[E0308]: mismatched types + --> $DIR/coercions_same_crate.rs:30:5 + | +LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedEnum` + +error[E0308]: mismatched types + --> $DIR/coercions_same_crate.rs:34:5 + | +LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedTupleStruct` + +error[E0308]: mismatched types + --> $DIR/coercions_same_crate.rs:38:5 + | +LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedStruct` + +error[E0308]: mismatched types + --> $DIR/coercions_same_crate.rs:42:5 + | +LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { + | - expected `A` because of return type +LL | x + | ^ expected `A`, found `UninhabitedVariants` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs new file mode 100644 index 000000000..98a7fdbc5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs @@ -0,0 +1,36 @@ +// aux-build:uninhabited.rs +#![feature(never_type)] + +extern crate uninhabited; + +use uninhabited::{ + IndirectUninhabitedEnum, + IndirectUninhabitedStruct, + IndirectUninhabitedTupleStruct, + IndirectUninhabitedVariants, +}; + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type through a level of +// indirection from an extern crate will not compile. + +fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( + x: IndirectUninhabitedVariants, +) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr new file mode 100644 index 000000000..66e93291c --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr @@ -0,0 +1,79 @@ +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty + --> $DIR/indirect_match.rs:19:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:26:1 + | +LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty + --> $DIR/indirect_match.rs:23:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:28:1 + | +LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty + --> $DIR/indirect_match.rs:27:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:30:1 + | +LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty + --> $DIR/indirect_match.rs:33:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:32:1 + | +LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs new file mode 100644 index 000000000..8f090fe88 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs @@ -0,0 +1,51 @@ +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +pub struct IndirectUninhabitedEnum(UninhabitedEnum); + +pub struct IndirectUninhabitedStruct(UninhabitedStruct); + +pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + +pub struct IndirectUninhabitedVariants(UninhabitedVariants); + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type through a level of +// indirection from the defining crate will not compile without `#![feature(exhaustive_patterns)]`. + +fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( + x: IndirectUninhabitedVariants, +) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr new file mode 100644 index 000000000..c12190541 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr @@ -0,0 +1,79 @@ +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty + --> $DIR/indirect_match_same_crate.rs:34:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedEnum` defined here + --> $DIR/indirect_match_same_crate.rs:20:12 + | +LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); + | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty + --> $DIR/indirect_match_same_crate.rs:38:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedStruct` defined here + --> $DIR/indirect_match_same_crate.rs:22:12 + | +LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty + --> $DIR/indirect_match_same_crate.rs:42:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedTupleStruct` defined here + --> $DIR/indirect_match_same_crate.rs:24:12 + | +LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty + --> $DIR/indirect_match_same_crate.rs:48:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedVariants` defined here + --> $DIR/indirect_match_same_crate.rs:26:12 + | +LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs new file mode 100644 index 000000000..be86519ec --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs @@ -0,0 +1,40 @@ +// aux-build:uninhabited.rs +#![deny(unreachable_patterns)] +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +extern crate uninhabited; + +use uninhabited::{ + IndirectUninhabitedEnum, + IndirectUninhabitedStruct, + IndirectUninhabitedTupleStruct, + IndirectUninhabitedVariants, +}; + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type through a level of +// indirection from an extern crate will not compile. In particular, this enables the +// `exhaustive_patterns` feature as this can change the branch used in the compiler to determine +// this. + +fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( + x: IndirectUninhabitedVariants, +) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr new file mode 100644 index 000000000..ef97c1fa1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr @@ -0,0 +1,79 @@ +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedEnum` is non-empty + --> $DIR/indirect_match_with_exhaustive_patterns.rs:23:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:26:1 + | +LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedEnum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedStruct` is non-empty + --> $DIR/indirect_match_with_exhaustive_patterns.rs:27:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:28:1 + | +LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedTupleStruct` is non-empty + --> $DIR/indirect_match_with_exhaustive_patterns.rs:31:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:30:1 + | +LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `IndirectUninhabitedVariants` is non-empty + --> $DIR/indirect_match_with_exhaustive_patterns.rs:37:11 + | +LL | match x {} + | ^ + | +note: `IndirectUninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:32:1 + | +LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `IndirectUninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs new file mode 100644 index 000000000..60289aa78 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs @@ -0,0 +1,57 @@ +// check-pass + +#![deny(unreachable_patterns)] +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +pub struct IndirectUninhabitedEnum(UninhabitedEnum); + +pub struct IndirectUninhabitedStruct(UninhabitedStruct); + +pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); + +pub struct IndirectUninhabitedVariants(UninhabitedVariants); + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate +// will compile. In particular, this enables the `exhaustive_patterns` feature as this can +// change the branch used in the compiler to determine this. +// Codegen is skipped because tests with long names can cause issues on Windows CI, see #60648. + +fn cannot_empty_match_on_empty_enum_to_anything(x: IndirectUninhabitedEnum) -> A { + match x {} +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: IndirectUninhabitedStruct) -> A { + match x {} +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: IndirectUninhabitedTupleStruct) -> A { + match x {} +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything( + x: IndirectUninhabitedVariants, +) -> A { + match x {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs new file mode 100644 index 000000000..230ac7529 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.rs @@ -0,0 +1,21 @@ +// aux-build:uninhabited.rs +#![deny(unreachable_patterns)] +#![feature(never_type)] + +extern crate uninhabited; + +use uninhabited::PartiallyInhabitedVariants; + +// This test checks a redundant/useless pattern of a non-exhaustive enum/variant is still +// warned against. + +pub fn foo(x: PartiallyInhabitedVariants) { + match x { + PartiallyInhabitedVariants::Struct { .. } => {}, + PartiallyInhabitedVariants::Struct { .. } => {}, + //~^ ERROR unreachable pattern + _ => {}, + } +} + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr new file mode 100644 index 000000000..f39e6ee29 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/issue-65157-repeated-match-arm.stderr @@ -0,0 +1,14 @@ +error: unreachable pattern + --> $DIR/issue-65157-repeated-match-arm.rs:15:9 + | +LL | PartiallyInhabitedVariants::Struct { .. } => {}, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-65157-repeated-match-arm.rs:2:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs new file mode 100644 index 000000000..e54098d4d --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.rs @@ -0,0 +1,34 @@ +// aux-build:uninhabited.rs +#![feature(never_type)] + +extern crate uninhabited; + +use uninhabited::{ + UninhabitedEnum, + UninhabitedStruct, + UninhabitedTupleStruct, + UninhabitedVariants, +}; + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type from an extern crate +// will not compile. + +fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr new file mode 100644 index 000000000..a9c54af04 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match.stderr @@ -0,0 +1,83 @@ +error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty + --> $DIR/match.rs:19:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:5:1 + | +LL | pub enum UninhabitedEnum { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty + --> $DIR/match.rs:23:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:9:1 + | +LL | pub struct UninhabitedStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty + --> $DIR/match.rs:27:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:14:1 + | +LL | pub struct UninhabitedTupleStruct(!); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered + --> $DIR/match.rs:31:11 + | +LL | match x {} + | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered + | +note: `UninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:17:23 + | +LL | pub enum UninhabitedVariants { + | ---------------------------- +LL | #[non_exhaustive] Tuple(!), + | ^^^^^ not covered +LL | #[non_exhaustive] Struct { x: ! } + | ^^^^^^ not covered + = note: the matched value is of type `UninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), +LL ~ } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs new file mode 100644 index 000000000..ebbdfba15 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs @@ -0,0 +1,41 @@ +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate +// will compile. + +fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { + match x {} +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr new file mode 100644 index 000000000..ec2a2f6f0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr @@ -0,0 +1,64 @@ +error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty + --> $DIR/match_same_crate.rs:30:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedStruct` defined here + --> $DIR/match_same_crate.rs:8:12 + | +LL | pub struct UninhabitedStruct { + | ^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty + --> $DIR/match_same_crate.rs:34:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedTupleStruct` defined here + --> $DIR/match_same_crate.rs:13:12 + | +LL | pub struct UninhabitedTupleStruct(!); + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered + --> $DIR/match_same_crate.rs:38:11 + | +LL | match x {} + | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered + | +note: `UninhabitedVariants` defined here + --> $DIR/match_same_crate.rs:16:23 + | +LL | pub enum UninhabitedVariants { + | ------------------- +LL | #[non_exhaustive] Tuple(!), + | ^^^^^ not covered +LL | #[non_exhaustive] Struct { x: ! } + | ^^^^^^ not covered + = note: the matched value is of type `UninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), +LL ~ } + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs new file mode 100644 index 000000000..900dfff65 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs @@ -0,0 +1,37 @@ +// aux-build:uninhabited.rs +#![deny(unreachable_patterns)] +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +extern crate uninhabited; + +use uninhabited::{ + UninhabitedEnum, + UninhabitedStruct, + UninhabitedTupleStruct, + UninhabitedVariants, +}; + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type from an extern crate +// will not compile. In particular, this enables the `exhaustive_patterns` feature as this can +// change the branch used in the compiler to determine this. + +fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { + match x {} //~ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr new file mode 100644 index 000000000..b6b777ec5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr @@ -0,0 +1,83 @@ +error[E0004]: non-exhaustive patterns: type `UninhabitedEnum` is non-empty + --> $DIR/match_with_exhaustive_patterns.rs:22:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedEnum` defined here + --> $DIR/auxiliary/uninhabited.rs:5:1 + | +LL | pub enum UninhabitedEnum { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty + --> $DIR/match_with_exhaustive_patterns.rs:26:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:9:1 + | +LL | pub struct UninhabitedStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: type `UninhabitedTupleStruct` is non-empty + --> $DIR/match_with_exhaustive_patterns.rs:30:11 + | +LL | match x {} + | ^ + | +note: `UninhabitedTupleStruct` defined here + --> $DIR/auxiliary/uninhabited.rs:14:1 + | +LL | pub struct UninhabitedTupleStruct(!); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the matched value is of type `UninhabitedTupleStruct` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match x { +LL + _ => todo!(), +LL ~ } + | + +error[E0004]: non-exhaustive patterns: `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered + --> $DIR/match_with_exhaustive_patterns.rs:34:11 + | +LL | match x {} + | ^ patterns `UninhabitedVariants::Tuple(_)` and `UninhabitedVariants::Struct { .. }` not covered + | +note: `UninhabitedVariants` defined here + --> $DIR/auxiliary/uninhabited.rs:17:23 + | +LL | pub enum UninhabitedVariants { + | ---------------------------- +LL | #[non_exhaustive] Tuple(!), + | ^^^^^ not covered +LL | #[non_exhaustive] Struct { x: ! } + | ^^^^^^ not covered + = note: the matched value is of type `UninhabitedVariants` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ match x { +LL + UninhabitedVariants::Tuple(_) | UninhabitedVariants::Struct { .. } => todo!(), +LL ~ } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs new file mode 100644 index 000000000..de5530485 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs @@ -0,0 +1,47 @@ +// check-pass + +#![deny(unreachable_patterns)] +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +struct A; + +// This test checks that an empty match on a non-exhaustive uninhabited type from the defining crate +// will compile. In particular, this enables the `exhaustive_patterns` feature as this can +// change the branch used in the compiler to determine this. +// Codegen is skipped because tests with long names can cause issues on Windows CI, see #60648. + +fn cannot_empty_match_on_empty_enum_to_anything(x: UninhabitedEnum) -> A { + match x {} +} + +fn cannot_empty_match_on_empty_struct_to_anything(x: UninhabitedStruct) -> A { + match x {} +} + +fn cannot_empty_match_on_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { + match x {} +} + +fn cannot_empty_match_on_enum_with_empty_variants_struct_to_anything(x: UninhabitedVariants) -> A { + match x {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs new file mode 100644 index 000000000..221b5cf6b --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs @@ -0,0 +1,59 @@ +// aux-build:uninhabited.rs +// build-pass (FIXME(62277): could be check-pass?) +#![deny(unreachable_patterns)] +#![feature(exhaustive_patterns)] + +extern crate uninhabited; + +use uninhabited::{ + PartiallyInhabitedVariants, + UninhabitedEnum, + UninhabitedStruct, + UninhabitedTupleStruct, + UninhabitedVariants, +}; + +fn uninhabited_enum() -> Option { + None +} + +fn uninhabited_variant() -> Option { + None +} + +fn partially_inhabited_variant() -> PartiallyInhabitedVariants { + PartiallyInhabitedVariants::Tuple(3) +} + +fn uninhabited_struct() -> Option { + None +} + +fn uninhabited_tuple_struct() -> Option { + None +} + +// This test checks that non-exhaustive types that would normally be considered uninhabited within +// the defining crate are not considered uninhabited from extern crates. + +fn main() { + match uninhabited_enum() { + Some(_x) => (), // This line would normally error. + None => (), + } + + match uninhabited_variant() { + Some(_x) => (), // This line would normally error. + None => (), + } + + // This line would normally error. + while let PartiallyInhabitedVariants::Struct { x, .. } = partially_inhabited_variant() { + } + + while let Some(_x) = uninhabited_struct() { // This line would normally error. + } + + while let Some(_x) = uninhabited_tuple_struct() { // This line would normally error. + } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs new file mode 100644 index 000000000..ffc496a97 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs @@ -0,0 +1,70 @@ +#![deny(unreachable_patterns)] +#![feature(exhaustive_patterns)] +#![feature(never_type)] + +#[non_exhaustive] +pub enum UninhabitedEnum { +} + +#[non_exhaustive] +pub struct UninhabitedTupleStruct(!); + +#[non_exhaustive] +pub struct UninhabitedStruct { + _priv: !, +} + +pub enum UninhabitedVariants { + #[non_exhaustive] Tuple(!), + #[non_exhaustive] Struct { x: ! } +} + +pub enum PartiallyInhabitedVariants { + Tuple(u8), + #[non_exhaustive] Struct { x: ! } +} + +fn uninhabited_enum() -> Option { + None +} + +fn uninhabited_variant() -> Option { + None +} + +fn partially_inhabited_variant() -> PartiallyInhabitedVariants { + PartiallyInhabitedVariants::Tuple(3) +} + +fn uninhabited_struct() -> Option { + None +} + +fn uninhabited_tuple_struct() -> Option { + None +} + +// This test checks that non-exhaustive types that would normally be considered uninhabited within +// the defining crate are still considered uninhabited. + +fn main() { + match uninhabited_enum() { + Some(_x) => (), //~ ERROR unreachable pattern + None => (), + } + + match uninhabited_variant() { + Some(_x) => (), //~ ERROR unreachable pattern + None => (), + } + + while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() { + //~^ ERROR unreachable pattern + } + + while let Some(_x) = uninhabited_struct() { //~ ERROR unreachable pattern + } + + while let Some(_x) = uninhabited_tuple_struct() { //~ ERROR unreachable pattern + } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr new file mode 100644 index 000000000..8bfd6e91f --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr @@ -0,0 +1,38 @@ +error: unreachable pattern + --> $DIR/patterns_same_crate.rs:52:9 + | +LL | Some(_x) => (), + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/patterns_same_crate.rs:1:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/patterns_same_crate.rs:57:9 + | +LL | Some(_x) => (), + | ^^^^^^^^ + +error: unreachable pattern + --> $DIR/patterns_same_crate.rs:61:15 + | +LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/patterns_same_crate.rs:65:15 + | +LL | while let Some(_x) = uninhabited_struct() { + | ^^^^^^^^ + +error: unreachable pattern + --> $DIR/patterns_same_crate.rs:68:15 + | +LL | while let Some(_x) = uninhabited_tuple_struct() { + | ^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs new file mode 100644 index 000000000..bc346aea5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.rs @@ -0,0 +1,33 @@ +// aux-build:variants.rs + +extern crate variants; + +use variants::NonExhaustiveVariants; + +fn main() { + let variant_struct = NonExhaustiveVariants::Struct { field: 640 }; + //~^ ERROR cannot create non-exhaustive variant + + let variant_tuple = NonExhaustiveVariants::Tuple(640); + //~^ ERROR tuple variant `Tuple` is private [E0603] + + let variant_unit = NonExhaustiveVariants::Unit; + //~^ ERROR unit variant `Unit` is private [E0603] + + match variant_struct { + NonExhaustiveVariants::Unit => "", + //~^ ERROR unit variant `Unit` is private [E0603] + NonExhaustiveVariants::Tuple(fe_tpl) => "", + //~^ ERROR tuple variant `Tuple` is private [E0603] + NonExhaustiveVariants::Struct { field } => "" + //~^ ERROR `..` required with variant marked as non-exhaustive + }; + + if let NonExhaustiveVariants::Tuple(fe_tpl) = variant_struct { + //~^ ERROR tuple variant `Tuple` is private [E0603] + } + + if let NonExhaustiveVariants::Struct { field } = variant_struct { + //~^ ERROR `..` required with variant marked as non-exhaustive + } +} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.stderr new file mode 100644 index 000000000..4083f57a9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/variant.stderr @@ -0,0 +1,102 @@ +error[E0603]: tuple variant `Tuple` is private + --> $DIR/variant.rs:11:48 + | +LL | let variant_tuple = NonExhaustiveVariants::Tuple(640); + | ^^^^^ private tuple variant + | +note: the tuple variant `Tuple` is defined here + --> $DIR/auxiliary/variants.rs:5:23 + | +LL | #[non_exhaustive] Tuple(u32), + | ----------------- ^^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` + +error[E0603]: unit variant `Unit` is private + --> $DIR/variant.rs:14:47 + | +LL | let variant_unit = NonExhaustiveVariants::Unit; + | ^^^^ private unit variant + | +note: the unit variant `Unit` is defined here + --> $DIR/auxiliary/variants.rs:4:23 + | +LL | #[non_exhaustive] Unit, + | ----------------- ^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` + +error[E0603]: unit variant `Unit` is private + --> $DIR/variant.rs:18:32 + | +LL | NonExhaustiveVariants::Unit => "", + | ^^^^ private unit variant + | +note: the unit variant `Unit` is defined here + --> $DIR/auxiliary/variants.rs:4:23 + | +LL | #[non_exhaustive] Unit, + | ----------------- ^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` + +error[E0603]: tuple variant `Tuple` is private + --> $DIR/variant.rs:20:32 + | +LL | NonExhaustiveVariants::Tuple(fe_tpl) => "", + | ^^^^^ private tuple variant + | +note: the tuple variant `Tuple` is defined here + --> $DIR/auxiliary/variants.rs:5:23 + | +LL | #[non_exhaustive] Tuple(u32), + | ----------------- ^^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` + +error[E0603]: tuple variant `Tuple` is private + --> $DIR/variant.rs:26:35 + | +LL | if let NonExhaustiveVariants::Tuple(fe_tpl) = variant_struct { + | ^^^^^ private tuple variant + | +note: the tuple variant `Tuple` is defined here + --> $DIR/auxiliary/variants.rs:5:23 + | +LL | #[non_exhaustive] Tuple(u32), + | ----------------- ^^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` + +error[E0639]: cannot create non-exhaustive variant using struct expression + --> $DIR/variant.rs:8:26 + | +LL | let variant_struct = NonExhaustiveVariants::Struct { field: 640 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0638]: `..` required with variant marked as non-exhaustive + --> $DIR/variant.rs:22:9 + | +LL | NonExhaustiveVariants::Struct { field } => "" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add `..` at the end of the field list to ignore all other fields + | +LL | NonExhaustiveVariants::Struct { field , .. } => "" + | ~~~~~~ + +error[E0638]: `..` required with variant marked as non-exhaustive + --> $DIR/variant.rs:30:12 + | +LL | if let NonExhaustiveVariants::Struct { field } = variant_struct { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add `..` at the end of the field list to ignore all other fields + | +LL | if let NonExhaustiveVariants::Struct { field , .. } = variant_struct { + | ~~~~~~ + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0603, E0638, E0639. +For more information about an error, try `rustc --explain E0603`. diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/variants_fictive_visibility.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/variants_fictive_visibility.rs new file mode 100644 index 000000000..dacaf489a --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/variants_fictive_visibility.rs @@ -0,0 +1,12 @@ +// build-pass (FIXME(62277): could be check-pass?) +// aux-build:variants.rs + +extern crate variants; + +const S: u8 = 0; + +// OK, `Struct` in value namespace is crate-private, so it's filtered away +// and there's no conflict with the previously defined `const S`. +use variants::NonExhaustiveVariants::Struct as S; + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs new file mode 100644 index 000000000..5f2816ec6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs @@ -0,0 +1,18 @@ +// run-pass + +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + #[non_exhaustive] Tuple(u32), + #[non_exhaustive] Struct { field: u32 } +} + +fn main() { + let variant_tuple = NonExhaustiveVariants::Tuple(340); + let _variant_struct = NonExhaustiveVariants::Struct { field: 340 }; + + match variant_tuple { + NonExhaustiveVariants::Unit => "", + NonExhaustiveVariants::Tuple(_fe_tpl) => "", + NonExhaustiveVariants::Struct { field: _ } => "" + }; +} diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs new file mode 100644 index 000000000..fa04f4b12 --- /dev/null +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs @@ -0,0 +1,23 @@ +// Check that we if we get ahold of an object unsafe trait +// object with auto traits and lifetimes, we can downcast it +// +// check-pass + +#![feature(object_safe_for_dispatch)] + +trait Trait: Sized {} + +fn downcast_auto(t: &(dyn Trait + Send)) -> &dyn Trait { + t +} + +fn downcast_lifetime<'a, 'b, 't>(t: &'a (dyn Trait + 't)) + -> &'b (dyn Trait + 't) +where + 'a: 'b, + 't: 'a + 'b, +{ + t +} + +fn main() {} 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 new file mode 100644 index 000000000..721890db4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/manual-self-impl-for-unsafe-obj.rs @@ -0,0 +1,66 @@ +// Check that we can manually implement an object-unsafe trait for its trait object. + +// run-pass + +#![feature(object_safe_for_dispatch)] + +trait Bad { + fn stat() -> char { + 'A' + } + fn virt(&self) -> char { + 'B' + } + fn indirect(&self) -> char { + Self::stat() + } +} + +trait Good { + fn good_virt(&self) -> char { + panic!() + } + fn good_indirect(&self) -> char { + panic!() + } +} + +impl<'a> Bad for dyn Bad + 'a { + fn stat() -> char { + 'C' + } + fn virt(&self) -> char { + 'D' + } +} + +struct Struct {} + +impl Bad for Struct {} + +impl Good for Struct {} + +fn main() { + let s = Struct {}; + + let mut res = String::new(); + + // Directly call static. + res.push(Struct::stat()); // "A" + res.push(::stat()); // "AC" + + let good: &dyn Good = &s; + + // These look similar enough... + let bad = unsafe { std::mem::transmute::<&dyn Good, &dyn Bad>(good) }; + + // Call virtual. + res.push(s.virt()); // "ACB" + res.push(bad.virt()); // "ACBD" + + // Indirectly call static. + res.push(s.indirect()); // "ACBDA" + res.push(bad.indirect()); // "ACBDAC" + + assert_eq!(&res, "ACBDAC"); +} diff --git a/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs new file mode 100644 index 000000000..df97d2c13 --- /dev/null +++ b/tests/ui/rfcs/rfc-2027-object-safe-for-dispatch/static-dispatch-unsafe-object.rs @@ -0,0 +1,37 @@ +// Check that we can statically dispatch methods for object +// unsafe trait objects, directly and indirectly +// +// check-pass + +#![feature(object_safe_for_dispatch)] + +trait Statics { + fn plain() {} + fn generic() {} +} + +trait Trait: Sized {} + +impl<'a> Statics for dyn Trait + 'a {} + +fn static_poly() { + T::plain(); + T::generic::(); +} + +fn inferred_poly(t: &T) { + static_poly::(); + T::plain(); + T::generic::(); +} + +fn call(t: &dyn Trait) { + static_poly::(); + inferred_poly(t); +} + +fn main() { + static_poly::(); + ::plain(); + ::generic::() +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/call-chain.rs b/tests/ui/rfcs/rfc-2091-track-caller/call-chain.rs new file mode 100644 index 000000000..a8814ce28 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/call-chain.rs @@ -0,0 +1,30 @@ +// run-pass +// revisions: default mir-opt +//[default] compile-flags: -Zinline-mir=false +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +use std::panic::Location; + +struct Foo; + +impl Foo { + #[inline(always)] + #[track_caller] + fn check_loc(&self, line: u32, col: u32) -> &Self { + let loc = Location::caller(); + assert_eq!(loc.file(), file!(), "file mismatch"); + assert_eq!(loc.line(), line, "line mismatch"); + assert_eq!(loc.column(), col, "column mismatch"); + self + } +} + +fn main() { + // Tests that when `Location::caller` is used in a method chain, + // it points to the start of the correct call (the first character after the dot) + // instead of to the very first expression in the chain + let foo = Foo; + foo. + check_loc(line!(), 9).check_loc(line!(), 31) + .check_loc(line!(), 10); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs new file mode 100644 index 000000000..a3bed707e --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs @@ -0,0 +1,32 @@ +// Ensure that a `#[track_caller]` function, returning `caller_location()`, +// which coerced (to a function pointer) and called, inside a `const fn`, +// in turn called, results in the same output irrespective of whether +// we're in a const or runtime context. + +// run-pass +// compile-flags: -Z unleash-the-miri-inside-of-you + +#![feature(core_intrinsics, const_caller_location)] + +type L = &'static std::panic::Location<'static>; + +#[track_caller] +const fn attributed() -> L { + std::intrinsics::caller_location() +} + +const fn calling_attributed() -> L { + // We need `-Z unleash-the-miri-inside-of-you` for this as we don't have `const fn` pointers. + let ptr: fn() -> L = attributed; + ptr() +} + +fn main() { + const CONSTANT: L = calling_attributed(); + let runtime = calling_attributed(); + + assert_eq!( + (runtime.file(), runtime.line(), runtime.column()), + (CONSTANT.file(), CONSTANT.line(), CONSTANT.column()), + ); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr new file mode 100644 index 000000000..cf8ca5771 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.stderr @@ -0,0 +1,10 @@ +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/caller-location-fnptr-rt-ctfe-equiv.rs:21:5 + | +LL | ptr() + | ^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-2091-track-caller/caller-location-intrinsic.rs b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-intrinsic.rs new file mode 100644 index 000000000..e5754d355 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/caller-location-intrinsic.rs @@ -0,0 +1,27 @@ +// run-pass +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +#[inline(never)] +#[track_caller] +fn codegen_caller_loc() -> &'static core::panic::Location<'static> { + core::panic::Location::caller() +} + +macro_rules! caller_location_from_macro { + () => (codegen_caller_loc()); +} + +fn main() { + let loc = codegen_caller_loc(); + assert_eq!(loc.file(), file!()); + assert_eq!(loc.line(), 16); + assert_eq!(loc.column(), 15); + + // `Location::caller()` in a macro should behave similarly to `file!` and `line!`, + // i.e. point to where the macro was invoked, instead of the macro itself. + let loc2 = caller_location_from_macro!(); + assert_eq!(loc2.file(), file!()); + assert_eq!(loc2.line(), 23); + assert_eq!(loc2.column(), 16); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs b/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs new file mode 100644 index 000000000..6e15cf3fe --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/const-caller-location.rs @@ -0,0 +1,43 @@ +// run-pass +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +#![feature(const_caller_location)] + +use std::panic::Location; + +const LOCATION: &Location = Location::caller(); + +const TRACKED: &Location = tracked(); +#[track_caller] +const fn tracked() -> &'static Location <'static> { + Location::caller() +} + +const NESTED: &Location = nested_location(); +const fn nested_location() -> &'static Location<'static> { + Location::caller() +} + +const CONTAINED: &Location = contained(); +const fn contained() -> &'static Location<'static> { + tracked() +} + +fn main() { + assert_eq!(LOCATION.file(), file!()); + assert_eq!(LOCATION.line(), 9); + assert_eq!(LOCATION.column(), 29); + + assert_eq!(TRACKED.file(), file!()); + assert_eq!(TRACKED.line(), 11); + assert_eq!(TRACKED.column(), 28); + + assert_eq!(NESTED.file(), file!()); + assert_eq!(NESTED.line(), 19); + assert_eq!(NESTED.column(), 5); + + assert_eq!(CONTAINED.file(), file!()); + assert_eq!(CONTAINED.line(), 24); + assert_eq!(CONTAINED.column(), 5); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/diverging-caller-location.rs b/tests/ui/rfcs/rfc-2091-track-caller/diverging-caller-location.rs new file mode 100644 index 000000000..668111955 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/diverging-caller-location.rs @@ -0,0 +1,17 @@ +// run-fail + +//! This test ensures that `#[track_caller]` can be applied directly to diverging functions, as +//! the tracking issue says: https://github.com/rust-lang/rust/issues/47809#issue-292138490. +//! Because the annotated function must diverge and a panic keeps that faster than an infinite loop, +//! we don't inspect the location returned -- it would be difficult to distinguish between the +//! explicit panic and a failed assertion. That it compiles and runs is enough for this one. + +#[track_caller] +fn doesnt_return() -> ! { + let _location = core::panic::Location::caller(); + panic!("huzzah"); +} + +fn main() { + doesnt_return(); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.rs new file mode 100644 index 000000000..6f4290e2a --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.rs @@ -0,0 +1,5 @@ +#[track_caller(1)] +fn f() {} +//~^^ ERROR malformed `track_caller` attribute input + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr new file mode 100644 index 000000000..e7ddf8df4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr @@ -0,0 +1,8 @@ +error: malformed `track_caller` attribute input + --> $DIR/error-odd-syntax.rs:1:1 + | +LL | #[track_caller(1)] + | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[track_caller]` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.rs new file mode 100644 index 000000000..074e1ceb7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.rs @@ -0,0 +1,11 @@ +#[track_caller] +extern "C" fn f() {} +//~^^ ERROR `#[track_caller]` requires Rust ABI + +extern "C" { + #[track_caller] + fn g(); + //~^^ ERROR `#[track_caller]` requires Rust ABI +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.stderr new file mode 100644 index 000000000..bcc0c8170 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-invalid-abi.stderr @@ -0,0 +1,15 @@ +error[E0737]: `#[track_caller]` requires Rust ABI + --> $DIR/error-with-invalid-abi.rs:1:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error[E0737]: `#[track_caller]` requires Rust ABI + --> $DIR/error-with-invalid-abi.rs:6:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0737`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-main.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-with-main.rs new file mode 100644 index 000000000..b2ea31bb5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-main.rs @@ -0,0 +1,4 @@ +#[track_caller] //~ ERROR `main` function is not allowed to be +fn main() { + panic!("{}: oh no", std::panic::Location::caller()); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-main.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-main.stderr new file mode 100644 index 000000000..6d6562dae --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-main.stderr @@ -0,0 +1,10 @@ +error: `main` function is not allowed to be `#[track_caller]` + --> $DIR/error-with-main.rs:1:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ help: remove this annotation +LL | fn main() { + | --------- `main` function is not allowed to be `#[track_caller]` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs new file mode 100644 index 000000000..43e33cbb1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs @@ -0,0 +1,24 @@ +// needs-asm-support +#![feature(naked_functions)] + +use std::arch::asm; + +#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` +//~^ ERROR `#[track_caller]` requires Rust ABI +#[naked] +extern "C" fn f() { + asm!("", options(noreturn)); +} + +struct S; + +impl S { + #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` + //~^ ERROR `#[track_caller]` requires Rust ABI + #[naked] + extern "C" fn g() { + asm!("", options(noreturn)); + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr new file mode 100644 index 000000000..3f7d0df42 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr @@ -0,0 +1,28 @@ +error[E0736]: cannot use `#[track_caller]` with `#[naked]` + --> $DIR/error-with-naked.rs:6:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error[E0736]: cannot use `#[track_caller]` with `#[naked]` + --> $DIR/error-with-naked.rs:16:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error[E0737]: `#[track_caller]` requires Rust ABI + --> $DIR/error-with-naked.rs:6:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error[E0737]: `#[track_caller]` requires Rust ABI + --> $DIR/error-with-naked.rs:16:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0736, E0737. +For more information about an error, try `rustc --explain E0736`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-start.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-with-start.rs new file mode 100644 index 000000000..0cab47170 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-start.rs @@ -0,0 +1,7 @@ +#![feature(start)] + +#[start] +#[track_caller] //~ ERROR `start` is not allowed to be `#[track_caller]` +fn start(_argc: isize, _argv: *const *const u8) -> isize { + panic!("{}: oh no", std::panic::Location::caller()); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-start.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-start.stderr new file mode 100644 index 000000000..454c98ff9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-start.stderr @@ -0,0 +1,10 @@ +error: `start` is not allowed to be `#[track_caller]` + --> $DIR/error-with-start.rs:4:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +LL | fn start(_argc: isize, _argv: *const *const u8) -> isize { + | -------------------------------------------------------- `start` is not allowed to be `#[track_caller]` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2091-track-caller/intrinsic-wrapper.rs b/tests/ui/rfcs/rfc-2091-track-caller/intrinsic-wrapper.rs new file mode 100644 index 000000000..23d2a4b0a --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/intrinsic-wrapper.rs @@ -0,0 +1,22 @@ +// run-pass +// revisions: default mir-opt +//[default] compile-flags: -Zinline-mir=no +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +macro_rules! caller_location_from_macro { + () => (core::panic::Location::caller()); +} + +fn main() { + let loc = core::panic::Location::caller(); + assert_eq!(loc.file(), file!()); + assert_eq!(loc.line(), 11); + assert_eq!(loc.column(), 15); + + // `Location::caller()` in a macro should behave similarly to `file!` and `line!`, + // i.e. point to where the macro was invoked, instead of the macro itself. + let loc2 = caller_location_from_macro!(); + assert_eq!(loc2.file(), file!()); + assert_eq!(loc2.line(), 18); + assert_eq!(loc2.column(), 16); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/macro-declaration.rs b/tests/ui/rfcs/rfc-2091-track-caller/macro-declaration.rs new file mode 100644 index 000000000..6ca09fac8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/macro-declaration.rs @@ -0,0 +1,10 @@ +// check-pass + +// See https://github.com/rust-lang/rust/issues/95151 +#[track_caller] +macro_rules! _foo { + () => {}; +} + +fn main() { +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/mir-inlined-macro.rs b/tests/ui/rfcs/rfc-2091-track-caller/mir-inlined-macro.rs new file mode 100644 index 000000000..a2e8eb27e --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/mir-inlined-macro.rs @@ -0,0 +1,23 @@ +// run-pass +// revisions: default mir-opt +//[default] compile-flags: -Zinline-mir=no +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +use std::panic::Location; + +macro_rules! f { + () => { + Location::caller() + }; +} + +#[inline(always)] +fn g() -> &'static Location<'static> { + f!() +} + +fn main() { + let loc = g(); + assert_eq!(loc.line(), 16); + assert_eq!(loc.column(), 5); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs new file mode 100644 index 000000000..2d2b01b6f --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs @@ -0,0 +1,5 @@ +#[track_caller] +struct S; +//~^^ ERROR attribute should be applied to a function definition + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr new file mode 100644 index 000000000..b36597bde --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr @@ -0,0 +1,11 @@ +error[E0739]: attribute should be applied to a function definition + --> $DIR/only-for-fns.rs:1:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ +LL | struct S; + | --------- not a function definition + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0739`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/pass.rs b/tests/ui/rfcs/rfc-2091-track-caller/pass.rs new file mode 100644 index 000000000..1b13ea3e9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/pass.rs @@ -0,0 +1,10 @@ +// run-pass +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +#[track_caller] +fn f() {} + +fn main() { + f(); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs b/tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs new file mode 100644 index 000000000..f11456250 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs @@ -0,0 +1,64 @@ +// run-pass +// needs-unwind +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +#![allow(unconditional_panic)] + +//! Test that panic locations for `#[track_caller]` functions in std have the correct +//! location reported. + +use std::cell::RefCell; +use std::collections::{BTreeMap, HashMap, VecDeque}; +use std::ops::{Index, IndexMut}; +use std::panic::{AssertUnwindSafe, UnwindSafe}; + +fn main() { + // inspect the `PanicInfo` we receive to ensure the right file is the source + std::panic::set_hook(Box::new(|info| { + let actual = info.location().unwrap(); + if actual.file() != file!() { + eprintln!("expected a location in the test file, found {:?}", actual); + panic!(); + } + })); + + fn assert_panicked(f: impl FnOnce() + UnwindSafe) { + std::panic::catch_unwind(f).unwrap_err(); + } + + let nope: Option<()> = None; + assert_panicked(|| nope.unwrap()); + assert_panicked(|| nope.expect("")); + + let oops: Result<(), ()> = Err(()); + assert_panicked(|| oops.unwrap()); + assert_panicked(|| oops.expect("")); + + let fine: Result<(), ()> = Ok(()); + assert_panicked(|| fine.unwrap_err()); + assert_panicked(|| fine.expect_err("")); + + let mut small = [0]; // the implementation backing str, vec, etc + assert_panicked(move || { small.index(1); }); + assert_panicked(move || { small[1]; }); + assert_panicked(move || { small.index_mut(1); }); + assert_panicked(move || { small[1] += 1; }); + + let sorted: BTreeMap = Default::default(); + assert_panicked(|| { sorted.index(&false); }); + assert_panicked(|| { sorted[&false]; }); + + let unsorted: HashMap = Default::default(); + assert_panicked(|| { unsorted.index(&false); }); + assert_panicked(|| { unsorted[&false]; }); + + let weirdo: VecDeque<()> = Default::default(); + assert_panicked(|| { weirdo.index(1); }); + assert_panicked(|| { weirdo[1]; }); + + let refcell: RefCell<()> = Default::default(); + let _conflicting = refcell.borrow_mut(); + assert_panicked(AssertUnwindSafe(|| { refcell.borrow(); })); + assert_panicked(AssertUnwindSafe(|| { refcell.borrow_mut(); })); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/track-caller-attribute.rs b/tests/ui/rfcs/rfc-2091-track-caller/track-caller-attribute.rs new file mode 100644 index 000000000..9d28eb9de --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/track-caller-attribute.rs @@ -0,0 +1,40 @@ +// run-pass +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +use std::panic::Location; + +#[track_caller] +fn tracked() -> &'static Location<'static> { + Location::caller() +} + +fn nested_intrinsic() -> &'static Location<'static> { + Location::caller() +} + +fn nested_tracked() -> &'static Location<'static> { + tracked() +} + +fn main() { + let location = Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), 21); + assert_eq!(location.column(), 20); + + let tracked = tracked(); + assert_eq!(tracked.file(), file!()); + assert_eq!(tracked.line(), 26); + assert_eq!(tracked.column(), 19); + + let nested = nested_intrinsic(); + assert_eq!(nested.file(), file!()); + assert_eq!(nested.line(), 13); + assert_eq!(nested.column(), 5); + + let contained = nested_tracked(); + assert_eq!(contained.file(), file!()); + assert_eq!(contained.line(), 17); + assert_eq!(contained.column(), 5); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/track-caller-ffi.rs b/tests/ui/rfcs/rfc-2091-track-caller/track-caller-ffi.rs new file mode 100644 index 000000000..5115f687c --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/track-caller-ffi.rs @@ -0,0 +1,48 @@ +// run-pass + +use std::panic::Location; + +extern "Rust" { + #[track_caller] + fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>; + fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static>; +} + +fn rust_track_caller_ffi_test_nested_tracked() -> &'static Location<'static> { + unsafe { rust_track_caller_ffi_test_tracked() } +} + +mod provides { + use std::panic::Location; + #[track_caller] // UB if we did not have this! + #[no_mangle] + fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static> { + Location::caller() + } + #[no_mangle] + fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static> { + Location::caller() + } +} + +fn main() { + let location = Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), 29); + assert_eq!(location.column(), 20); + + let tracked = unsafe { rust_track_caller_ffi_test_tracked() }; + assert_eq!(tracked.file(), file!()); + assert_eq!(tracked.line(), 34); + assert_eq!(tracked.column(), 28); + + let untracked = unsafe { rust_track_caller_ffi_test_untracked() }; + assert_eq!(untracked.file(), file!()); + assert_eq!(untracked.line(), 24); + assert_eq!(untracked.column(), 9); + + let contained = rust_track_caller_ffi_test_nested_tracked(); + assert_eq!(contained.file(), file!()); + assert_eq!(contained.line(), 12); + assert_eq!(contained.column(), 14); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs new file mode 100644 index 000000000..670c423a7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-closure.rs @@ -0,0 +1,154 @@ +// run-pass + +#![feature(stmt_expr_attributes)] +#![feature(closure_track_caller)] +#![feature(generator_trait)] +#![feature(generators)] + +use std::ops::{Generator, GeneratorState}; +use std::pin::Pin; +use std::panic::Location; + +type Loc = &'static Location<'static>; + +#[track_caller] +fn mono_invoke_fn (&'static str, bool, Loc)>( + val: &F +) -> (&'static str, bool, Loc) { + val("from_mono", false) +} + +#[track_caller] +fn mono_invoke_fn_once (&'static str, bool, Loc)>( + val: F +) -> (&'static str, bool, Loc) { + val("from_mono", false) +} + +#[track_caller] +fn dyn_invoke_fn_mut( + val: &mut dyn FnMut(&'static str, bool) -> (&'static str, bool, Loc) +) -> (&'static str, bool, Loc) { + val("from_dyn", false) +} + +#[track_caller] +fn dyn_invoke_fn_once( + val: Box (&'static str, bool, Loc)> +) -> (&'static str, bool, Loc) { + val("from_dyn", false) +} + + +fn test_closure() { + let mut track_closure = #[track_caller] |first: &'static str, second: bool| { + (first, second, Location::caller()) + }; + let (first_arg, first_bool, first_loc) = track_closure("first_arg", true); + let first_line = line!() - 1; + assert_eq!(first_arg, "first_arg"); + assert_eq!(first_bool, true); + assert_eq!(first_loc.file(), file!()); + assert_eq!(first_loc.line(), first_line); + assert_eq!(first_loc.column(), 46); + + let (dyn_arg, dyn_bool, dyn_loc) = dyn_invoke_fn_mut(&mut track_closure); + assert_eq!(dyn_arg, "from_dyn"); + assert_eq!(dyn_bool, false); + // `FnMut::call_mut` does not have `#[track_caller]`, + // so this will not match + assert_ne!(dyn_loc.file(), file!()); + + let (dyn_arg, dyn_bool, dyn_loc) = dyn_invoke_fn_once(Box::new(track_closure)); + assert_eq!(dyn_arg, "from_dyn"); + assert_eq!(dyn_bool, false); + // `FnOnce::call_once` does not have `#[track_caller]` + // so this will not match + assert_ne!(dyn_loc.file(), file!()); + + + let (mono_arg, mono_bool, mono_loc) = mono_invoke_fn(&track_closure); + let mono_line = line!() - 1; + assert_eq!(mono_arg, "from_mono"); + assert_eq!(mono_bool, false); + assert_eq!(mono_loc.file(), file!()); + assert_eq!(mono_loc.line(), mono_line); + assert_eq!(mono_loc.column(), 43); + + let (mono_arg, mono_bool, mono_loc) = mono_invoke_fn_once(track_closure); + let mono_line = line!() - 1; + assert_eq!(mono_arg, "from_mono"); + assert_eq!(mono_bool, false); + assert_eq!(mono_loc.file(), file!()); + assert_eq!(mono_loc.line(), mono_line); + assert_eq!(mono_loc.column(), 43); + + let non_tracked_caller = || Location::caller(); + let non_tracked_line = line!() - 1; // This is the line of the closure, not its caller + let non_tracked_loc = non_tracked_caller(); + assert_eq!(non_tracked_loc.file(), file!()); + assert_eq!(non_tracked_loc.line(), non_tracked_line); + assert_eq!(non_tracked_loc.column(), 33); +} + + +#[track_caller] +fn mono_generator>( + val: Pin<&mut F> +) -> (&'static str, String, Loc) { + match val.resume("Mono".to_string()) { + GeneratorState::Yielded(val) => val, + _ => unreachable!() + } +} + +#[track_caller] +fn dyn_generator( + val: Pin<&mut dyn Generator> +) -> (&'static str, String, Loc) { + match val.resume("Dyn".to_string()) { + GeneratorState::Yielded(val) => val, + _ => unreachable!() + } +} + +fn test_generator() { + let generator = #[track_caller] |arg: String| { + yield ("first", arg.clone(), Location::caller()); + yield ("second", arg.clone(), Location::caller()); + }; + + let mut pinned = Box::pin(generator); + let (dyn_ret, dyn_arg, dyn_loc) = dyn_generator(pinned.as_mut()); + assert_eq!(dyn_ret, "first"); + assert_eq!(dyn_arg, "Dyn".to_string()); + // The `Generator` trait does not have `#[track_caller]` on `resume`, so + // this will not match. + assert_ne!(dyn_loc.file(), file!()); + + + let (mono_ret, mono_arg, mono_loc) = mono_generator(pinned.as_mut()); + let mono_line = line!() - 1; + assert_eq!(mono_ret, "second"); + // The generator ignores the argument to the second `resume` call + assert_eq!(mono_arg, "Dyn".to_string()); + assert_eq!(mono_loc.file(), file!()); + assert_eq!(mono_loc.line(), mono_line); + assert_eq!(mono_loc.column(), 42); + + let non_tracked_generator = || { yield Location::caller(); }; + let non_tracked_line = line!() - 1; // This is the line of the generator, not its caller + let non_tracked_loc = match Box::pin(non_tracked_generator).as_mut().resume(()) { + GeneratorState::Yielded(val) => val, + _ => unreachable!() + }; + assert_eq!(non_tracked_loc.file(), file!()); + assert_eq!(non_tracked_loc.line(), non_tracked_line); + assert_eq!(non_tracked_loc.column(), 44); + +} + +fn main() { + test_closure(); + test_generator(); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs new file mode 100644 index 000000000..658812578 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr-with-arg.rs @@ -0,0 +1,62 @@ +// run-pass +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +fn pass_to_ptr_call(f: fn(T), x: T) { + f(x); +} + +#[track_caller] +fn tracked_unit(_: ()) { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); +} + +trait Trait { + fn trait_tracked_unit(_: ()); +} + +impl Trait for () { + #[track_caller] + fn trait_tracked_unit(_: ()) { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); + } +} + +trait TrackedTrait { + #[track_caller] + fn trait_tracked_unit_default(_: ()) { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); + } +} + +impl TrackedTrait for () {} + +trait BlanketTrackedTrait { + #[track_caller] + fn tracked_blanket(_: ()); +} + +impl BlanketTrackedTrait for () { + fn tracked_blanket(_: ()) { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); + } +} + +fn main() { + pass_to_ptr_call(tracked_unit, ()); + pass_to_ptr_call(<() as Trait>::trait_tracked_unit, ()); + pass_to_ptr_call(<() as TrackedTrait>::trait_tracked_unit_default, ()); + pass_to_ptr_call(<() as BlanketTrackedTrait>::tracked_blanket, ()); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr.rs new file mode 100644 index 000000000..8bb4dd288 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-fn-ptr.rs @@ -0,0 +1,62 @@ +// run-pass +// revisions: default mir-opt +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +fn ptr_call(f: fn()) { + f(); +} + +#[track_caller] +fn tracked() { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); +} + +trait Trait { + fn trait_tracked(); +} + +impl Trait for () { + #[track_caller] + fn trait_tracked() { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); + } +} + +trait TrackedTrait { + #[track_caller] + fn trait_tracked_default() { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); + } +} + +impl TrackedTrait for () {} + +trait TraitBlanketTracked { + #[track_caller] + fn tracked_blanket(); +} + +impl TraitBlanketTracked for () { + fn tracked_blanket() { + let expected_line = line!() - 1; + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), expected_line, "call shims report location as fn definition"); + } +} + +fn main() { + ptr_call(tracked); + ptr_call(<() as Trait>::trait_tracked); + ptr_call(<() as TrackedTrait>::trait_tracked_default); + ptr_call(<() as TraitBlanketTracked>::tracked_blanket); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-impls.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-impls.rs new file mode 100644 index 000000000..4db4c29e5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-impls.rs @@ -0,0 +1,77 @@ +// run-pass + +macro_rules! assert_expansion_site_is_tracked { + () => {{ + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_ne!(location.line(), line!(), "line should be outside this fn"); + }} +} + +trait Tracked { + fn local_tracked(&self); + + #[track_caller] + fn blanket_tracked(&self); + + #[track_caller] + fn default_tracked(&self) { + assert_expansion_site_is_tracked!(); + } +} + +impl Tracked for () { + #[track_caller] + fn local_tracked(&self) { + assert_expansion_site_is_tracked!(); + } + + fn blanket_tracked(&self) { + assert_expansion_site_is_tracked!(); + } +} + +impl Tracked for bool { + #[track_caller] + fn local_tracked(&self) { + assert_expansion_site_is_tracked!(); + } + + fn blanket_tracked(&self) { + assert_expansion_site_is_tracked!(); + } + + fn default_tracked(&self) { + assert_expansion_site_is_tracked!(); + } +} + +impl Tracked for u8 { + #[track_caller] + fn local_tracked(&self) { + assert_expansion_site_is_tracked!(); + } + + fn blanket_tracked(&self) { + assert_expansion_site_is_tracked!(); + } + + #[track_caller] + fn default_tracked(&self) { + assert_expansion_site_is_tracked!(); + } +} + +fn main() { + ().local_tracked(); + ().default_tracked(); + ().blanket_tracked(); + + true.local_tracked(); + true.default_tracked(); + true.blanket_tracked(); + + 0u8.local_tracked(); + 0u8.default_tracked(); + 0u8.blanket_tracked(); +} diff --git a/tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-obj.rs b/tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-obj.rs new file mode 100644 index 000000000..06883a857 --- /dev/null +++ b/tests/ui/rfcs/rfc-2091-track-caller/tracked-trait-obj.rs @@ -0,0 +1,61 @@ +// run-pass + +trait Tracked { + #[track_caller] + fn track_caller_trait_method(&self, line: u32, col: u32) { + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + // The trait method definition is annotated with `#[track_caller]`, + // so caller location information will work through a method + // call on a trait object + assert_eq!(location.line(), line, "Bad line"); + assert_eq!(location.column(), col, "Bad col"); + } + + fn track_caller_not_on_trait_method(&self); + + #[track_caller] + fn track_caller_through_self(self: Box, line: u32, col: u32); +} + +impl Tracked for () { + // We have `#[track_caller]` on the implementation of the method, + // but not on the definition of the method in the trait. Therefore, + // caller location information will *not* work through a method call + // on a trait object. Instead, we will get the location of this method + #[track_caller] + fn track_caller_not_on_trait_method(&self) { + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), line!() - 3); + assert_eq!(location.column(), 5); + } + + // We don't have a `#[track_caller]` attribute, but + // `#[track_caller]` is present on the trait definition, + // so we'll still get location information + fn track_caller_through_self(self: Box, line: u32, col: u32) { + let location = std::panic::Location::caller(); + assert_eq!(location.file(), file!()); + // The trait method definition is annotated with `#[track_caller]`, + // so caller location information will work through a method + // call on a trait object + assert_eq!(location.line(), line, "Bad line"); + assert_eq!(location.column(), col, "Bad col"); + } +} + +fn main() { + let tracked: &dyn Tracked = &(); + // The column is the start of 'track_caller_trait_method' + tracked.track_caller_trait_method(line!(), 13); + + const TRACKED: &dyn Tracked = &(); + // The column is the start of 'track_caller_trait_method' + TRACKED.track_caller_trait_method(line!(), 13); + TRACKED.track_caller_not_on_trait_method(); + + // The column is the start of `track_caller_through_self` + let boxed: Box = Box::new(()); + boxed.track_caller_through_self(line!(), 11); +} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.rs new file mode 100644 index 000000000..a9bfeabf1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.rs @@ -0,0 +1,8 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'a, T> { //~ ERROR rustc_outlives + bar: std::slice::IterMut<'a, T> +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.stderr new file mode 100644 index 000000000..76300cce5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/cross-crate.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/cross-crate.rs:4:1 + | +LL | struct Foo<'a, T> { + | ^^^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.rs new file mode 100644 index 000000000..d3940b13b --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.rs @@ -0,0 +1,12 @@ +/* + * We don't infer `T: 'static` outlives relationships. + */ + +struct Foo { + bar: Bar //~ ERROR the parameter type `U` may not live long enough [E0310] +} +struct Bar { + x: T, +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.stderr new file mode 100644 index 000000000..0c388f5fe --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/dont-infer-static.stderr @@ -0,0 +1,19 @@ +error[E0310]: the parameter type `U` may not live long enough + --> $DIR/dont-infer-static.rs:6:10 + | +LL | bar: Bar + | ^^^^^^ ...so that the type `U` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/dont-infer-static.rs:8:15 + | +LL | struct Bar { + | ^^^^^^^ +help: consider adding an explicit lifetime bound... + | +LL | struct Foo { + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/enum.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/enum.rs new file mode 100644 index 000000000..71d2d3222 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/enum.rs @@ -0,0 +1,27 @@ +#![feature(rustc_attrs)] + +// Needs an explicit where clause stating outlives condition. (RFC 2093) + +// Type T needs to outlive lifetime 'a. +#[rustc_outlives] +enum Foo<'a, T> { //~ ERROR rustc_outlives + One(Bar<'a, T>) +} + +// Type U needs to outlive lifetime 'b +#[rustc_outlives] +struct Bar<'b, U> { //~ ERROR rustc_outlives + field2: &'b U +} + +// Type K needs to outlive lifetime 'c. +#[rustc_outlives] +enum Ying<'c, K> { //~ ERROR rustc_outlives + One(&'c Yang) +} + +struct Yang { + field2: V +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/enum.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/enum.stderr new file mode 100644 index 000000000..b6ce2450e --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/enum.stderr @@ -0,0 +1,26 @@ +error: rustc_outlives + --> $DIR/enum.rs:7:1 + | +LL | enum Foo<'a, T> { + | ^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: rustc_outlives + --> $DIR/enum.rs:13:1 + | +LL | struct Bar<'b, U> { + | ^^^^^^^^^^^^^^^^^ + | + = note: U: 'b + +error: rustc_outlives + --> $DIR/enum.rs:19:1 + | +LL | enum Ying<'c, K> { + | ^^^^^^^^^^^^^^^^ + | + = note: K: 'c + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.rs new file mode 100644 index 000000000..419fb0a0e --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.rs @@ -0,0 +1,12 @@ +#![feature(rustc_attrs)] + +trait Trait<'x, T> where T: 'x { +} + +#[rustc_outlives] +struct Foo<'a, A> //~ ERROR rustc_outlives +{ + foo: Box> +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.stderr new file mode 100644 index 000000000..595a5c280 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-dyn.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/explicit-dyn.rs:7:1 + | +LL | struct Foo<'a, A> + | ^^^^^^^^^^^^^^^^^ + | + = note: A: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.rs new file mode 100644 index 000000000..c330c27fe --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.rs @@ -0,0 +1,13 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +enum Foo<'a, U> { //~ ERROR rustc_outlives + One(Bar<'a, U>) +} + +struct Bar<'x, T> where T: 'x { + x: &'x (), + y: T, +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.stderr new file mode 100644 index 000000000..3059f95ae --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-enum.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/explicit-enum.rs:4:1 + | +LL | enum Foo<'a, U> { + | ^^^^^^^^^^^^^^^ + | + = note: U: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.rs new file mode 100644 index 000000000..00b895288 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.rs @@ -0,0 +1,13 @@ +#![feature(rustc_attrs)] + +trait Trait<'x, T> where T: 'x { + type Type; +} + +#[rustc_outlives] +struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives +{ + foo: >::Type +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.stderr new file mode 100644 index 000000000..589e95899 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-projection.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/explicit-projection.rs:8:1 + | +LL | struct Foo<'a, A, B> where A: Trait<'a, B> + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: B: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.rs new file mode 100644 index 000000000..3d5e610b9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.rs @@ -0,0 +1,13 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'b, U> { //~ ERROR rustc_outlives + bar: Bar<'b, U> +} + +struct Bar<'a, T> where T: 'a { + x: &'a (), + y: T, +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.stderr new file mode 100644 index 000000000..9912e36b2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-struct.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/explicit-struct.rs:4:1 + | +LL | struct Foo<'b, U> { + | ^^^^^^^^^^^^^^^^^ + | + = note: U: 'b + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.rs new file mode 100644 index 000000000..871208b5b --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.rs @@ -0,0 +1,14 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +union Foo<'b, U: Copy> { //~ ERROR rustc_outlives + bar: Bar<'b, U> +} + +#[derive(Clone, Copy)] +union Bar<'a, T: Copy> where T: 'a { + x: &'a (), + y: T, +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.stderr new file mode 100644 index 000000000..16b64bdc2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/explicit-union.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/explicit-union.rs:4:1 + | +LL | union Foo<'b, U: Copy> { + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: U: 'b + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/issue-54467.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/issue-54467.rs new file mode 100644 index 000000000..c712f15e3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/issue-54467.rs @@ -0,0 +1,17 @@ +// Regression test for #54467: +// +// Here, the trait object has an "inferred outlives" requirement that +// `>::Item: 'a`; but since we don't know what +// `Self` is, we were (incorrectly) messing things up, leading to +// strange errors. This test ensures that we do not give compilation +// errors. +// +// check-pass + +trait MyIterator<'a>: Iterator where Self::Item: 'a { } + +struct MyStruct<'a, A> { + item: Box> +} + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.rs new file mode 100644 index 000000000..0cd706e7a --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.rs @@ -0,0 +1,13 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +enum Foo<'a, T> { //~ ERROR rustc_outlives + + One(Bar<'a, T>) +} + +struct Bar<'b, U> { + field2: &'b U +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.stderr new file mode 100644 index 000000000..4350e6e8b --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-enum.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/nested-enum.rs:4:1 + | +LL | enum Foo<'a, T> { + | ^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.rs new file mode 100644 index 000000000..a01c50681 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.rs @@ -0,0 +1,8 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives + x: &'a &'b T +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.stderr new file mode 100644 index 000000000..c08add7ed --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-regions.stderr @@ -0,0 +1,12 @@ +error: rustc_outlives + --> $DIR/nested-regions.rs:4:1 + | +LL | struct Foo<'a, 'b, T> { + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: 'b: 'a + = note: T: 'a + = note: T: 'b + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.rs new file mode 100644 index 000000000..ac6817d22 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.rs @@ -0,0 +1,12 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'a, T> { //~ ERROR rustc_outlives + field1: Bar<'a, T> +} + +struct Bar<'b, U> { + field2: &'b U +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.stderr new file mode 100644 index 000000000..769555234 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-structs.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/nested-structs.rs:4:1 + | +LL | struct Foo<'a, T> { + | ^^^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.rs new file mode 100644 index 000000000..27ebd0b54 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.rs @@ -0,0 +1,14 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +union Foo<'a, T: Copy> { //~ ERROR rustc_outlives + field1: Bar<'a, T> +} + +// Type U needs to outlive lifetime 'b +#[derive(Clone, Copy)] +union Bar<'b, U: Copy> { + field2: &'b U +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.stderr new file mode 100644 index 000000000..a785c63ce --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/nested-union.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/nested-union.rs:4:1 + | +LL | union Foo<'a, T: Copy> { + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs new file mode 100644 index 000000000..180f5ac6c --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/privacy.rs @@ -0,0 +1,20 @@ +// Test that we do not get a privacy error here. Initially, we did, +// because we inferred an outlives predciate of ` as +// Private>::Out: 'a`, but the private trait is -- well -- private, +// and hence it was not something that a pub trait could refer to. +// +// run-pass + +#![allow(dead_code)] + +pub struct Foo<'a> { + field: Option<&'a as Private>::Out> +} + +trait Private { + type Out: ?Sized; +} + +impl Private for T { type Out = Self; } + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/projection.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/projection.rs new file mode 100644 index 000000000..411c86da1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/projection.rs @@ -0,0 +1,8 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives + bar: &'a T::Item +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/projection.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/projection.stderr new file mode 100644 index 000000000..d9342013f --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/projection.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/projection.rs:4:1 + | +LL | struct Foo<'a, T: Iterator> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ::Item: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/reference.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/reference.rs new file mode 100644 index 000000000..a48a3315a --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/reference.rs @@ -0,0 +1,8 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'a, T> { //~ ERROR rustc_outlives + bar: &'a T, +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/reference.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/reference.stderr new file mode 100644 index 000000000..508114357 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/reference.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/reference.rs:4:1 + | +LL | struct Foo<'a, T> { + | ^^^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs new file mode 100644 index 000000000..8b491ee4e --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.rs @@ -0,0 +1,39 @@ +// Various examples of structs whose fields are not well-formed. + +#![allow(dead_code)] + +trait Dummy<'a> { + type Out; +} +impl<'a, T> Dummy<'a> for T +where + T: 'a, +{ + type Out = (); +} +type RequireOutlives<'a, T> = >::Out; + +enum Ref1<'a, T> { + Ref1Variant1(RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough +} + +enum Ref2<'a, T> { + Ref2Variant1, + Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough +} + +enum RefOk<'a, T: 'a> { + RefOkVariant1(&'a T), +} + +// This is now well formed. RFC 2093 +enum RefIndirect<'a, T> { + RefIndirectVariant1(isize, RefOk<'a, T>), +} + +enum RefDouble<'a, 'b, T> { + RefDoubleVariant1(&'a RequireOutlives<'b, T>), + //~^ the parameter type `T` may not live long enough [E0309] +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr new file mode 100644 index 000000000..2c660b285 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-enum-not-wf.stderr @@ -0,0 +1,36 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:17:18 + | +LL | Ref1Variant1(RequireOutlives<'a, T>), + | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | enum Ref1<'a, T: 'a> { + | ++++ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:22:25 + | +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), + | ^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | enum Ref2<'a, T: 'a> { + | ++++ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:35:23 + | +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | enum RefDouble<'a, 'b, T: 'b> { + | ++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs new file mode 100644 index 000000000..36b024d2e --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs @@ -0,0 +1,22 @@ +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + + +#![allow(dead_code)] + +mod rev_variant_struct_region { + struct Foo<'a> { + x: fn(&'a i32), + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + } +} + + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr new file mode 100644 index 000000000..5dff4c8ff --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:20 + | +LL | type Out = &'a Foo<'b>; + | ^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs new file mode 100644 index 000000000..47a38f7c4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs @@ -0,0 +1,22 @@ +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + + +#![allow(dead_code)] + +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + } +} + + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr new file mode 100644 index 000000000..975776cdd --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-region.rs:17:20 + | +LL | type Out = &'a Foo<'b>; + | ^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-nominal-type-region.rs:16:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-nominal-type-region.rs:16:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs new file mode 100644 index 000000000..083ba8948 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs @@ -0,0 +1,22 @@ +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + + +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: fn(T) + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + } +} + + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr new file mode 100644 index 000000000..be05ecec0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:20 + | +LL | type Out = &'a Foo<&'b i32>; + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs new file mode 100644 index 000000000..f3e4e39ac --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs @@ -0,0 +1,22 @@ +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + + +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + } +} + + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr new file mode 100644 index 000000000..4ba1778d6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-type.rs:17:20 + | +LL | type Out = &'a Foo<&'b i32>; + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-nominal-type-type.rs:16:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-nominal-type-type.rs:16:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.rs new file mode 100644 index 000000000..552c6cf00 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.rs @@ -0,0 +1,28 @@ +// Various examples of structs whose fields are not well-formed. + +#![allow(dead_code)] + +trait Trait<'a, T> { + type Out; +} +trait Trait1<'a, 'b, T> { + type Out; +} + +impl<'a, T> Trait<'a, T> for usize { + type Out = &'a T; //~ ERROR `T` may not live long enough +} + +struct RefOk<'a, T:'a> { + field: &'a T +} + +impl<'a, T> Trait<'a, T> for u32 { + type Out = RefOk<'a, T>; //~ ERROR `T` may not live long enough +} + +impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + type Out = &'a &'b T; //~ ERROR reference has a longer lifetime than the data +} + +fn main() { } diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr new file mode 100644 index 000000000..34ff1362c --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -0,0 +1,48 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:13:16 + | +LL | type Out = &'a T; + | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for usize { + | ++++ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:21:16 + | +LL | type Out = RefOk<'a, T>; + | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/regions-struct-not-wf.rs:16:20 + | +LL | struct RefOk<'a, T:'a> { + | ^^ +help: consider adding an explicit lifetime bound... + | +LL | impl<'a, T: 'a> Trait<'a, T> for u32 { + | ++++ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:25:16 + | +LL | type Out = &'a &'b T; + | ^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-struct-not-wf.rs:24:6 + | +LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-struct-not-wf.rs:24:10 + | +LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + | ^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.rs new file mode 100644 index 000000000..c53d6c18f --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.rs @@ -0,0 +1,13 @@ +#![feature(rustc_attrs)] + +trait Trait<'x, 's, T> where T: 'x, + 's: { +} + +#[rustc_outlives] +struct Foo<'a, 'b, A> //~ ERROR rustc_outlives +{ + foo: Box> +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.stderr new file mode 100644 index 000000000..9c836b190 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/self-dyn.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/self-dyn.rs:8:1 + | +LL | struct Foo<'a, 'b, A> + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: A: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.rs b/tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.rs new file mode 100644 index 000000000..8f2d29d6f --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.rs @@ -0,0 +1,13 @@ +#![feature(rustc_attrs)] + +#[rustc_outlives] +struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives + field1: dyn Bar<'a, 'b, T> +} + +trait Bar<'x, 's, U> + where U: 'x, + Self:'s +{} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.stderr new file mode 100644 index 000000000..2b4625f77 --- /dev/null +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/self-structs.stderr @@ -0,0 +1,10 @@ +error: rustc_outlives + --> $DIR/self-structs.rs:4:1 + | +LL | struct Foo<'a, 'b, T> { + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: T: 'a + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs new file mode 100644 index 000000000..79f6b0dfe --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.rs @@ -0,0 +1,11 @@ +struct S; + +pub mod m { + fn f() { + let s = ::m::crate::S; //~ ERROR failed to resolve + let s1 = ::crate::S; //~ ERROR failed to resolve + let s2 = crate::S; // no error + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr new file mode 100644 index 000000000..7e7ee3ce0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-crate-paths/crate-path-non-absolute.stderr @@ -0,0 +1,15 @@ +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/crate-path-non-absolute.rs:5:22 + | +LL | let s = ::m::crate::S; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `crate` + --> $DIR/crate-path-non-absolute.rs:6:20 + | +LL | let s1 = ::crate::S; + | ^^^^^ global paths cannot start with `crate` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs new file mode 100644 index 000000000..019ef8e9d --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.rs @@ -0,0 +1,4 @@ +fn main() { + let crate = 0; + //~^ ERROR expected unit struct, unit variant or constant, found module `crate` +} diff --git a/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr new file mode 100644 index 000000000..c39a70f66 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr @@ -0,0 +1,9 @@ +error[E0532]: expected unit struct, unit variant or constant, found module `crate` + --> $DIR/keyword-crate-as-identifier.rs:2:9 + | +LL | let crate = 0; + | ^^^^^ not a unit struct, unit variant or constant + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs new file mode 100644 index 000000000..c4d444764 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs @@ -0,0 +1,5 @@ +#[derive(Debug)] +pub struct S; + +#[derive(Debug)] +pub struct Z; diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs new file mode 100644 index 000000000..9c0e0bef4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.rs @@ -0,0 +1,5 @@ +// edition:2018 + +use xcrate::S; //~ ERROR unresolved import `xcrate` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr new file mode 100644 index 000000000..818915721 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-1.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `xcrate` + --> $DIR/non-existent-1.rs:3:5 + | +LL | use xcrate::S; + | ^^^^^^ use of undeclared crate or module `xcrate` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs new file mode 100644 index 000000000..def60feb5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.rs @@ -0,0 +1,6 @@ +// edition:2018 + +fn main() { + let s = ::xcrate::S; + //~^ ERROR failed to resolve: could not find `xcrate` in the list of imported crates +} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr new file mode 100644 index 000000000..7df4f06d1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-2.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: could not find `xcrate` in the list of imported crates + --> $DIR/non-existent-2.rs:4:15 + | +LL | let s = ::xcrate::S; + | ^^^^^^ could not find `xcrate` in the list of imported crates + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs new file mode 100644 index 000000000..486159c0e --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.rs @@ -0,0 +1,5 @@ +// edition:2018 + +use ycrate; //~ ERROR unresolved import `ycrate` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr new file mode 100644 index 000000000..bd6778cf3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/non-existent-3.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `ycrate` + --> $DIR/non-existent-3.rs:3:5 + | +LL | use ycrate; + | ^^^^^^ no external crate `ycrate` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs new file mode 100644 index 000000000..acb4bbebe --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.rs @@ -0,0 +1,9 @@ +// edition:2018 + +// Tests that arbitrary crates (other than `core`, `std` and `meta`) +// aren't allowed without `--extern`, even if they're in the sysroot. +use alloc; //~ ERROR unresolved import `alloc` +use test; // OK, imports the built-in attribute macro `#[test]`, but not the `test` crate. +use proc_macro; // OK, imports the built-in `proc_macro` attribute, but not the `proc_macro` crate. + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr new file mode 100644 index 000000000..122e8fd35 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/not-allowed.stderr @@ -0,0 +1,16 @@ +error[E0432]: unresolved import `alloc` + --> $DIR/not-allowed.rs:5:5 + | +LL | use alloc; + | ^^^^^ no external crate `alloc` + | +help: consider importing one of these items instead + | +LL | use core::alloc; + | ~~~~~~~~~~~ +LL | use std::alloc; + | ~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs new file mode 100644 index 000000000..72e50d78b --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.rs @@ -0,0 +1,11 @@ +// aux-build:xcrate.rs +// compile-flags:--extern xcrate +// edition:2018 + +use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` +use *; //~ ERROR cannot glob-import all possible crates + +fn main() { + let s = ::xcrate; //~ ERROR expected value, found crate `xcrate` + //~^ NOTE not a value +} diff --git a/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr new file mode 100644 index 000000000..253cc1bc5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2126-extern-absolute-paths/single-segment.stderr @@ -0,0 +1,21 @@ +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/single-segment.rs:5:5 + | +LL | use crate; + | ^^^^^ + +error: cannot glob-import all possible crates + --> $DIR/single-segment.rs:6:5 + | +LL | use *; + | ^ + +error[E0423]: expected value, found crate `xcrate` + --> $DIR/single-segment.rs:9:13 + | +LL | let s = ::xcrate; + | ^^^^^^^^ not a value + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs new file mode 100644 index 000000000..1f32e4af1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs @@ -0,0 +1,9 @@ +#![feature(if_let_guard)] + +fn main() { + match Some(None) { + Some(x) if let Some(y) = x => (x, y), + _ => y, //~ ERROR cannot find value `y` + } + y //~ ERROR cannot find value `y` +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr new file mode 100644 index 000000000..2463b7f3e --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr @@ -0,0 +1,15 @@ +error[E0425]: cannot find value `y` in this scope + --> $DIR/bindings.rs:6:14 + | +LL | _ => y, + | ^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/bindings.rs:8:5 + | +LL | y + | ^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs new file mode 100644 index 000000000..3beb20f0a --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs @@ -0,0 +1,96 @@ +// gate-test-if_let_guard + +use std::ops::Range; + +fn _if_let_guard() { + match () { + () if let 0 = 1 => {} + //~^ ERROR `if let` guards are experimental + + () if (let 0 = 1) => {} + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + + () if (((let 0 = 1))) => {} + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + + () if true && let 0 = 1 => {} + //~^ ERROR `if let` guards are experimental + //~| ERROR `let` expressions in this position are unstable + + () if let 0 = 1 && true => {} + //~^ ERROR `if let` guards are experimental + //~| ERROR `let` expressions in this position are unstable + + () if (let 0 = 1) && true => {} + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + + () if true && (let 0 = 1) => {} + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + + () if (let 0 = 1) && (let 0 = 1) => {} + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + + () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + //~^ ERROR `if let` guards are experimental + //~| ERROR `let` expressions in this position are unstable + //~| ERROR `let` expressions in this position are unstable + //~| ERROR `let` expressions in this position are unstable + //~| ERROR `let` expressions in this position are unstable + //~| ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + + + () if let Range { start: _, end: _ } = (true..true) && false => {} + //~^ ERROR `if let` guards are experimental + //~| ERROR `let` expressions in this position are unstable + + _ => {} + } +} + +fn _macros() { + macro_rules! use_expr { + ($e:expr) => { + match () { + () if $e => {} + _ => {} + } + } + } + use_expr!((let 0 = 1 && 0 == 0)); + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + use_expr!((let 0 = 1)); + //~^ ERROR `let` expressions in this position are unstable + //~| ERROR expected expression, found `let` statement + //~| ERROR `let` expressions are not supported here + match () { + #[cfg(FALSE)] + () if let 0 = 1 => {} + //~^ ERROR `if let` guards are experimental + _ => {} + } + use_expr!(let 0 = 1); + //~^ ERROR no rules expected the token `let` +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr new file mode 100644 index 000000000..dc182ce46 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr @@ -0,0 +1,431 @@ +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:15:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:28:16 + | +LL | () if (let 0 = 1) && true => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:33:24 + | +LL | () if true && (let 0 = 1) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:38:16 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:38:31 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:46:55 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:46:68 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:78:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:82:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + +error: no rules expected the token `let` + --> $DIR/feature-gate.rs:92:15 + | +LL | macro_rules! use_expr { + | --------------------- when calling this macro +... +LL | use_expr!(let 0 = 1); + | ^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/feature-gate.rs:71:10 + | +LL | ($e:expr) => { + | ^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:15:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:15:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:28:16 + | +LL | () if (let 0 = 1) && true => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:28:16 + | +LL | () if (let 0 = 1) && true => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:33:24 + | +LL | () if true && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:33:24 + | +LL | () if true && (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:38:16 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:38:16 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:38:31 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:38:31 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:46:55 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:46:68 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:78:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:78:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/feature-gate.rs:82:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/feature-gate.rs:82:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + +error[E0658]: `if let` guards are experimental + --> $DIR/feature-gate.rs:7:12 + | +LL | () if let 0 = 1 => {} + | ^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `if let` guards are experimental + --> $DIR/feature-gate.rs:20:12 + | +LL | () if true && let 0 = 1 => {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `if let` guards are experimental + --> $DIR/feature-gate.rs:24:12 + | +LL | () if let 0 = 1 && true => {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `if let` guards are experimental + --> $DIR/feature-gate.rs:46:12 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `if let` guards are experimental + --> $DIR/feature-gate.rs:61:12 + | +LL | () if let Range { start: _, end: _ } = (true..true) && false => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `if let` guards are experimental + --> $DIR/feature-gate.rs:88:12 + | +LL | () if let 0 = 1 => {} + | ^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:10:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:15:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:20:23 + | +LL | () if true && let 0 = 1 => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:24:15 + | +LL | () if let 0 = 1 && true => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:28:16 + | +LL | () if (let 0 = 1) && true => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:33:24 + | +LL | () if true && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:38:16 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:38:31 + | +LL | () if (let 0 = 1) && (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:46:15 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:46:28 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:46:42 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:46:55 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:46:68 + | +LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:61:15 + | +LL | () if let Range { start: _, end: _ } = (true..true) && false => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:78:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:82:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error: aborting due to 45 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs new file mode 100644 index 000000000..a303a0d1f --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs @@ -0,0 +1,40 @@ +// run-pass + +#![feature(if_let_guard)] + +enum Foo { + Bar, + Baz, + Qux(u8), +} + +fn bar(x: bool) -> Foo { + if x { Foo::Baz } else { Foo::Bar } +} + +fn baz(x: u8) -> Foo { + if x % 2 == 0 { Foo::Bar } else { Foo::Baz } +} + +fn qux(x: u8) -> Foo { + Foo::Qux(x.rotate_left(1)) +} + +fn main() { + match Some((true, 3)) { + Some((x, _)) if let Foo::Bar = bar(x) => panic!(), + Some((_, x)) if let Foo::Baz = baz(x) => {}, + _ => panic!(), + } + match Some(42) { + Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84), + _ => panic!(), + } + + // issue #88015 + #[allow(irrefutable_let_patterns)] + match () { + () | () if let x = 42 => assert_eq!(x, 42), + _ => panic!() + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs new file mode 100644 index 000000000..ad178dfa4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs @@ -0,0 +1,15 @@ +#![feature(if_let_guard)] + +fn ok() -> Result, ()> { + Ok(Some(true)) +} + +fn main() { + match ok() { + Ok(x) if let Err(_) = x => {}, + //~^ ERROR mismatched types + Ok(x) if let 0 = x => {}, + //~^ ERROR mismatched types + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr new file mode 100644 index 000000000..4ce97a68a --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/typeck.rs:9:22 + | +LL | Ok(x) if let Err(_) = x => {}, + | ^^^^^^ - this expression has type `Option` + | | + | expected `Option`, found `Result<_, _>` + | + = note: expected enum `Option` + found enum `Result<_, _>` + +error[E0308]: mismatched types + --> $DIR/typeck.rs:11:22 + | +LL | Ok(x) if let 0 = x => {}, + | ^ - this expression has type `Option` + | | + | expected `Option`, found integer + | + = note: expected enum `Option` + found type `{integer}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs new file mode 100644 index 000000000..3ad1a50c6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs @@ -0,0 +1,21 @@ +#![feature(if_let_guard)] + +#[deny(irrefutable_let_patterns)] +fn irrefutable_let_guard() { + match Some(()) { + Some(x) if let () = x => {} + //~^ ERROR irrefutable `if let` guard + _ => {} + } +} + +#[deny(unreachable_patterns)] +fn unreachable_pattern() { + match Some(()) { + x if let None | None = x => {} + //~^ ERROR unreachable pattern + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr new file mode 100644 index 000000000..75f22ac8d --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr @@ -0,0 +1,28 @@ +error: irrefutable `if let` guard pattern + --> $DIR/warns.rs:6:24 + | +LL | Some(x) if let () = x => {} + | ^^ + | + = note: this pattern will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm +note: the lint level is defined here + --> $DIR/warns.rs:3:8 + | +LL | #[deny(irrefutable_let_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/warns.rs:15:25 + | +LL | x if let None | None = x => {} + | ^^^^ + | +note: the lint level is defined here + --> $DIR/warns.rs:12:8 + | +LL | #[deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2302-self-struct-ctor.rs b/tests/ui/rfcs/rfc-2302-self-struct-ctor.rs deleted file mode 100644 index 1ec20c500..000000000 --- a/tests/ui/rfcs/rfc-2302-self-struct-ctor.rs +++ /dev/null @@ -1,127 +0,0 @@ -// run-pass - -#![allow(dead_code)] - -use std::fmt::Display; - -struct ST1(i32, i32); - -impl ST1 { - fn new() -> Self { - ST1(0, 1) - } - - fn ctor() -> Self { - Self(1,2) // Self as a constructor - } - - fn pattern(self) { - match self { - Self(x, y) => println!("{} {}", x, y), // Self as a pattern - } - } -} - -struct ST2(T); // With type parameter - -impl ST2 where T: Display { - - fn ctor(v: T) -> Self { - Self(v) - } - - fn pattern(&self) { - match self { - Self(ref v) => println!("{}", v), - } - } -} - -struct ST3<'a>(&'a i32); // With lifetime parameter - -impl<'a> ST3<'a> { - - fn ctor(v: &'a i32) -> Self { - Self(v) - } - - fn pattern(self) { - let Self(ref v) = self; - println!("{}", v); - } -} - -struct ST4(usize); - -impl ST4 { - fn map(opt: Option) -> Option { - opt.map(Self) // use `Self` as a function passed somewhere - } -} - -struct ST5; // unit struct - -impl ST5 { - fn ctor() -> Self { - Self // `Self` as a unit struct value - } - - fn pattern(self) -> Self { - match self { - Self => Self, // `Self` as a unit struct value for matching - } - } -} - -struct ST6(i32); -type T = ST6; -impl T { - fn ctor() -> Self { - ST6(1) - } - - fn type_alias(self) { - let Self(_x) = match self { Self(x) => Self(x) }; - let _opt: Option = Some(0).map(Self); - } -} - -struct ST7(T1, T2); - -impl ST7 { - - fn ctor() -> Self { - Self(1, 2) - } - - fn pattern(self) -> Self { - match self { - Self(x, y) => Self(x, y), - } - } -} - -fn main() { - let v1 = ST1::ctor(); - v1.pattern(); - - let v2 = ST2::ctor(10); - v2.pattern(); - - let local = 42; - let v3 = ST3::ctor(&local); - v3.pattern(); - - let v4 = Some(1usize); - let _ = ST4::map(v4); - - let v5 = ST5::ctor(); - v5.pattern(); - - let v6 = ST6::ctor(); - v6.type_alias(); - - let v7 = ST7::::ctor(); - let r = v7.pattern(); - println!("{} {}", r.0, r.1) -} diff --git a/tests/ui/rfcs/rfc-2302-self-struct-ctor/rfc-2302-self-struct-ctor.rs b/tests/ui/rfcs/rfc-2302-self-struct-ctor/rfc-2302-self-struct-ctor.rs new file mode 100644 index 000000000..1ec20c500 --- /dev/null +++ b/tests/ui/rfcs/rfc-2302-self-struct-ctor/rfc-2302-self-struct-ctor.rs @@ -0,0 +1,127 @@ +// run-pass + +#![allow(dead_code)] + +use std::fmt::Display; + +struct ST1(i32, i32); + +impl ST1 { + fn new() -> Self { + ST1(0, 1) + } + + fn ctor() -> Self { + Self(1,2) // Self as a constructor + } + + fn pattern(self) { + match self { + Self(x, y) => println!("{} {}", x, y), // Self as a pattern + } + } +} + +struct ST2(T); // With type parameter + +impl ST2 where T: Display { + + fn ctor(v: T) -> Self { + Self(v) + } + + fn pattern(&self) { + match self { + Self(ref v) => println!("{}", v), + } + } +} + +struct ST3<'a>(&'a i32); // With lifetime parameter + +impl<'a> ST3<'a> { + + fn ctor(v: &'a i32) -> Self { + Self(v) + } + + fn pattern(self) { + let Self(ref v) = self; + println!("{}", v); + } +} + +struct ST4(usize); + +impl ST4 { + fn map(opt: Option) -> Option { + opt.map(Self) // use `Self` as a function passed somewhere + } +} + +struct ST5; // unit struct + +impl ST5 { + fn ctor() -> Self { + Self // `Self` as a unit struct value + } + + fn pattern(self) -> Self { + match self { + Self => Self, // `Self` as a unit struct value for matching + } + } +} + +struct ST6(i32); +type T = ST6; +impl T { + fn ctor() -> Self { + ST6(1) + } + + fn type_alias(self) { + let Self(_x) = match self { Self(x) => Self(x) }; + let _opt: Option = Some(0).map(Self); + } +} + +struct ST7(T1, T2); + +impl ST7 { + + fn ctor() -> Self { + Self(1, 2) + } + + fn pattern(self) -> Self { + match self { + Self(x, y) => Self(x, y), + } + } +} + +fn main() { + let v1 = ST1::ctor(); + v1.pattern(); + + let v2 = ST2::ctor(10); + v2.pattern(); + + let local = 42; + let v3 = ST3::ctor(&local); + v3.pattern(); + + let v4 = Some(1usize); + let _ = ST4::map(v4); + + let v5 = ST5::ctor(); + v5.pattern(); + + let v6 = ST6::ctor(); + v6.type_alias(); + + let v7 = ST7::::ctor(); + let r = v7.pattern(); + println!("{} {}", r.0, r.1) +} diff --git a/tests/ui/rfcs/rfc-2306-convert-id/convert-id-const-with-gate.rs b/tests/ui/rfcs/rfc-2306-convert-id/convert-id-const-with-gate.rs new file mode 100644 index 000000000..762dfbe48 --- /dev/null +++ b/tests/ui/rfcs/rfc-2306-convert-id/convert-id-const-with-gate.rs @@ -0,0 +1,7 @@ +// This test should pass since 'identity' is const fn. + +// build-pass (FIXME(62277): could be check-pass?) + +fn main() { + const _FOO: u8 = ::std::convert::identity(42u8); +} diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs new file mode 100644 index 000000000..542be3942 --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs @@ -0,0 +1,69 @@ +// run-pass +// check-run-results + +// Tests ensuring that `dbg!(expr)` has the expected run-time behavior. +// as well as some compile time properties we expect. + +#![allow(dropping_copy_types)] + +#[derive(Copy, Clone, Debug)] +struct Unit; + +#[derive(Copy, Clone, Debug, PartialEq)] +struct Point { + x: T, + y: T, +} + +#[derive(Debug, PartialEq)] +struct NoCopy(usize); + +fn main() { + let a: Unit = dbg!(Unit); + let _: Unit = dbg!(a); + // We can move `a` because it's Copy. + drop(a); + + // `Point` will be faithfully formatted according to `{:#?}`. + let a = Point { x: 42, y: 24 }; + let b: Point = dbg!(Point { x: 42, y: 24 }); // test stringify!(..) + let c: Point = dbg!(b); + // Identity conversion: + assert_eq!(a, b); + assert_eq!(a, c); + // We can move `b` because it's Copy. + drop(b); + + // Without parameters works as expected. + let _: () = dbg!(); + + // Test that we can borrow and that successive applications is still identity. + let a = NoCopy(1337); + let b: &NoCopy = dbg!(dbg!(&a)); + assert_eq!(&a, b); + + // Test involving lifetimes of temporaries: + fn f<'a>(x: &'a u8) -> &'a u8 { x } + let a: &u8 = dbg!(f(&42)); + assert_eq!(a, &42); + + // Test side effects: + let mut foo = 41; + assert_eq!(7331, dbg!({ + foo += 1; + eprintln!("before"); + 7331 + })); + assert_eq!(foo, 42); + + // Test trailing comma: + assert_eq!(("Yeah",), dbg!(("Yeah",))); + + // Test multiple arguments: + assert_eq!((1u8, 2u32), dbg!(1, + 2)); + + // Test multiple arguments + trailing comma: + assert_eq!((1u8, 2u32, "Yeah"), dbg!(1u8, 2u32, + "Yeah",)); +} diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr new file mode 100644 index 000000000..a20a6062c --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-expected-behavior.run.stderr @@ -0,0 +1,28 @@ +[$DIR/dbg-macro-expected-behavior.rs:22] Unit = Unit +[$DIR/dbg-macro-expected-behavior.rs:23] a = Unit +[$DIR/dbg-macro-expected-behavior.rs:29] Point { x: 42, y: 24 } = Point { + x: 42, + y: 24, +} +[$DIR/dbg-macro-expected-behavior.rs:30] b = Point { + x: 42, + y: 24, +} +[$DIR/dbg-macro-expected-behavior.rs:38] +[$DIR/dbg-macro-expected-behavior.rs:42] &a = NoCopy( + 1337, +) +[$DIR/dbg-macro-expected-behavior.rs:42] dbg!(& a) = NoCopy( + 1337, +) +[$DIR/dbg-macro-expected-behavior.rs:47] f(&42) = 42 +before +[$DIR/dbg-macro-expected-behavior.rs:52] { foo += 1; eprintln!("before"); 7331 } = 7331 +[$DIR/dbg-macro-expected-behavior.rs:60] ("Yeah",) = ( + "Yeah", +) +[$DIR/dbg-macro-expected-behavior.rs:63] 1 = 1 +[$DIR/dbg-macro-expected-behavior.rs:63] 2 = 2 +[$DIR/dbg-macro-expected-behavior.rs:67] 1u8 = 1 +[$DIR/dbg-macro-expected-behavior.rs:67] 2u32 = 2 +[$DIR/dbg-macro-expected-behavior.rs:67] "Yeah" = "Yeah" diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs new file mode 100644 index 000000000..9f3c567b6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs @@ -0,0 +1,10 @@ +// Test ensuring that `dbg!(expr)` will take ownership of the argument. + +#[derive(Debug)] +struct NoCopy(usize); + +fn main() { + let a = NoCopy(0); + let _ = dbg!(a); + let _ = dbg!(a); //~ ERROR use of moved value +} diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr new file mode 100644 index 000000000..e97fdcce1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `a` + --> $DIR/dbg-macro-move-semantics.rs:9:18 + | +LL | let a = NoCopy(0); + | - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait +LL | let _ = dbg!(a); + | ------- value moved here +LL | let _ = dbg!(a); + | ^ value used here after move + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs new file mode 100644 index 000000000..f2fb62d76 --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs @@ -0,0 +1,7 @@ +// Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`. + +struct NotDebug; + +fn main() { + let _: NotDebug = dbg!(NotDebug); //~ ERROR `NotDebug` doesn't implement `Debug` +} diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr new file mode 100644 index 000000000..ce165e646 --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -0,0 +1,18 @@ +error[E0277]: `NotDebug` doesn't implement `Debug` + --> $DIR/dbg-macro-requires-debug.rs:6:23 + | +LL | let _: NotDebug = dbg!(NotDebug); + | ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}` + | + = help: the trait `Debug` is not implemented for `NotDebug` + = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `NotDebug` with `#[derive(Debug)]` + | +LL + #[derive(Debug)] +LL | struct NotDebug; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs b/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs new file mode 100644 index 000000000..5053c115b --- /dev/null +++ b/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.rs @@ -0,0 +1,21 @@ +#![feature(do_not_recommend)] + +pub trait Foo { +} + +impl Foo for i32 { +} + +pub trait Bar { +} + +#[do_not_recommend] +impl Bar for T { +} + +fn stuff(_: T) {} + +fn main() { + stuff(1u8); + //~^ the trait bound `u8: Foo` is not satisfied +} diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr b/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr new file mode 100644 index 000000000..a3e559054 --- /dev/null +++ b/tests/ui/rfcs/rfc-2397-do-not-recommend/feature-gate-do_not_recommend.stderr @@ -0,0 +1,25 @@ +error[E0277]: the trait bound `u8: Foo` is not satisfied + --> $DIR/feature-gate-do_not_recommend.rs:19:11 + | +LL | stuff(1u8); + | ----- ^^^ the trait `Foo` is not implemented for `u8` + | | + | required by a bound introduced by this call + | + = help: the trait `Foo` is implemented for `i32` +note: required for `u8` to implement `Bar` + --> $DIR/feature-gate-do_not_recommend.rs:13:14 + | +LL | impl Bar for T { + | --- ^^^ ^ + | | + | unsatisfied trait bound introduced here +note: required by a bound in `stuff` + --> $DIR/feature-gate-do_not_recommend.rs:16:13 + | +LL | fn stuff(_: T) {} + | ^^^ required by this bound in `stuff` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs b/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs new file mode 100644 index 000000000..91863f5e4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.rs @@ -0,0 +1,45 @@ +#![feature(do_not_recommend)] + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +const CONST: () = (); + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +static Static: () = (); + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +type Type = (); + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +enum Enum { +} + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +extern { +} + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +fn fun() { +} + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +struct Struct { +} + +#[do_not_recommend] +//~^ `#[do_not_recommend]` can only be placed +trait Trait { +} + +#[do_not_recommend] +impl Trait for i32 { +} + +fn main() { +} diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr b/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr new file mode 100644 index 000000000..01ebc23c8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2397-do-not-recommend/incorrect-locations.stderr @@ -0,0 +1,50 @@ +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:3:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:7:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:11:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:15:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:20:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:25:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:30:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: `#[do_not_recommend]` can only be placed on trait implementations + --> $DIR/incorrect-locations.rs:35:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 8 previous errors + diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs b/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs new file mode 100644 index 000000000..f0c5c222e --- /dev/null +++ b/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.rs @@ -0,0 +1,10 @@ +trait Foo { +} + +#[do_not_recommend] +//~^ ERROR the `#[do_not_recommend]` attribute is an experimental feature +impl Foo for i32 { +} + +fn main() { +} diff --git a/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr b/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr new file mode 100644 index 000000000..1597e5be4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2397-do-not-recommend/unstable-feature.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[do_not_recommend]` attribute is an experimental feature + --> $DIR/unstable-feature.rs:4:1 + | +LL | #[do_not_recommend] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51992 for more information + = help: add `#![feature(do_not_recommend)]` 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/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs b/tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs deleted file mode 100644 index 6d7bca4da..000000000 --- a/tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_variables)] -// Test that removed keywords are allowed as identifiers. -fn main () { - let offsetof = (); - let alignof = (); - let sizeof = (); - let pure = (); -} - -fn offsetof() {} -fn alignof() {} -fn sizeof() {} -fn pure() {} diff --git a/tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof/offsetof-alignof-sizeof-pure-can-be-used-as-idents.rs b/tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof/offsetof-alignof-sizeof-pure-can-be-used-as-idents.rs new file mode 100644 index 000000000..6d7bca4da --- /dev/null +++ b/tests/ui/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof/offsetof-alignof-sizeof-pure-can-be-used-as-idents.rs @@ -0,0 +1,15 @@ +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that removed keywords are allowed as identifiers. +fn main () { + let offsetof = (); + let alignof = (); + let sizeof = (); + let pure = (); +} + +fn offsetof() {} +fn alignof() {} +fn sizeof() {} +fn pure() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs new file mode 100644 index 000000000..e373b6438 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/auxiliary/mod_file_nonascii_with_path_allowed-aux.rs @@ -0,0 +1 @@ +pub trait Foo {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.rs new file mode 100644 index 000000000..c07ba54af --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.rs @@ -0,0 +1,3 @@ +extern crate ьаг; //~ ERROR cannot load a crate with a non-ascii name `ьаг` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.stderr b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.stderr new file mode 100644 index 000000000..a8f3abe59 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-1.stderr @@ -0,0 +1,8 @@ +error: cannot load a crate with a non-ascii name `ьаг` + --> $DIR/crate_name_nonascii_forbidden-1.rs:1:1 + | +LL | extern crate ьаг; + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.rs new file mode 100644 index 000000000..f8e033937 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.rs @@ -0,0 +1,6 @@ +// compile-flags:--extern му_сгате +// edition:2018 + +use му_сгате::baz; //~ ERROR cannot load a crate with a non-ascii name `му_сгате` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.stderr b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.stderr new file mode 100644 index 000000000..05fc4fb22 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/crate_name_nonascii_forbidden-2.stderr @@ -0,0 +1,8 @@ +error: cannot load a crate with a non-ascii name `му_сгате` + --> $DIR/crate_name_nonascii_forbidden-2.rs:4:5 + | +LL | use му_сгате::baz; + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.rs new file mode 100644 index 000000000..ad6825404 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.rs @@ -0,0 +1,9 @@ +#![feature(extern_types)] + +extern "C" { + type 一; //~ items in `extern` blocks cannot use non-ascii identifiers + fn 二(); //~ items in `extern` blocks cannot use non-ascii identifiers + static 三: usize; //~ items in `extern` blocks cannot use non-ascii identifiers +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.stderr b/tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.stderr new file mode 100644 index 000000000..ca1b8a6e7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/extern_block_nonascii_forbidden.stderr @@ -0,0 +1,34 @@ +error: items in `extern` blocks cannot use non-ascii identifiers + --> $DIR/extern_block_nonascii_forbidden.rs:4:10 + | +LL | extern "C" { + | ---------- in this `extern` block +LL | type 一; + | ^^ + | + = note: this limitation may be lifted in the future; see issue #83942 for more information + +error: items in `extern` blocks cannot use non-ascii identifiers + --> $DIR/extern_block_nonascii_forbidden.rs:5:8 + | +LL | extern "C" { + | ---------- in this `extern` block +LL | type 一; +LL | fn 二(); + | ^^ + | + = note: this limitation may be lifted in the future; see issue #83942 for more information + +error: items in `extern` blocks cannot use non-ascii identifiers + --> $DIR/extern_block_nonascii_forbidden.rs:6:12 + | +LL | extern "C" { + | ---------- in this `extern` block +... +LL | static 三: usize; + | ^^ + | + = note: this limitation may be lifted in the future; see issue #83942 for more information + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/idents-normalized.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/idents-normalized.rs new file mode 100644 index 000000000..1023fee37 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/idents-normalized.rs @@ -0,0 +1,7 @@ +// check-pass + +struct Résumé; // ['LATIN SMALL LETTER E WITH ACUTE'] + +fn main() { + let _ = Résumé; // ['LATIN SMALL LETTER E', 'COMBINING ACUTE ACCENT'] +} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.rs new file mode 100644 index 000000000..e949e2319 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.rs @@ -0,0 +1,4 @@ +mod řųśť; //~ trying to load file for +//~^ file not found for + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.stderr b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.stderr new file mode 100644 index 000000000..7639ae9f6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_forbidden.stderr @@ -0,0 +1,20 @@ +error[E0583]: file not found for module `řųśť` + --> $DIR/mod_file_nonascii_forbidden.rs:1:1 + | +LL | mod řųśť; + | ^^^^^^^^^ + | + = help: to create the module `řųśť`, create file "$DIR/řųśť.rs" or "$DIR/řųśť/mod.rs" + +error[E0754]: trying to load file for module `řųśť` with non-ascii identifier name + --> $DIR/mod_file_nonascii_forbidden.rs:1:5 + | +LL | mod řųśť; + | ^^^^ + | + = help: consider using the `#[path]` attribute to specify filesystem path + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0583, E0754. +For more information about an error, try `rustc --explain E0583`. diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_with_path_allowed.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_with_path_allowed.rs new file mode 100644 index 000000000..94327846d --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_file_nonascii_with_path_allowed.rs @@ -0,0 +1,6 @@ +// check-pass + +#[path="auxiliary/mod_file_nonascii_with_path_allowed-aux.rs"] +mod řųśť; + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_inline_nonascii_allowed.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_inline_nonascii_allowed.rs new file mode 100644 index 000000000..e1d836b7c --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/mod_inline_nonascii_allowed.rs @@ -0,0 +1,7 @@ +// check-pass + +mod řųśť { + const IS_GREAT: bool = true; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.rs b/tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.rs new file mode 100644 index 000000000..f4c126a6e --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.rs @@ -0,0 +1,20 @@ +#[no_mangle] +pub fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier + +pub struct Foo; + +impl Foo { + #[no_mangle] + pub fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier +} + +trait Bar { + fn řųśť(); +} + +impl Bar for Foo { + #[no_mangle] + fn řųśť() {} //~ `#[no_mangle]` requires ASCII identifier +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.stderr b/tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.stderr new file mode 100644 index 000000000..459d5d6b5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2457-non-ascii-idents/no_mangle_nonascii_forbidden.stderr @@ -0,0 +1,21 @@ +error[E0754]: `#[no_mangle]` requires ASCII identifier + --> $DIR/no_mangle_nonascii_forbidden.rs:2:1 + | +LL | pub fn řųśť() {} + | ^^^^^^^^^^^^^ + +error[E0754]: `#[no_mangle]` requires ASCII identifier + --> $DIR/no_mangle_nonascii_forbidden.rs:8:5 + | +LL | pub fn řųśť() {} + | ^^^^^^^^^^^^^ + +error[E0754]: `#[no_mangle]` requires ASCII identifier + --> $DIR/no_mangle_nonascii_forbidden.rs:17:5 + | +LL | fn řųśť() {} + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0754`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs new file mode 100644 index 000000000..d851fac8e --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-lowering-does-not-wrap-let-chains.rs @@ -0,0 +1,16 @@ +// run-pass + +#![feature(let_chains)] +#![allow(irrefutable_let_patterns)] + +fn main() { + let first = Some(1); + let second = Some(2); + let mut n = 0; + if let x = first && let y = second && 1 == 1 { + assert_eq!(x, first); + assert_eq!(y, second); + n = 1; + } + assert_eq!(n, 1); +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.rs new file mode 100644 index 000000000..69bc189dd --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.rs @@ -0,0 +1,6 @@ +// check-pass +// compile-flags: -Z unpretty=expanded + +fn main() { + if let 0 = 1 {} +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout new file mode 100644 index 000000000..e737ef26e --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout @@ -0,0 +1,10 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// check-pass +// compile-flags: -Z unpretty=expanded + +fn main() { if let 0 = 1 {} } diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs new file mode 100644 index 000000000..e6dee2a1d --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.rs @@ -0,0 +1,23 @@ +#![feature(let_chains)] + +fn let_or_guard(x: Result, ()>) { + match x { + Ok(opt) if let Some(4) = opt || false => {} + //~^ ERROR `let` expressions are not supported here + _ => {} + } +} + +fn hiding_unsafe_mod(x: Result, ()>) { + match x { + Ok(opt) + if { + unsafe mod a {}; + //~^ ERROR module cannot be declared unsafe + false + } => {} + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr new file mode 100644 index 000000000..26850998c --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-validate-guards.stderr @@ -0,0 +1,21 @@ +error: `let` expressions are not supported here + --> $DIR/ast-validate-guards.rs:5:20 + | +LL | Ok(opt) if let Some(4) = opt || false => {} + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/ast-validate-guards.rs:5:38 + | +LL | Ok(opt) if let Some(4) = opt || false => {} + | ^^ + +error: module cannot be declared unsafe + --> $DIR/ast-validate-guards.rs:15:17 + | +LL | unsafe mod a {}; + | ^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs new file mode 100644 index 000000000..e0dded152 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs @@ -0,0 +1,20 @@ +fn and_chain() { + let z; + if true && { z = 3; true} && z == 3 {} + //~^ ERROR E0381 +} + +fn and_chain_2() { + let z; + true && { z = 3; true} && z == 3; + //~^ ERROR E0381 +} + +fn or_chain() { + let z; + if false || { z = 3; false} || z == 3 {} + //~^ ERROR E0381 +} + +fn main() { +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr new file mode 100644 index 000000000..30d5a6779 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr @@ -0,0 +1,33 @@ +error[E0381]: used binding `z` is possibly-uninitialized + --> $DIR/chains-without-let.rs:3:34 + | +LL | let z; + | - binding declared here but left uninitialized +LL | if true && { z = 3; true} && z == 3 {} + | ----- ^ `z` used here but it is possibly-uninitialized + | | + | binding initialized here in some conditions + +error[E0381]: used binding `z` is possibly-uninitialized + --> $DIR/chains-without-let.rs:9:31 + | +LL | let z; + | - binding declared here but left uninitialized +LL | true && { z = 3; true} && z == 3; + | ----- ^ `z` used here but it is possibly-uninitialized + | | + | binding initialized here in some conditions + +error[E0381]: used binding `z` is possibly-uninitialized + --> $DIR/chains-without-let.rs:15:36 + | +LL | let z; + | - binding declared here but left uninitialized +LL | if false || { z = 3; false} || z == 3 {} + | ----- ^ `z` used here but it is possibly-uninitialized + | | + | binding initialized here in some conditions + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs new file mode 100644 index 000000000..2a9a5472b --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs @@ -0,0 +1,480 @@ +// Here we test that `lowering` behaves correctly wrt. `let $pats = $expr` expressions. +// +// We want to make sure that `let` is banned in situations other than: +// +// expr = +// | ... +// | "if" expr_with_let block {"else" block}? +// | {label ":"}? while" expr_with_let block +// ; +// +// expr_with_let = +// | "let" top_pats "=" expr +// | expr_with_let "&&" expr_with_let +// | "(" expr_with_let ")" +// | expr +// ; +// +// To that end, we check some positions which is not part of the language above. + +#![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test. + +#![allow(irrefutable_let_patterns)] + +use std::ops::Range; + +fn main() {} + +fn _if() { + if (let 0 = 1) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + if (((let 0 = 1))) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + if (let 0 = 1) && true {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + if true && (let 0 = 1) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + if (let 0 = 1) && (let 0 = 1) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + + if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement +} + +fn _while() { + while (let 0 = 1) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + while (((let 0 = 1))) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + while (let 0 = 1) && true {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + while true && (let 0 = 1) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + while (let 0 = 1) && (let 0 = 1) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + + while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement +} + +fn _macros() { + macro_rules! use_expr { + ($e:expr) => { + if $e {} + while $e {} + } + } + use_expr!((let 0 = 1 && 0 == 0)); + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + use_expr!((let 0 = 1)); + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement +} + +fn nested_within_if_expr() { + if &let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + if !let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + if *let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR type `bool` cannot be dereferenced + //~| ERROR expected expression, found `let` statement + if -let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR cannot apply unary operator `-` to type `bool` + //~| ERROR expected expression, found `let` statement + + fn _check_try_binds_tighter() -> Result<(), ()> { + if let 0 = 0? {} + //~^ ERROR the `?` operator can only be applied to values that implement `Try` + Ok(()) + } + if (let 0 = 0)? {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR the `?` operator can only be applied to values that implement `Try` + //~| ERROR the `?` operator can only be used in a function that returns `Result` + //~| ERROR expected expression, found `let` statement + + if true || let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + if (true || let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + if true && (true || let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + if true || (true && let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + let mut x = true; + if x = let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + if true..(let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + if ..(let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + if (let 0 = 0).. {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + // Binds as `(let ... = true)..true &&/|| false`. + if let Range { start: _, end: _ } = true..true && false {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + if let Range { start: _, end: _ } = true..true || false {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + + // Binds as `(let Range { start: F, end } = F)..(|| true)`. + const F: fn() -> bool = || true; + if let Range { start: F, end } = F..|| true {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR mismatched types + + // Binds as `(let Range { start: true, end } = t)..(&&false)`. + let t = &&true; + if let Range { start: true, end } = t..&&false {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR mismatched types + + if let true = let true = true {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement +} + +fn nested_within_while_expr() { + while &let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + while !let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + while *let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR type `bool` cannot be dereferenced + //~| ERROR expected expression, found `let` statement + while -let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR cannot apply unary operator `-` to type `bool` + //~| ERROR expected expression, found `let` statement + + fn _check_try_binds_tighter() -> Result<(), ()> { + while let 0 = 0? {} + //~^ ERROR the `?` operator can only be applied to values that implement `Try` + Ok(()) + } + while (let 0 = 0)? {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR the `?` operator can only be applied to values that implement `Try` + //~| ERROR the `?` operator can only be used in a function that returns `Result` + //~| ERROR expected expression, found `let` statement + + while true || let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + while (true || let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + while true && (true || let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + while true || (true && let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + let mut x = true; + while x = let 0 = 0 {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + while true..(let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + while ..(let 0 = 0) {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + while (let 0 = 0).. {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + // Binds as `(let ... = true)..true &&/|| false`. + while let Range { start: _, end: _ } = true..true && false {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + while let Range { start: _, end: _ } = true..true || false {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + + // Binds as `(let Range { start: F, end } = F)..(|| true)`. + const F: fn() -> bool = || true; + while let Range { start: F, end } = F..|| true {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR mismatched types + + // Binds as `(let Range { start: true, end } = t)..(&&false)`. + let t = &&true; + while let Range { start: true, end } = t..&&false {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR mismatched types + + while let true = let true = true {} + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement +} + +fn not_error_because_clarified_intent() { + if let Range { start: _, end: _ } = (true..true || false) { } + + if let Range { start: _, end: _ } = (true..true && false) { } + + while let Range { start: _, end: _ } = (true..true || false) { } + + while let Range { start: _, end: _ } = (true..true && false) { } +} + +fn outside_if_and_while_expr() { + &let 0 = 0; + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + !let 0 = 0; + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + *let 0 = 0; + //~^ ERROR `let` expressions are not supported here + //~| ERROR type `bool` cannot be dereferenced + //~| ERROR expected expression, found `let` statement + -let 0 = 0; + //~^ ERROR `let` expressions are not supported here + //~| ERROR cannot apply unary operator `-` to type `bool` + //~| ERROR expected expression, found `let` statement + + fn _check_try_binds_tighter() -> Result<(), ()> { + let 0 = 0?; + //~^ ERROR the `?` operator can only be applied to values that implement `Try` + Ok(()) + } + (let 0 = 0)?; + //~^ ERROR `let` expressions are not supported here + //~| ERROR the `?` operator can only be used in a function that returns `Result` + //~| ERROR the `?` operator can only be applied to values that implement `Try` + //~| ERROR expected expression, found `let` statement + + true || let 0 = 0; + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + (true || let 0 = 0); + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + true && (true || let 0 = 0); + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + let mut x = true; + x = let 0 = 0; + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + true..(let 0 = 0); + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + ..(let 0 = 0); + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + (let 0 = 0)..; + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + + (let Range { start: _, end: _ } = true..true || false); + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + + (let true = let true = true); + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + + { + #[cfg(FALSE)] + let x = true && let y = 1; + //~^ ERROR expected expression, found `let` statement + } + + #[cfg(FALSE)] + { + [1, 2, 3][let _ = ()] + //~^ ERROR expected expression, found `let` statement + } + + // Check function tail position. + &let 0 = 0 + //~^ ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement +} + +// Let's make sure that `let` inside const generic arguments are considered. +fn inside_const_generic_arguments() { + struct A; + impl A<{B}> { const O: u32 = 5; } + + if let A::<{ + true && let 1 = 1 + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + }>::O = 5 {} + + while let A::<{ + true && let 1 = 1 + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + }>::O = 5 {} + + if A::<{ + true && let 1 = 1 + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + }>::O == 5 {} + + // In the cases above we have `ExprKind::Block` to help us out. + // Below however, we would not have a block and so an implementation might go + // from visiting expressions to types without banning `let` expressions down the tree. + // This tests ensures that we are not caught by surprise should the parser + // admit non-IDENT expressions in const generic arguments. + + if A::< + true && let 1 = 1 + //~^ ERROR `let` expressions are not supported here + //~| ERROR expressions must be enclosed in braces + //~| ERROR expected expression, found `let` statement + >::O == 5 {} +} + +fn with_parenthesis() { + let opt = Some(Some(1i32)); + + if (let Some(a) = opt && true) { + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + } + + if (let Some(a) = opt) && true { + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + } + if (let Some(a) = opt) && (let Some(b) = a) { + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + } + if let Some(a) = opt && (true && true) { + } + + if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + } + if (let Some(a) = opt && (let Some(b) = a)) && true { + //~^ ERROR `let` expressions are not supported here + //~| ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + } + if (let Some(a) = opt && (true)) && true { + //~^ ERROR `let` expressions are not supported here + //~| ERROR expected expression, found `let` statement + } + + if (true && (true)) && let Some(a) = opt { + } + if (true) && let Some(a) = opt { + } + if true && let Some(a) = opt { + } + + let fun = || true; + if let true = (true && fun()) && (true) { + } + + #[cfg(FALSE)] + let x = (true && let y = 1); + //~^ ERROR expected expression, found `let` statement + + #[cfg(FALSE)] + { + ([1, 2, 3][let _ = ()]) + //~^ ERROR expected expression, found `let` statement + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr new file mode 100644 index 000000000..81933173c --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.stderr @@ -0,0 +1,1911 @@ +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:29:9 + | +LL | if (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:33:11 + | +LL | if (((let 0 = 1))) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:37:9 + | +LL | if (let 0 = 1) && true {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:41:17 + | +LL | if true && (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:45:9 + | +LL | if (let 0 = 1) && (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:45:24 + | +LL | if (let 0 = 1) && (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:51:35 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:51:48 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:51:61 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:61:12 + | +LL | while (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:65:14 + | +LL | while (((let 0 = 1))) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:69:12 + | +LL | while (let 0 = 1) && true {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:73:20 + | +LL | while true && (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:77:12 + | +LL | while (let 0 = 1) && (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:77:27 + | +LL | while (let 0 = 1) && (let 0 = 1) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:83:38 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:83:51 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:83:64 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:110:9 + | +LL | if &let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:115:9 + | +LL | if !let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:118:9 + | +LL | if *let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:122:9 + | +LL | if -let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:132:9 + | +LL | if (let 0 = 0)? {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:138:16 + | +LL | if true || let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:141:17 + | +LL | if (true || let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:144:25 + | +LL | if true && (true || let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:147:25 + | +LL | if true || (true && let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:152:12 + | +LL | if x = let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:157:15 + | +LL | if true..(let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:161:11 + | +LL | if ..(let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:165:9 + | +LL | if (let 0 = 0).. {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:196:19 + | +LL | if let true = let true = true {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:202:12 + | +LL | while &let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:207:12 + | +LL | while !let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:210:12 + | +LL | while *let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:214:12 + | +LL | while -let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:224:12 + | +LL | while (let 0 = 0)? {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:230:19 + | +LL | while true || let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:233:20 + | +LL | while (true || let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:236:28 + | +LL | while true && (true || let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:239:28 + | +LL | while true || (true && let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:244:15 + | +LL | while x = let 0 = 0 {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:249:18 + | +LL | while true..(let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:253:14 + | +LL | while ..(let 0 = 0) {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:257:12 + | +LL | while (let 0 = 0).. {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:288:22 + | +LL | while let true = let true = true {} + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:304:6 + | +LL | &let 0 = 0; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:308:6 + | +LL | !let 0 = 0; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:311:6 + | +LL | *let 0 = 0; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:315:6 + | +LL | -let 0 = 0; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:325:6 + | +LL | (let 0 = 0)?; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:331:13 + | +LL | true || let 0 = 0; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:334:14 + | +LL | (true || let 0 = 0); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:337:22 + | +LL | true && (true || let 0 = 0); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:342:9 + | +LL | x = let 0 = 0; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:346:12 + | +LL | true..(let 0 = 0); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:349:8 + | +LL | ..(let 0 = 0); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:352:6 + | +LL | (let 0 = 0)..; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:356:6 + | +LL | (let Range { start: _, end: _ } = true..true || false); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:361:6 + | +LL | (let true = let true = true); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:361:17 + | +LL | (let true = let true = true); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:368:25 + | +LL | let x = true && let y = 1; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:374:19 + | +LL | [1, 2, 3][let _ = ()] + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:379:6 + | +LL | &let 0 = 0 + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:391:17 + | +LL | true && let 1 = 1 + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:397:17 + | +LL | true && let 1 = 1 + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:403:17 + | +LL | true && let 1 = 1 + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:415:17 + | +LL | true && let 1 = 1 + | ^^^ + +error: expressions must be enclosed in braces to be used as const generic arguments + --> $DIR/disallowed-positions.rs:415:9 + | +LL | true && let 1 = 1 + | ^^^^^^^^^^^^^^^^^ + | +help: enclose the `const` expression in braces + | +LL | { true && let 1 = 1 } + | + + + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:425:9 + | +LL | if (let Some(a) = opt && true) { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:430:9 + | +LL | if (let Some(a) = opt) && true { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:434:9 + | +LL | if (let Some(a) = opt) && (let Some(b) = a) { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:434:32 + | +LL | if (let Some(a) = opt) && (let Some(b) = a) { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:443:9 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:443:31 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:449:9 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && true { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:449:31 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && true { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:455:9 + | +LL | if (let Some(a) = opt && (true)) && true { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:472:22 + | +LL | let x = (true && let y = 1); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:477:20 + | +LL | ([1, 2, 3][let _ = ()]) + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:99:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/disallowed-positions.rs:103:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:29:9 + | +LL | if (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:29:9 + | +LL | if (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:33:11 + | +LL | if (((let 0 = 1))) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:33:11 + | +LL | if (((let 0 = 1))) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:37:9 + | +LL | if (let 0 = 1) && true {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:37:9 + | +LL | if (let 0 = 1) && true {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:41:17 + | +LL | if true && (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:41:17 + | +LL | if true && (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:45:9 + | +LL | if (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:45:9 + | +LL | if (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:45:24 + | +LL | if (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:45:24 + | +LL | if (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:51:35 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:51:35 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:51:48 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:51:35 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:51:61 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:51:35 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:61:12 + | +LL | while (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:61:12 + | +LL | while (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:65:14 + | +LL | while (((let 0 = 1))) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:65:14 + | +LL | while (((let 0 = 1))) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:69:12 + | +LL | while (let 0 = 1) && true {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:69:12 + | +LL | while (let 0 = 1) && true {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:73:20 + | +LL | while true && (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:73:20 + | +LL | while true && (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:77:12 + | +LL | while (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:77:12 + | +LL | while (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:77:27 + | +LL | while (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:77:27 + | +LL | while (let 0 = 1) && (let 0 = 1) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:83:38 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:83:38 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:83:51 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:83:38 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:83:64 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:83:38 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:99:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:99:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:99:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:99:16 + | +LL | use_expr!((let 0 = 1 && 0 == 0)); + | ^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:103:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:103:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:103:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:103:16 + | +LL | use_expr!((let 0 = 1)); + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:110:9 + | +LL | if &let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:115:9 + | +LL | if !let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:118:9 + | +LL | if *let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:122:9 + | +LL | if -let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:132:9 + | +LL | if (let 0 = 0)? {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:132:9 + | +LL | if (let 0 = 0)? {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:138:16 + | +LL | if true || let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:138:13 + | +LL | if true || let 0 = 0 {} + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:141:17 + | +LL | if (true || let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:141:14 + | +LL | if (true || let 0 = 0) {} + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:144:25 + | +LL | if true && (true || let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:144:22 + | +LL | if true && (true || let 0 = 0) {} + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:147:25 + | +LL | if true || (true && let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:147:17 + | +LL | if true || (true && let 0 = 0) {} + | ^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:152:12 + | +LL | if x = let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:157:15 + | +LL | if true..(let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:157:15 + | +LL | if true..(let 0 = 0) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:161:11 + | +LL | if ..(let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:161:11 + | +LL | if ..(let 0 = 0) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:165:9 + | +LL | if (let 0 = 0).. {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:165:9 + | +LL | if (let 0 = 0).. {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:171:8 + | +LL | if let Range { start: _, end: _ } = true..true && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:175:8 + | +LL | if let Range { start: _, end: _ } = true..true || false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:182:8 + | +LL | if let Range { start: F, end } = F..|| true {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:190:8 + | +LL | if let Range { start: true, end } = t..&&false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:196:19 + | +LL | if let true = let true = true {} + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:202:12 + | +LL | while &let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:207:12 + | +LL | while !let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:210:12 + | +LL | while *let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:214:12 + | +LL | while -let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:224:12 + | +LL | while (let 0 = 0)? {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:224:12 + | +LL | while (let 0 = 0)? {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:230:19 + | +LL | while true || let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:230:16 + | +LL | while true || let 0 = 0 {} + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:233:20 + | +LL | while (true || let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:233:17 + | +LL | while (true || let 0 = 0) {} + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:236:28 + | +LL | while true && (true || let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:236:25 + | +LL | while true && (true || let 0 = 0) {} + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:239:28 + | +LL | while true || (true && let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:239:20 + | +LL | while true || (true && let 0 = 0) {} + | ^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:244:15 + | +LL | while x = let 0 = 0 {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:249:18 + | +LL | while true..(let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:249:18 + | +LL | while true..(let 0 = 0) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:253:14 + | +LL | while ..(let 0 = 0) {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:253:14 + | +LL | while ..(let 0 = 0) {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:257:12 + | +LL | while (let 0 = 0).. {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:257:12 + | +LL | while (let 0 = 0).. {} + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:263:11 + | +LL | while let Range { start: _, end: _ } = true..true && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:267:11 + | +LL | while let Range { start: _, end: _ } = true..true || false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:274:11 + | +LL | while let Range { start: F, end } = F..|| true {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:282:11 + | +LL | while let Range { start: true, end } = t..&&false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:288:22 + | +LL | while let true = let true = true {} + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:304:6 + | +LL | &let 0 = 0; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:308:6 + | +LL | !let 0 = 0; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:311:6 + | +LL | *let 0 = 0; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:315:6 + | +LL | -let 0 = 0; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:325:6 + | +LL | (let 0 = 0)?; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:325:6 + | +LL | (let 0 = 0)?; + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:331:13 + | +LL | true || let 0 = 0; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:331:10 + | +LL | true || let 0 = 0; + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:334:14 + | +LL | (true || let 0 = 0); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:334:11 + | +LL | (true || let 0 = 0); + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:337:22 + | +LL | true && (true || let 0 = 0); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `||` operators are not supported in let chain expressions + --> $DIR/disallowed-positions.rs:337:19 + | +LL | true && (true || let 0 = 0); + | ^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:342:9 + | +LL | x = let 0 = 0; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:346:12 + | +LL | true..(let 0 = 0); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:346:12 + | +LL | true..(let 0 = 0); + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:349:8 + | +LL | ..(let 0 = 0); + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:349:8 + | +LL | ..(let 0 = 0); + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:352:6 + | +LL | (let 0 = 0)..; + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:352:6 + | +LL | (let 0 = 0)..; + | ^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:356:6 + | +LL | (let Range { start: _, end: _ } = true..true || false); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:361:6 + | +LL | (let true = let true = true); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:361:6 + | +LL | (let true = let true = true); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:379:6 + | +LL | &let 0 = 0 + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:391:17 + | +LL | true && let 1 = 1 + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:397:17 + | +LL | true && let 1 = 1 + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:403:17 + | +LL | true && let 1 = 1 + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:415:17 + | +LL | true && let 1 = 1 + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:425:9 + | +LL | if (let Some(a) = opt && true) { + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:425:9 + | +LL | if (let Some(a) = opt && true) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:430:9 + | +LL | if (let Some(a) = opt) && true { + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:430:9 + | +LL | if (let Some(a) = opt) && true { + | ^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:434:9 + | +LL | if (let Some(a) = opt) && (let Some(b) = a) { + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:434:9 + | +LL | if (let Some(a) = opt) && (let Some(b) = a) { + | ^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:434:32 + | +LL | if (let Some(a) = opt) && (let Some(b) = a) { + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:434:32 + | +LL | if (let Some(a) = opt) && (let Some(b) = a) { + | ^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:443:9 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:443:9 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:443:31 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:443:31 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { + | ^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:449:9 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && true { + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:449:9 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && true { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:449:31 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && true { + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:449:31 + | +LL | if (let Some(a) = opt && (let Some(b) = a)) && true { + | ^^^^^^^^^^^^^^^ + +error: `let` expressions are not supported here + --> $DIR/disallowed-positions.rs:455:9 + | +LL | if (let Some(a) = opt && (true)) && true { + | ^^^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/disallowed-positions.rs:455:9 + | +LL | if (let Some(a) = opt && (true)) && true { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:110:8 + | +LL | if &let 0 = 0 {} + | ^^^^^^^^^^ expected `bool`, found `&bool` + | +help: consider removing the borrow + | +LL - if &let 0 = 0 {} +LL + if let 0 = 0 {} + | + +error[E0614]: type `bool` cannot be dereferenced + --> $DIR/disallowed-positions.rs:118:8 + | +LL | if *let 0 = 0 {} + | ^^^^^^^^^^ + +error[E0600]: cannot apply unary operator `-` to type `bool` + --> $DIR/disallowed-positions.rs:122:8 + | +LL | if -let 0 = 0 {} + | ^^^^^^^^^^ cannot apply unary operator `-` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/disallowed-positions.rs:132:8 + | +LL | if (let 0 = 0)? {} + | ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool` + | + = help: the trait `Try` is not implemented for `bool` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/disallowed-positions.rs:132:19 + | +LL | fn nested_within_if_expr() { + | -------------------------- this function should return `Result` or `Option` to accept `?` +... +LL | if (let 0 = 0)? {} + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:152:8 + | +LL | if x = let 0 = 0 {} + | ^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: you might have meant to compare for equality + | +LL | if x == let 0 = 0 {} + | + + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:157:8 + | +LL | if true..(let 0 = 0) {} + | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:161:8 + | +LL | if ..(let 0 = 0) {} + | ^^^^^^^^^^^^^ expected `bool`, found `RangeTo` + | + = note: expected type `bool` + found struct `RangeTo` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:165:8 + | +LL | if (let 0 = 0).. {} + | ^^^^^^^^^^^^^ expected `bool`, found `RangeFrom` + | + = note: expected type `bool` + found struct `RangeFrom` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:171:12 + | +LL | if let Range { start: _, end: _ } = true..true && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:171:8 + | +LL | if let Range { start: _, end: _ } = true..true && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:175:12 + | +LL | if let Range { start: _, end: _ } = true..true || false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:175:8 + | +LL | if let Range { start: _, end: _ } = true..true || false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:182:12 + | +LL | if let Range { start: F, end } = F..|| true {} + | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` + | | + | expected fn pointer, found `Range<_>` + | + = note: expected fn pointer `fn() -> bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:182:41 + | +LL | if let Range { start: F, end } = F..|| true {} + | ^^^^^^^ expected `bool`, found closure + | + = note: expected type `bool` + found closure `[closure@$DIR/disallowed-positions.rs:182:41: 182:43]` +help: use parentheses to call this closure + | +LL | if let Range { start: F, end } = F..(|| true)() {} + | + +++ + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:182:8 + | +LL | if let Range { start: F, end } = F..|| true {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:190:12 + | +LL | if let Range { start: true, end } = t..&&false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:190:44 + | +LL | if let Range { start: true, end } = t..&&false {} + | ^^^^^^^ expected `bool`, found `&&bool` + | +help: consider removing the `&&` + | +LL - if let Range { start: true, end } = t..&&false {} +LL + if let Range { start: true, end } = t..false {} + | + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:190:8 + | +LL | if let Range { start: true, end } = t..&&false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/disallowed-positions.rs:128:20 + | +LL | if let 0 = 0? {} + | ^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:202:11 + | +LL | while &let 0 = 0 {} + | ^^^^^^^^^^ expected `bool`, found `&bool` + | +help: consider removing the borrow + | +LL - while &let 0 = 0 {} +LL + while let 0 = 0 {} + | + +error[E0614]: type `bool` cannot be dereferenced + --> $DIR/disallowed-positions.rs:210:11 + | +LL | while *let 0 = 0 {} + | ^^^^^^^^^^ + +error[E0600]: cannot apply unary operator `-` to type `bool` + --> $DIR/disallowed-positions.rs:214:11 + | +LL | while -let 0 = 0 {} + | ^^^^^^^^^^ cannot apply unary operator `-` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/disallowed-positions.rs:224:11 + | +LL | while (let 0 = 0)? {} + | ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool` + | + = help: the trait `Try` is not implemented for `bool` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/disallowed-positions.rs:224:22 + | +LL | fn nested_within_while_expr() { + | ----------------------------- this function should return `Result` or `Option` to accept `?` +... +LL | while (let 0 = 0)? {} + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:244:11 + | +LL | while x = let 0 = 0 {} + | ^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: you might have meant to compare for equality + | +LL | while x == let 0 = 0 {} + | + + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:249:11 + | +LL | while true..(let 0 = 0) {} + | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:253:11 + | +LL | while ..(let 0 = 0) {} + | ^^^^^^^^^^^^^ expected `bool`, found `RangeTo` + | + = note: expected type `bool` + found struct `RangeTo` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:257:11 + | +LL | while (let 0 = 0).. {} + | ^^^^^^^^^^^^^ expected `bool`, found `RangeFrom` + | + = note: expected type `bool` + found struct `RangeFrom` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:263:15 + | +LL | while let Range { start: _, end: _ } = true..true && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:263:11 + | +LL | while let Range { start: _, end: _ } = true..true && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:267:15 + | +LL | while let Range { start: _, end: _ } = true..true || false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:267:11 + | +LL | while let Range { start: _, end: _ } = true..true || false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:274:15 + | +LL | while let Range { start: F, end } = F..|| true {} + | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` + | | + | expected fn pointer, found `Range<_>` + | + = note: expected fn pointer `fn() -> bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:274:44 + | +LL | while let Range { start: F, end } = F..|| true {} + | ^^^^^^^ expected `bool`, found closure + | + = note: expected type `bool` + found closure `[closure@$DIR/disallowed-positions.rs:274:44: 274:46]` +help: use parentheses to call this closure + | +LL | while let Range { start: F, end } = F..(|| true)() {} + | + +++ + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:274:11 + | +LL | while let Range { start: F, end } = F..|| true {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:282:15 + | +LL | while let Range { start: true, end } = t..&&false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:282:47 + | +LL | while let Range { start: true, end } = t..&&false {} + | ^^^^^^^ expected `bool`, found `&&bool` + | +help: consider removing the `&&` + | +LL - while let Range { start: true, end } = t..&&false {} +LL + while let Range { start: true, end } = t..false {} + | + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:282:11 + | +LL | while let Range { start: true, end } = t..&&false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `Range` + | + = note: expected type `bool` + found struct `std::ops::Range` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/disallowed-positions.rs:220:23 + | +LL | while let 0 = 0? {} + | ^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error[E0614]: type `bool` cannot be dereferenced + --> $DIR/disallowed-positions.rs:311:5 + | +LL | *let 0 = 0; + | ^^^^^^^^^^ + +error[E0600]: cannot apply unary operator `-` to type `bool` + --> $DIR/disallowed-positions.rs:315:5 + | +LL | -let 0 = 0; + | ^^^^^^^^^^ cannot apply unary operator `-` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/disallowed-positions.rs:325:5 + | +LL | (let 0 = 0)?; + | ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool` + | + = help: the trait `Try` is not implemented for `bool` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/disallowed-positions.rs:325:16 + | +LL | fn outside_if_and_while_expr() { + | ------------------------------ this function should return `Result` or `Option` to accept `?` +... +LL | (let 0 = 0)?; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:356:10 + | +LL | (let Range { start: _, end: _ } = true..true || false); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` + | | + | expected `bool`, found `Range<_>` + | + = note: expected type `bool` + found struct `std::ops::Range<_>` + +error[E0308]: mismatched types + --> $DIR/disallowed-positions.rs:379:5 + | +LL | fn outside_if_and_while_expr() { + | - help: try adding a return type: `-> &bool` +... +LL | &let 0 = 0 + | ^^^^^^^^^^ expected `()`, found `&bool` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/disallowed-positions.rs:321:17 + | +LL | let 0 = 0?; + | ^^ the `?` operator cannot be applied to type `{integer}` + | + = help: the trait `Try` is not implemented for `{integer}` + +error: aborting due to 215 previous errors + +Some errors have detailed explanations: E0277, E0308, E0600, E0614. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs new file mode 100644 index 000000000..2a6c14435 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.rs @@ -0,0 +1,55 @@ +#![feature(let_chains)] + +fn main() { + let opt = Some(1i32); + + let Some(n) = opt else { + return; + }; + let Some(n) = opt && n == 1 else { + //~^ ERROR a `&&` expression cannot be directly assigned in `let...else` + //~| ERROR mismatched types + //~| ERROR mismatched types + return; + }; + let Some(n) = opt && let another = n else { + //~^ ERROR a `&&` expression cannot be directly assigned in `let...else` + //~| ERROR `let` expressions are not supported here + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR expected expression, found `let` statement + return; + }; + + if let Some(n) = opt else { + //~^ ERROR this `if` expression is missing a block after the condition + return; + }; + if let Some(n) = opt && n == 1 else { + //~^ ERROR this `if` expression is missing a block after the condition + return; + }; + if let Some(n) = opt && let another = n else { + //~^ ERROR this `if` expression is missing a block after the condition + return; + }; + + { + while let Some(n) = opt else { + //~^ ERROR expected `{`, found keyword `else` + return; + }; + } + { + while let Some(n) = opt && n == 1 else { + //~^ ERROR expected `{`, found keyword `else` + return; + }; + } + { + while let Some(n) = opt && let another = n else { + //~^ ERROR expected `{`, found keyword `else` + return; + }; + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr new file mode 100644 index 000000000..9bc3e7541 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr @@ -0,0 +1,147 @@ +error: a `&&` expression cannot be directly assigned in `let...else` + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:19 + | +LL | let Some(n) = opt && n == 1 else { + | ^^^^^^^^^^^^^ + | +help: wrap the expression in parentheses + | +LL | let Some(n) = (opt && n == 1) else { + | + + + +error: expected expression, found `let` statement + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:26 + | +LL | let Some(n) = opt && let another = n else { + | ^^^ + +error: a `&&` expression cannot be directly assigned in `let...else` + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:19 + | +LL | let Some(n) = opt && let another = n else { + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: wrap the expression in parentheses + | +LL | let Some(n) = (opt && let another = n) else { + | + + + +error: this `if` expression is missing a block after the condition + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:24:5 + | +LL | if let Some(n) = opt else { + | ^^ + | +help: add a block here + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:24:25 + | +LL | if let Some(n) = opt else { + | ^ +help: remove the `if` if you meant to write a `let...else` statement + | +LL - if let Some(n) = opt else { +LL + let Some(n) = opt else { + | + +error: this `if` expression is missing a block after the condition + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:28:5 + | +LL | if let Some(n) = opt && n == 1 else { + | ^^ + | +help: add a block here + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:28:35 + | +LL | if let Some(n) = opt && n == 1 else { + | ^ + +error: this `if` expression is missing a block after the condition + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:32:5 + | +LL | if let Some(n) = opt && let another = n else { + | ^^ + | +help: add a block here + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:32:44 + | +LL | if let Some(n) = opt && let another = n else { + | ^ + +error: expected `{`, found keyword `else` + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:38:33 + | +LL | while let Some(n) = opt else { + | ----- ----------------- ^^^^ expected `{` + | | | + | | this `while` condition successfully parsed + | while parsing the body of this `while` expression + +error: expected `{`, found keyword `else` + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:44:43 + | +LL | while let Some(n) = opt && n == 1 else { + | ----- --------------------------- ^^^^ expected `{` + | | | + | | this `while` condition successfully parsed + | while parsing the body of this `while` expression + +error: expected `{`, found keyword `else` + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:50:52 + | +LL | while let Some(n) = opt && let another = n else { + | ----- ------------------------------------ ^^^^ expected `{` + | | | + | | this `while` condition successfully parsed + | while parsing the body of this `while` expression + +error: `let` expressions are not supported here + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:26 + | +LL | let Some(n) = opt && let another = n else { + | ^^^^^^^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error[E0308]: mismatched types + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:19 + | +LL | let Some(n) = opt && n == 1 else { + | ^^^ expected `bool`, found `Option` + | + = note: expected type `bool` + found enum `Option` + +error[E0308]: mismatched types + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:9 + | +LL | let Some(n) = opt && n == 1 else { + | ^^^^^^^ ------------- this expression has type `bool` + | | + | expected `bool`, found `Option<_>` + | + = note: expected type `bool` + found enum `Option<_>` + +error[E0308]: mismatched types + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:19 + | +LL | let Some(n) = opt && let another = n else { + | ^^^ expected `bool`, found `Option` + | + = note: expected type `bool` + found enum `Option` + +error[E0308]: mismatched types + --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:9 + | +LL | let Some(n) = opt && let another = n else { + | ^^^^^^^ ---------------------- this expression has type `bool` + | | + | expected `bool`, found `Option<_>` + | + = note: expected type `bool` + found enum `Option<_>` + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs new file mode 100644 index 000000000..2b407ef51 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs @@ -0,0 +1,62 @@ +// gate-test-let_chains + +// Here we test feature gating for ´let_chains`. +// See `disallowed-positions.rs` for the grammar +// defining the language for gated allowed positions. + +#![allow(irrefutable_let_patterns)] + +use std::ops::Range; + +fn _if() { + if let 0 = 1 {} // Stable! + + if true && let 0 = 1 {} + //~^ ERROR `let` expressions in this position are unstable [E0658] + + if let 0 = 1 && true {} + //~^ ERROR `let` expressions in this position are unstable [E0658] + + if let Range { start: _, end: _ } = (true..true) && false {} + //~^ ERROR `let` expressions in this position are unstable [E0658] + + if let 1 = 1 && let true = { true } && false { + //~^ ERROR `let` expressions in this position are unstable [E0658] + //~| ERROR `let` expressions in this position are unstable [E0658] + } +} + +fn _while() { + while let 0 = 1 {} // Stable! + + while true && let 0 = 1 {} + //~^ ERROR `let` expressions in this position are unstable [E0658] + + while let 0 = 1 && true {} + //~^ ERROR `let` expressions in this position are unstable [E0658] + + while let Range { start: _, end: _ } = (true..true) && false {} + //~^ ERROR `let` expressions in this position are unstable [E0658] +} + +fn _macros() { + macro_rules! noop_expr { ($e:expr) => {}; } + + noop_expr!((let 0 = 1)); + //~^ ERROR `let` expressions in this position are unstable [E0658] + //~| ERROR expected expression, found `let` statement + + macro_rules! use_expr { + ($e:expr) => { + if $e {} + while $e {} + } + } + #[cfg(FALSE)] (let 0 = 1); + //~^ ERROR `let` expressions in this position are unstable [E0658] + //~| ERROR expected expression, found `let` statement + use_expr!(let 0 = 1); + //~^ ERROR no rules expected the token `let` +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr new file mode 100644 index 000000000..7a43b71fc --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr @@ -0,0 +1,120 @@ +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:55:20 + | +LL | #[cfg(FALSE)] (let 0 = 1); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/feature-gate.rs:45:17 + | +LL | noop_expr!((let 0 = 1)); + | ^^^ + +error: no rules expected the token `let` + --> $DIR/feature-gate.rs:58:15 + | +LL | macro_rules! use_expr { + | --------------------- when calling this macro +... +LL | use_expr!(let 0 = 1); + | ^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/feature-gate.rs:50:10 + | +LL | ($e:expr) => { + | ^^^^^^^ + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:14:16 + | +LL | if true && let 0 = 1 {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:17:8 + | +LL | if let 0 = 1 && true {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:20:8 + | +LL | if let Range { start: _, end: _ } = (true..true) && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:23:8 + | +LL | if let 1 = 1 && let true = { true } && false { + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:23:21 + | +LL | if let 1 = 1 && let true = { true } && false { + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:32:19 + | +LL | while true && let 0 = 1 {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:35:11 + | +LL | while let 0 = 1 && true {} + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:38:11 + | +LL | while let Range { start: _, end: _ } = (true..true) && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:55:20 + | +LL | #[cfg(FALSE)] (let 0 = 1); + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/feature-gate.rs:45:17 + | +LL | noop_expr!((let 0 = 1)); + | ^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs new file mode 100644 index 000000000..a942d1f4c --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs @@ -0,0 +1,45 @@ +#![feature(let_chains)] + +fn main() { + let _opt = Some(1i32); + + #[cfg(FALSE)] + { + let _ = &&let Some(x) = Some(42); + //~^ ERROR expected expression, found `let` statement + } + #[cfg(FALSE)] + { + if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 { + //~^ ERROR expected expression, found `let` statement + //~| ERROR expected expression, found `let` statement + true + } + } + + #[cfg(FALSE)] + { + if let Some(elem) = _opt && { + [1, 2, 3][let _ = ()]; + //~^ ERROR expected expression, found `let` statement + true + } { + } + } + + #[cfg(FALSE)] + { + if let Some(elem) = _opt && [1, 2, 3][let _ = ()] = 1 { + //~^ ERROR expected expression, found `let` statement + true + } + } + #[cfg(FALSE)] + { + if let a = 1 && { + let x = let y = 1; + //~^ ERROR expected expression, found `let` statement + } { + } + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr new file mode 100644 index 000000000..d1ce83c72 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.stderr @@ -0,0 +1,38 @@ +error: expected expression, found `let` statement + --> $DIR/invalid-let-in-a-valid-let-context.rs:8:19 + | +LL | let _ = &&let Some(x) = Some(42); + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/invalid-let-in-a-valid-let-context.rs:13:47 + | +LL | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/invalid-let-in-a-valid-let-context.rs:13:57 + | +LL | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/invalid-let-in-a-valid-let-context.rs:23:23 + | +LL | [1, 2, 3][let _ = ()]; + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/invalid-let-in-a-valid-let-context.rs:32:47 + | +LL | if let Some(elem) = _opt && [1, 2, 3][let _ = ()] = 1 { + | ^^^ + +error: expected expression, found `let` statement + --> $DIR/invalid-let-in-a-valid-let-context.rs:40:21 + | +LL | let x = let y = 1; + | ^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr new file mode 100644 index 000000000..be4a52315 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr @@ -0,0 +1,115 @@ +error: leading irrefutable pattern in let chain + --> $DIR/irrefutable-lets.rs:13:8 + | +LL | if let first = &opt && let Some(ref second) = first && let None = second.start {} + | ^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match + = help: consider moving it outside of the construct +note: the lint level is defined here + --> $DIR/irrefutable-lets.rs:6:30 + | +LL | #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: irrefutable `if let` patterns + --> $DIR/irrefutable-lets.rs:19:8 + | +LL | if let first = &opt && let (a, b) = (1, 2) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: these patterns will always match, so the `if let` is useless + = help: consider replacing the `if let` with a `let` + +error: leading irrefutable pattern in let chain + --> $DIR/irrefutable-lets.rs:22:8 + | +LL | if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} + | ^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match + = help: consider moving it outside of the construct + +error: trailing irrefutable pattern in let chain + --> $DIR/irrefutable-lets.rs:22:87 + | +LL | if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} + | ^^^^^^^^^ + | + = note: this pattern will always match + = help: consider moving it into the body + +error: trailing irrefutable patterns in let chain + --> $DIR/irrefutable-lets.rs:26:37 + | +LL | if let Some(ref first) = opt && let second = first && let _third = second {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: these patterns will always match + = help: consider moving them into the body + +error: leading irrefutable pattern in let chain + --> $DIR/irrefutable-lets.rs:29:8 + | +LL | if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match + = help: consider moving it outside of the construct + +error: leading irrefutable pattern in let chain + --> $DIR/irrefutable-lets.rs:32:8 + | +LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match + = help: consider moving it outside of the construct + +error: leading irrefutable pattern in let chain + --> $DIR/irrefutable-lets.rs:35:8 + | +LL | if let first = &opt && let None = Some(1) {} + | ^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match + = help: consider moving it outside of the construct + +error: irrefutable `if let` guard patterns + --> $DIR/irrefutable-lets.rs:44:28 + | +LL | Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: these patterns will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm + +error: trailing irrefutable patterns in let chain + --> $DIR/irrefutable-lets.rs:59:16 + | +LL | && let v = local_end && let w = v => {}, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: these patterns will always match + = help: consider moving them into the body + +error: irrefutable `while let` patterns + --> $DIR/irrefutable-lets.rs:68:11 + | +LL | while let first = &opt && let (a, b) = (1, 2) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: these patterns will always match, so the loop will never exit + = help: consider instead using a `loop { ... }` with a `let` inside it + +error: trailing irrefutable patterns in let chain + --> $DIR/irrefutable-lets.rs:71:40 + | +LL | while let Some(ref first) = opt && let second = first && let _third = second {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: these patterns will always match + = help: consider moving them into the body + +error: aborting due to 12 previous errors + diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs new file mode 100644 index 000000000..9afb6853b --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs @@ -0,0 +1,78 @@ +// revisions: allowed disallowed +//[allowed] check-pass + +#![feature(if_let_guard, let_chains)] +#![cfg_attr(allowed, allow(irrefutable_let_patterns))] +#![cfg_attr(disallowed, deny(irrefutable_let_patterns))] + +use std::ops::Range; + +fn main() { + let opt = Some(None..Some(1)); + + if let first = &opt && let Some(ref second) = first && let None = second.start {} + //[disallowed]~^ ERROR leading irrefutable pattern in let chain + + // No lint as the irrefutable pattern is surrounded by other stuff + if 4 * 2 == 0 && let first = &opt && let Some(ref second) = first && let None = second.start {} + + if let first = &opt && let (a, b) = (1, 2) {} + //[disallowed]~^ ERROR irrefutable `if let` patterns + + if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} + //[disallowed]~^ ERROR leading irrefutable pattern in let chain + //[disallowed]~^^ ERROR trailing irrefutable pattern in let chain + + if let Some(ref first) = opt && let second = first && let _third = second {} + //[disallowed]~^ ERROR trailing irrefutable patterns in let chain + + if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} + //[disallowed]~^ ERROR leading irrefutable pattern in let chain + + if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} + //[disallowed]~^ ERROR leading irrefutable pattern in let chain + + if let first = &opt && let None = Some(1) {} + //[disallowed]~^ ERROR leading irrefutable pattern in let chain + + if let Some(ref first) = opt + && let Range { start: local_start, end: _ } = first + && let None = local_start { + } + + match opt { + Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, + //[disallowed]~^ ERROR irrefutable `if let` guard patterns + _ => {} + } + + // No error about leading irrefutable patterns: the expr on the rhs might + // use the bindings created by the match. + match opt { + Some(ref first) if let Range { start: local_start, end: _ } = first + && let None = local_start => {}, + _ => {} + } + + match opt { + Some(ref first) if let Range { start: Some(_), end: local_end } = first + && let v = local_end && let w = v => {}, + //[disallowed]~^ ERROR trailing irrefutable patterns in let chain + _ => {} + } + + // No error, despite the prefix being irrefutable: moving out could change the behaviour, + // due to possible side effects of the operation. + while let first = &opt && let Some(ref second) = first && let None = second.start {} + + while let first = &opt && let (a, b) = (1, 2) {} + //[disallowed]~^ ERROR irrefutable `while let` patterns + + while let Some(ref first) = opt && let second = first && let _third = second {} + //[disallowed]~^ ERROR trailing irrefutable patterns in let chain + + while let Some(ref first) = opt + && let Range { start: local_start, end: _ } = first + && let None = local_start { + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-88498.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-88498.rs new file mode 100644 index 000000000..3eb8a9ad0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-88498.rs @@ -0,0 +1,16 @@ +// check-pass + +pub enum UnOp { + Not(Vec<()>), +} + +pub fn foo() { + if let Some(x) = None { + match x { + UnOp::Not(_) => {} + } + } +} + +fn main() { +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-90722.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-90722.rs new file mode 100644 index 000000000..6b7d88356 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-90722.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(let_chains)] + +fn main() { + let x = Some(vec!["test"]); + + if let Some(v) = x && v.is_empty() { + println!("x == Some([])"); + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-92145.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-92145.rs new file mode 100644 index 000000000..7c7e31f4d --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-92145.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(let_chains)] + +fn main() { + let opt = Some("foo bar"); + + if true && let Some(x) = opt { + println!("{}", x); + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs new file mode 100644 index 000000000..f90b9ab0d --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs @@ -0,0 +1,8 @@ +fn main() { + match true { + _ if let true = true && true => {} + //~^ ERROR `if let` guards are + //~| ERROR `let` expressions in this + _ => {} + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr new file mode 100644 index 000000000..b25f299a2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr @@ -0,0 +1,22 @@ +error[E0658]: `if let` guards are experimental + --> $DIR/issue-93150.rs:3:11 + | +LL | _ if let true = true && true => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51114 for more information + = help: add `#![feature(if_let_guard)]` to the crate attributes to enable + = help: you can write `if matches!(, )` instead of `if let = ` + +error[E0658]: `let` expressions in this position are unstable + --> $DIR/issue-93150.rs:3:14 + | +LL | _ if let true = true && true => {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #53667 for more information + = help: add `#![feature(let_chains)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-99938.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-99938.rs new file mode 100644 index 000000000..bd81ce0b1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-99938.rs @@ -0,0 +1,31 @@ +// compile-flags: -Zvalidate-mir -C opt-level=3 +// build-pass +#![feature(let_chains)] +struct TupleIter> { + inner: I, +} + +impl> Iterator for TupleIter { + type Item = (T, T, T); + + fn next(&mut self) -> Option { + let inner = &mut self.inner; + + if let Some(first) = inner.next() + && let Some(second) = inner.next() + && let Some(third) = inner.next() + { + Some((first, second, third)) + } else { + None + } + } +} + +fn main() { + let vec: Vec = Vec::new(); + let mut tup_iter = TupleIter { + inner: vec.into_iter(), + }; + tup_iter.next(); +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/no-double-assigments.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/no-double-assigments.rs new file mode 100644 index 000000000..6b91c455e --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/no-double-assigments.rs @@ -0,0 +1,9 @@ +// check-pass + +fn main() { + loop { + // [1][0] should leave top scope + if true && [1][0] == 1 && true { + } + } +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.rs new file mode 100644 index 000000000..fcc09b159 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.rs @@ -0,0 +1,17 @@ +// run-pass + +#![allow(irrefutable_let_patterns)] + +fn main() { + let x: bool; + // This should associate as: `(x = (true && false));`. + x = true && false; + assert!(!x); + + fn _f1() -> bool { + // Should associate as `(let _ = (return (true && false)))`. + if let _ = return true && false {}; + //~^ WARNING unreachable block in `if` + } + assert!(!_f1()); +} diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.stderr new file mode 100644 index 000000000..24b35a2ab --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/protect-precedences.stderr @@ -0,0 +1,12 @@ +warning: unreachable block in `if` or `while` expression + --> $DIR/protect-precedences.rs:13:41 + | +LL | if let _ = return true && false {}; + | -------------------- ^^ unreachable block in `if` or `while` expression + | | + | any code following this expression is unreachable + | + = note: `#[warn(unreachable_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs new file mode 100644 index 000000000..e061174f6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs @@ -0,0 +1,49 @@ +// run-pass + +#![feature(if_let_guard, let_chains)] + +fn check_if_let(opt: Option>>, value: i32) -> bool { + if let Some(first) = opt + && let Some(second) = first + && let Some(third) = second + && third == value + { + true + } + else { + false + } +} + +fn check_let_guard(opt: Option>>, value: i32) -> bool { + match opt { + Some(first) if let Some(second) = first && let Some(third) = second && third == value => { + true + } + _ => { + false + } + } +} + +fn check_while_let(opt: Option>>, value: i32) -> bool { + while let Some(first) = opt + && let Some(second) = first + && let Some(third) = second + && third == value + { + return true; + } + false +} + +fn main() { + assert_eq!(check_if_let(Some(Some(Some(1))), 1), true); + assert_eq!(check_if_let(Some(Some(Some(1))), 9), false); + + assert_eq!(check_let_guard(Some(Some(Some(1))), 1), true); + assert_eq!(check_let_guard(Some(Some(Some(1))), 9), false); + + assert_eq!(check_while_let(Some(Some(Some(1))), 1), true); + assert_eq!(check_while_let(Some(Some(Some(1))), 9), false); +} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.rs b/tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.rs new file mode 100644 index 000000000..eeb2191ba --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.rs @@ -0,0 +1,16 @@ +#[cfg(FALSE)] +impl S { + fn f(#[attr]) {} //~ ERROR expected parameter name, found `)` +} + +#[cfg(FALSE)] +impl T for S { + fn f(#[attr]) {} //~ ERROR expected parameter name, found `)` +} + +#[cfg(FALSE)] +trait T { + fn f(#[attr]); //~ ERROR expected argument name, found `)` +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.stderr new file mode 100644 index 000000000..26dff4d4b --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/attr-without-param.stderr @@ -0,0 +1,20 @@ +error: expected parameter name, found `)` + --> $DIR/attr-without-param.rs:3:17 + | +LL | fn f(#[attr]) {} + | ^ expected parameter name + +error: expected parameter name, found `)` + --> $DIR/attr-without-param.rs:8:17 + | +LL | fn f(#[attr]) {} + | ^ expected parameter name + +error: expected argument name, found `)` + --> $DIR/attr-without-param.rs:13:17 + | +LL | fn f(#[attr]); + | ^ expected argument name + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/ident-mac.rs b/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/ident-mac.rs new file mode 100644 index 000000000..b62cf3120 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/ident-mac.rs @@ -0,0 +1,11 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn id(_: TokenStream, input: TokenStream) -> TokenStream { input } diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs b/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs new file mode 100644 index 000000000..82c4120b4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/auxiliary/param-attrs.rs @@ -0,0 +1,43 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +macro_rules! checker { + ($attr_name:ident, $expected:literal) => { + #[proc_macro_attribute] + pub fn $attr_name(attr: TokenStream, input: TokenStream) -> TokenStream { + assert_eq!(input.to_string(), $expected); + TokenStream::new() + } + } +} + +checker!(attr_extern, r#"extern "C" { fn ffi(#[a1] arg1 : i32, #[a2] ...) ; }"#); +checker!(attr_extern_cvar, r#"unsafe extern "C" fn cvar(arg1 : i32, #[a1] mut args : ...) {}"#); +checker!(attr_alias, "type Alias = fn(#[a1] u8, #[a2] ...) ;"); +checker!(attr_free, "fn free(#[a1] arg1 : u8) { let lam = | #[a2] W(x), #[a3] y | () ; }"); +checker!(attr_inherent_1, "fn inherent1(#[a1] self, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_2, "fn inherent2(#[a1] & self, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_3, "fn inherent3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_4, "fn inherent4 < 'a > (#[a1] self : Box < Self >, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_issue_64682, "fn inherent5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) {}"); +checker!(attr_trait_1, "fn trait1(#[a1] self, #[a2] arg1 : u8) ;"); +checker!(attr_trait_2, "fn trait2(#[a1] & self, #[a2] arg1 : u8) ;"); +checker!(attr_trait_3, "fn trait3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) ;"); +checker!(attr_trait_4, r#"fn trait4 < 'a > +(#[a1] self : Box < Self >, #[a2] arg1 : u8, #[a3] Vec < u8 >) ;"#); +checker!(attr_trait_issue_64682, "fn trait5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) ;"); +checker!(rename_params, r#"impl Foo +{ + fn hello(#[angery(true)] a : i32, #[a2] b : i32, #[what = "how"] c : u32) + {} fn + hello2(#[a1] #[a2] a : i32, #[what = "how"] b : i32, #[angery(true)] c : + u32) {} fn + hello_self(#[a1] #[a2] & self, #[a1] #[a2] a : i32, #[what = "how"] b : + i32, #[angery(true)] c : u32) {} +}"#); diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs b/tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs new file mode 100644 index 000000000..670303906 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs @@ -0,0 +1,21 @@ +// aux-build:param-attrs.rs + +// check-pass + +extern crate param_attrs; + +use param_attrs::rename_params; + +#[rename_params(send_help)] +impl Foo { + fn hello(#[angery(true)] a: i32, #[a2] b: i32, #[what = "how"] c: u32) {} + fn hello2(#[a1] #[a2] a: i32, #[what = "how"] b: i32, #[angery(true)] c: u32) {} + fn hello_self( + #[a1] #[a2] &self, + #[a1] #[a2] a: i32, + #[what = "how"] b: i32, + #[angery(true)] c: u32 + ) {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.rs new file mode 100644 index 000000000..a6f693bd5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.rs @@ -0,0 +1,6 @@ +// edition:2018 + +trait Trait2015 { fn foo(#[allow(C)] i32); } +//~^ ERROR expected one of `:`, `@`, or `|`, found `)` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.stderr new file mode 100644 index 000000000..593821bf9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-2018.stderr @@ -0,0 +1,22 @@ +error: expected one of `:`, `@`, or `|`, found `)` + --> $DIR/param-attrs-2018.rs:3:41 + | +LL | trait Trait2015 { fn foo(#[allow(C)] i32); } + | ^ expected one of `:`, `@`, or `|` + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | trait Trait2015 { fn foo(#[allow(C)] self: i32); } + | +++++ +help: if this is a parameter name, give it a type + | +LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); } + | ++++++++++ +help: if this is a type, explicitly ignore the parameter name + | +LL | trait Trait2015 { fn foo(#[allow(C)] _: i32); } + | ++ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs new file mode 100644 index 000000000..2de37c859 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-allowed.rs @@ -0,0 +1,101 @@ +// check-pass +// compile-flags: --cfg something + +#![deny(unused_mut)] + +extern "C" { + fn ffi( + #[allow(unused_mut)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[forbid(unused_mut)] d: i32, + #[deny(unused_mut)] #[warn(unused_mut)] ... + ); +} + +type FnType = fn( + #[allow(unused_mut)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[forbid(unused_mut)] d: i32, + #[deny(unused_mut)] #[warn(unused_mut)] e: i32 +); + +pub fn foo( + #[allow(unused_mut)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[forbid(unused_mut)] d: i32, + #[deny(unused_mut)] #[warn(unused_mut)] _e: i32 +) {} + +// self + +struct SelfStruct {} +impl SelfStruct { + fn foo( + #[allow(unused_mut)] self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(unused_mut)] b: i32, + ) {} +} + +struct RefStruct {} +impl RefStruct { + fn foo( + #[allow(unused_mut)] &self, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(unused_mut)] b: i32, + ) {} +} +trait RefTrait { + fn foo( + #[forbid(unused_mut)] &self, + #[warn(unused_mut)] a: i32 + ) {} +} +impl RefTrait for RefStruct { + fn foo( + #[forbid(unused_mut)] &self, + #[warn(unused_mut)] a: i32 + ) {} +} + +// Box + +struct BoxSelfStruct {} +impl BoxSelfStruct { + fn foo( + #[allow(unused_mut)] self: Box, + #[cfg(something)] a: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(unused_mut)] b: i32, + ) {} +} +trait BoxSelfTrait { + fn foo( + #[forbid(unused_mut)] self: Box, + #[warn(unused_mut)] a: i32 + ) {} +} +impl BoxSelfTrait for BoxSelfStruct { + fn foo( + #[forbid(unused_mut)] self: Box, + #[warn(unused_mut)] a: i32 + ) {} +} + +fn main() { + let _: unsafe extern "C" fn(_, _, _, ...) = ffi; + let _: fn(_, _, _, _) = foo; + let _: FnType = |_, _, _, _| {}; + let c = | + #[allow(unused_mut)] a: u32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] + #[deny(unused_mut)] c: i32, + | {}; + c(1, 2); +} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs new file mode 100644 index 000000000..151659e35 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.rs @@ -0,0 +1,174 @@ +extern "C" { + fn ffi( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ); +} + +type FnType = fn( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: u32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters +); + +pub fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: u32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters +) {} + +struct SelfStruct {} +impl SelfStruct { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ) {} + + fn issue_64682_associated_fn( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ) {} +} + +struct RefStruct {} +impl RefStruct { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + &self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ) {} +} +trait RefTrait { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + &self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ) {} + + fn issue_64682_associated_fn( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ) {} +} + +impl RefTrait for RefStruct { + fn foo( + /// Foo + //~^ ERROR documentation comments cannot be applied to function + &self, + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[test] a: i32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Qux + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32, + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + ) {} +} + +fn main() { + let _ = | + /// Foo + //~^ ERROR documentation comments cannot be applied to function + #[test] a: u32, + //~^ ERROR expected non-macro attribute, found attribute macro + /// Bar + //~^ ERROR documentation comments cannot be applied to function + #[must_use] + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + /// Baz + //~^ ERROR documentation comments cannot be applied to function + #[no_mangle] b: i32 + //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + | {}; +} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr new file mode 100644 index 000000000..7573e39d8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr @@ -0,0 +1,386 @@ +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:5:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:21:7 + | +LL | #[test] a: u32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:36:7 + | +LL | #[test] a: u32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:56:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:71:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:92:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:111:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:126:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:146:11 + | +LL | #[test] a: i32, + | ^^^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `test` + --> $DIR/param-attrs-builtin-attrs.rs:163:11 + | +LL | #[test] a: u32, + | ^^^^ not a non-macro attribute + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:3:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:7:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:9:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:11:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:13:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:19:5 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:23:5 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:25:5 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:27:5 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:29:5 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:34:5 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:38:5 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:40:5 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:42:5 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:44:5 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:51:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:54:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:58:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:60:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:62:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:64:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:69:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:73:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:75:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:77:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:79:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:87:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:90:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:94:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:96:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:98:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:100:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:106:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:109:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:113:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:115:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:117:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:119:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:124:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:128:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:130:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:132:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:134:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:141:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:144:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:148:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:150:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:152:9 + | +LL | /// Qux + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:154:9 + | +LL | #[no_mangle] b: i32, + | ^^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:161:9 + | +LL | /// Foo + | ^^^^^^^ doc comments are not allowed here + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:165:9 + | +LL | /// Bar + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:167:9 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +error: documentation comments cannot be applied to function parameters + --> $DIR/param-attrs-builtin-attrs.rs:169:9 + | +LL | /// Baz + | ^^^^^^^ doc comments are not allowed here + +error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters + --> $DIR/param-attrs-builtin-attrs.rs:171:9 + | +LL | #[no_mangle] b: i32 + | ^^^^^^^^^^^^ + +error: aborting due to 64 previous errors + diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs new file mode 100644 index 000000000..14539d4b6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.rs @@ -0,0 +1,121 @@ +// compile-flags: --cfg something +// edition:2018 + +#![feature(async_closure)] +#![deny(unused_variables)] + +extern "C" { + fn ffi( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(something, cfg(nothing))] c: i32, + #[cfg_attr(nothing, cfg(nothing))] ... + ); +} + +type FnType = fn( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + #[cfg_attr(nothing, cfg(nothing))] c: i32, + #[cfg_attr(something, cfg(nothing))] d: i32, +); + +async fn foo_async( + #[cfg(something)] a: i32, + //~^ ERROR unused variable: `a` + #[cfg(nothing)] b: i32, +) {} +fn foo( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, +) {} + +struct RefStruct {} +impl RefStruct { + async fn bar_async( + &self, + #[cfg(something)] a: i32, + //~^ ERROR unused variable: `a` + #[cfg(nothing)] b: i32, + ) {} + fn bar( + &self, + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} + fn issue_64682_associated_fn( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} +} +trait RefTrait { + fn bar( + &self, + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} + fn issue_64682_associated_fn( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} +} +impl RefTrait for RefStruct { + fn bar( + &self, + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} + fn issue_64682_associated_fn( + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + ) {} +} + +fn main() { + let _: unsafe extern "C" fn(_, ...) = ffi; + let _: fn(_, _) = foo; + let _: FnType = |_, _| {}; + let a = async move | + #[cfg(something)] a: i32, + //~^ ERROR unused variable: `a` + #[cfg(nothing)] b: i32, + | {}; + let c = | + #[cfg(nothing)] a: i32, + #[cfg(something)] b: i32, + //~^ ERROR unused variable: `b` + #[cfg_attr(nothing, cfg(nothing))] c: i32, + //~^ ERROR unused variable: `c` + #[cfg_attr(something, cfg(nothing))] d: i32, + | {}; + a(1); + c(1, 2); +} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.stderr new file mode 100644 index 000000000..16e1af460 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-cfg.stderr @@ -0,0 +1,122 @@ +error: unused variable: `a` + --> $DIR/param-attrs-cfg.rs:24:23 + | +LL | #[cfg(something)] a: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_a` + | +note: the lint level is defined here + --> $DIR/param-attrs-cfg.rs:5:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: unused variable: `a` + --> $DIR/param-attrs-cfg.rs:41:27 + | +LL | #[cfg(something)] a: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_a` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:30:23 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:32:40 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:48:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:50:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:56:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:58:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:67:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:69:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:75:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:77:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:86:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:88:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:94:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:96:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: unused variable: `a` + --> $DIR/param-attrs-cfg.rs:107:27 + | +LL | #[cfg(something)] a: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_a` + +error: unused variable: `b` + --> $DIR/param-attrs-cfg.rs:113:27 + | +LL | #[cfg(something)] b: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_b` + +error: unused variable: `c` + --> $DIR/param-attrs-cfg.rs:115:44 + | +LL | #[cfg_attr(nothing, cfg(nothing))] c: i32, + | ^ help: if this is intentional, prefix it with an underscore: `_c` + +error: aborting due to 19 previous errors + diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs new file mode 100644 index 000000000..1183ac65b --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs @@ -0,0 +1,61 @@ +// aux-build:param-attrs.rs + +// check-pass + +#![feature(c_variadic)] + +extern crate param_attrs; + +use param_attrs::*; + +struct W(u8); + +#[attr_extern] +extern "C" { fn ffi(#[a1] arg1: i32, #[a2] ...); } + +#[attr_extern_cvar] +unsafe extern "C" fn cvar(arg1: i32, #[a1] mut args: ...) {} + +#[attr_alias] +type Alias = fn(#[a1] u8, #[a2] ...); + +#[attr_free] +fn free(#[a1] arg1: u8) { + let lam = |#[a2] W(x), #[a3] y| (); +} + +impl W { + #[attr_inherent_1] + fn inherent1(#[a1] self, #[a2] arg1: u8) {} + + #[attr_inherent_2] + fn inherent2(#[a1] &self, #[a2] arg1: u8) {} + + #[attr_inherent_3] + fn inherent3<'a>(#[a1] &'a mut self, #[a2] arg1: u8) {} + + #[attr_inherent_4] + fn inherent4<'a>(#[a1] self: Box, #[a2] arg1: u8) {} + + #[attr_inherent_issue_64682] + fn inherent5(#[a1] #[a2] arg1: u8, #[a3] arg2: u8) {} +} + +trait A { + #[attr_trait_1] + fn trait1(#[a1] self, #[a2] arg1: u8); + + #[attr_trait_2] + fn trait2(#[a1] &self, #[a2] arg1: u8); + + #[attr_trait_3] + fn trait3<'a>(#[a1] &'a mut self, #[a2] arg1: u8); + + #[attr_trait_4] + fn trait4<'a>(#[a1] self: Box, #[a2] arg1: u8, #[a3] Vec); + + #[attr_trait_issue_64682] + fn trait5(#[a1] #[a2] arg1: u8, #[a3] arg2: u8); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs new file mode 100644 index 000000000..54f2f451b --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.rs @@ -0,0 +1,66 @@ +// aux-build:ident-mac.rs + +#![feature(c_variadic)] +#![allow(anonymous_parameters)] + +extern crate ident_mac; +use ident_mac::id; + +struct W(u8); + +extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } +//~^ ERROR expected non-macro attribute, found attribute macro +//~| ERROR expected non-macro attribute, found attribute macro + +unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} +//~^ ERROR expected non-macro attribute, found attribute macro + +type Alias = extern "C" fn(#[id] u8, #[id] ...); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + +fn free(#[id] arg1: u8) { + //~^ ERROR expected non-macro attribute, found attribute macro + let lam = |#[id] W(x), #[id] y: usize| (); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro +} + +impl W { + fn inherent1(#[id] self, #[id] arg1: u8) {} + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn inherent2(#[id] &self, #[id] arg1: u8) {} + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro +} + +trait A { + fn trait1(#[id] self, #[id] arg1: u8); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn trait2(#[id] &self, #[id] arg1: u8); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro + fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); + //~^ ERROR expected non-macro attribute, found attribute macro + //~| ERROR expected non-macro attribute, found attribute macro +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr new file mode 100644 index 000000000..e74d05d49 --- /dev/null +++ b/tests/ui/rfcs/rfc-2565-param-attrs/proc-macro-cannot-be-used.stderr @@ -0,0 +1,176 @@ +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:11:23 + | +LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:11:40 + | +LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:15:40 + | +LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:18:30 + | +LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:18:40 + | +LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:22:11 + | +LL | fn free(#[id] arg1: u8) { + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:24:18 + | +LL | let lam = |#[id] W(x), #[id] y: usize| (); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:24:30 + | +LL | let lam = |#[id] W(x), #[id] y: usize| (); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:30:20 + | +LL | fn inherent1(#[id] self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:30:32 + | +LL | fn inherent1(#[id] self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:33:20 + | +LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:33:33 + | +LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:36:24 + | +LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:36:44 + | +LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:39:24 + | +LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:39:47 + | +LL | fn inherent4<'a>(#[id] self: Box, #[id] arg1: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:42:40 + | +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:42:56 + | +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:48:17 + | +LL | fn trait1(#[id] self, #[id] arg1: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:48:29 + | +LL | fn trait1(#[id] self, #[id] arg1: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:51:17 + | +LL | fn trait2(#[id] &self, #[id] arg1: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:51:30 + | +LL | fn trait2(#[id] &self, #[id] arg1: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:54:21 + | +LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:54:41 + | +LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:57:21 + | +LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:57:44 + | +LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:57:60 + | +LL | fn trait4<'a>(#[id] self: Box, #[id] arg1: u8, #[id] Vec); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:61:40 + | +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); + | ^^ not a non-macro attribute + +error: expected non-macro attribute, found attribute macro `id` + --> $DIR/proc-macro-cannot-be-used.rs:61:56 + | +LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); + | ^^ not a non-macro attribute + +error: aborting due to 29 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs new file mode 100644 index 000000000..d7a418959 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.rs @@ -0,0 +1,19 @@ +// Tests that dlltool failing to generate an import library will raise an error. + +// only-gnu +// only-windows +// needs-dlltool +// compile-flags: --crate-type lib --emit link +// normalize-stderr-test: "[^ ']*/dlltool.exe" -> "$$DLLTOOL" +// normalize-stderr-test: "[^ ]*/foo.def" -> "$$DEF_FILE" +#[link(name = "foo", kind = "raw-dylib")] +extern "C" { + // `@1` is an invalid name to export, as it usually indicates that something + // is being exported via ordinal. + #[link_name = "@1"] + fn f(x: i32); +} + +pub fn lib_main() { + unsafe { f(42); } +} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr new file mode 100644 index 000000000..020ac6a2b --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/dlltool-failed.stderr @@ -0,0 +1,5 @@ +error: Dlltool could not create import library: + $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/import-name-type-invalid-format.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs new file mode 100644 index 000000000..7bc44d65b --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.rs @@ -0,0 +1,7 @@ +// only-windows +// only-x86 +#[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] +//~^ ERROR import name type must be of the form `import_name_type = "string"` +extern "C" { } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr new file mode 100644 index 000000000..fb70b987f --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-invalid-format.stderr @@ -0,0 +1,8 @@ +error: import name type must be of the form `import_name_type = "string"` + --> $DIR/import-name-type-invalid-format.rs:3:42 + | +LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs new file mode 100644 index 000000000..b96f61a26 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.rs @@ -0,0 +1,8 @@ +// ignore-tidy-linelength +// only-windows +// only-x86 +#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] +//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute +extern "C" { } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr new file mode 100644 index 000000000..953306189 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-multiple.stderr @@ -0,0 +1,8 @@ +error: multiple `import_name_type` arguments in a single `#[link]` attribute + --> $DIR/import-name-type-multiple.rs:4:74 + | +LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs new file mode 100644 index 000000000..067e82a17 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.rs @@ -0,0 +1,7 @@ +// only-windows +// only-x86 +#[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] +//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated +extern "C" { } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr new file mode 100644 index 000000000..2bce9758e --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unknown-value.stderr @@ -0,0 +1,8 @@ +error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated + --> $DIR/import-name-type-unknown-value.rs:3:42 + | +LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs new file mode 100644 index 000000000..34e907bde --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.rs @@ -0,0 +1,15 @@ +// only-windows +// only-x86 +#[link(name = "foo", import_name_type = "decorated")] +//~^ ERROR import name type can only be used with link kind `raw-dylib` +extern "C" { } + +#[link(name = "bar", kind = "static", import_name_type = "decorated")] +//~^ ERROR import name type can only be used with link kind `raw-dylib` +extern "C" { } + +// Specifying `import_name_type` before `kind` shouldn't raise an error. +#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")] +extern "C" { } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr new file mode 100644 index 000000000..75cadc471 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-unsupported-link-kind.stderr @@ -0,0 +1,14 @@ +error: import name type can only be used with link kind `raw-dylib` + --> $DIR/import-name-type-unsupported-link-kind.rs:3:22 + | +LL | #[link(name = "foo", import_name_type = "decorated")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: import name type can only be used with link kind `raw-dylib` + --> $DIR/import-name-type-unsupported-link-kind.rs:7:39 + | +LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs new file mode 100644 index 000000000..346ea18a8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.rs @@ -0,0 +1,7 @@ +// only-windows +// ignore-x86 +#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] +//~^ ERROR import name type is only supported on x86 +extern "C" { } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr new file mode 100644 index 000000000..b56449299 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/import-name-type-x86-only.stderr @@ -0,0 +1,8 @@ +error: import name type is only supported on x86 + --> $DIR/import-name-type-x86-only.rs:3:42 + | +LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs new file mode 100644 index 000000000..a07be9d92 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.rs @@ -0,0 +1,13 @@ +// Tests that failing to run dlltool will raise an error. + +// only-gnu +// only-windows +// compile-flags: --crate-type lib --emit link -Cdlltool=does_not_exit.exe +#[link(name = "foo", kind = "raw-dylib")] +extern "C" { + fn f(x: i32); +} + +pub fn lib_main() { + unsafe { f(42); } +} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr new file mode 100644 index 000000000..3ae901e0d --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/invalid-dlltool.stderr @@ -0,0 +1,4 @@ +error: Error calling dlltool 'does_not_exit.exe': program not found + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs new file mode 100644 index 000000000..b04c2facb --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.rs @@ -0,0 +1,13 @@ +#[link(name="foo")] +extern "C" { + #[link_name="foo"] + #[link_ordinal(42)] + //~^ ERROR cannot use `#[link_name]` with `#[link_ordinal]` + fn foo(); + #[link_name="foo"] + #[link_ordinal(5)] + //~^ ERROR cannot use `#[link_name]` with `#[link_ordinal]` + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr new file mode 100644 index 000000000..f1e54d378 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-and-name.stderr @@ -0,0 +1,14 @@ +error: cannot use `#[link_name]` with `#[link_ordinal]` + --> $DIR/link-ordinal-and-name.rs:4:5 + | +LL | #[link_ordinal(42)] + | ^^^^^^^^^^^^^^^^^^^ + +error: cannot use `#[link_name]` with `#[link_ordinal]` + --> $DIR/link-ordinal-and-name.rs:8:5 + | +LL | #[link_ordinal(5)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs new file mode 100644 index 000000000..9b7e8d707 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.rs @@ -0,0 +1,11 @@ +#[link(name = "foo")] +extern "C" { + #[link_ordinal("JustMonika")] + //~^ ERROR illegal ordinal format in `link_ordinal` + fn foo(); + #[link_ordinal("JustMonika")] + //~^ ERROR illegal ordinal format in `link_ordinal` + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr new file mode 100644 index 000000000..6341e57a0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-invalid-format.stderr @@ -0,0 +1,18 @@ +error: illegal ordinal format in `link_ordinal` + --> $DIR/link-ordinal-invalid-format.rs:3:5 + | +LL | #[link_ordinal("JustMonika")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an unsuffixed integer value, e.g., `1`, is expected + +error: illegal ordinal format in `link_ordinal` + --> $DIR/link-ordinal-invalid-format.rs:6:5 + | +LL | #[link_ordinal("JustMonika")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an unsuffixed integer value, e.g., `1`, is expected + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs new file mode 100644 index 000000000..6b8cd4956 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.rs @@ -0,0 +1,11 @@ +#[link(name = "foo")] +extern "C" { + #[link_ordinal()] + //~^ ERROR incorrect number of arguments to `#[link_ordinal]` + fn foo(); + #[link_ordinal()] + //~^ ERROR incorrect number of arguments to `#[link_ordinal]` + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr new file mode 100644 index 000000000..1b04bb228 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-missing-argument.stderr @@ -0,0 +1,18 @@ +error: incorrect number of arguments to `#[link_ordinal]` + --> $DIR/link-ordinal-missing-argument.rs:3:5 + | +LL | #[link_ordinal()] + | ^^^^^^^^^^^^^^^^^ + | + = note: the attribute requires exactly one argument + +error: incorrect number of arguments to `#[link_ordinal]` + --> $DIR/link-ordinal-missing-argument.rs:6:5 + | +LL | #[link_ordinal()] + | ^^^^^^^^^^^^^^^^^ + | + = note: the attribute requires exactly one argument + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs new file mode 100644 index 000000000..8842cb944 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.rs @@ -0,0 +1,12 @@ +// only-windows +#[link(name = "foo", kind = "raw-dylib")] +extern "C" { + #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes + #[link_ordinal(2)] + fn foo(); + #[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes + #[link_ordinal(2)] + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr new file mode 100644 index 000000000..2e6cf3761 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-multiple.stderr @@ -0,0 +1,26 @@ +error: multiple `link_ordinal` attributes + --> $DIR/link-ordinal-multiple.rs:4:5 + | +LL | #[link_ordinal(1)] + | ^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/link-ordinal-multiple.rs:5:5 + | +LL | #[link_ordinal(2)] + | ^^^^^^^^^^^^^^^^^^ + +error: multiple `link_ordinal` attributes + --> $DIR/link-ordinal-multiple.rs:7:5 + | +LL | #[link_ordinal(1)] + | ^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/link-ordinal-multiple.rs:8:5 + | +LL | #[link_ordinal(2)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs new file mode 100644 index 000000000..f33a3d62e --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs @@ -0,0 +1,22 @@ +#[link_ordinal(123)] +//~^ ERROR attribute should be applied to a foreign function or static +struct Foo {} + +#[link_ordinal(123)] +//~^ ERROR attribute should be applied to a foreign function or static +fn test() {} + +#[link_ordinal(42)] +//~^ ERROR attribute should be applied to a foreign function or static +static mut imported_val: i32 = 123; + +#[link(name = "exporter", kind = "raw-dylib")] +extern { + #[link_ordinal(13)] + fn imported_function(); + + #[link_ordinal(42)] + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr new file mode 100644 index 000000000..8f2795087 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.stderr @@ -0,0 +1,20 @@ +error: attribute should be applied to a foreign function or static + --> $DIR/link-ordinal-not-foreign-fn.rs:1:1 + | +LL | #[link_ordinal(123)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: attribute should be applied to a foreign function or static + --> $DIR/link-ordinal-not-foreign-fn.rs:5:1 + | +LL | #[link_ordinal(123)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: attribute should be applied to a foreign function or static + --> $DIR/link-ordinal-not-foreign-fn.rs:9:1 + | +LL | #[link_ordinal(42)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs new file mode 100644 index 000000000..9d741630f --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.rs @@ -0,0 +1,11 @@ +#[link(name = "foo")] +extern "C" { + #[link_ordinal(72436)] + //~^ ERROR ordinal value in `link_ordinal` is too large: `72436` + fn foo(); + #[link_ordinal(72436)] + //~^ ERROR ordinal value in `link_ordinal` is too large: `72436` + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr new file mode 100644 index 000000000..811145e77 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-large.stderr @@ -0,0 +1,18 @@ +error: ordinal value in `link_ordinal` is too large: `72436` + --> $DIR/link-ordinal-too-large.rs:3:5 + | +LL | #[link_ordinal(72436)] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the value may not exceed `u16::MAX` + +error: ordinal value in `link_ordinal` is too large: `72436` + --> $DIR/link-ordinal-too-large.rs:6:5 + | +LL | #[link_ordinal(72436)] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the value may not exceed `u16::MAX` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs new file mode 100644 index 000000000..9988115fd --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.rs @@ -0,0 +1,11 @@ +#[link(name = "foo")] +extern "C" { + #[link_ordinal(3, 4)] + //~^ ERROR incorrect number of arguments to `#[link_ordinal]` + fn foo(); + #[link_ordinal(3, 4)] + //~^ ERROR incorrect number of arguments to `#[link_ordinal]` + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr new file mode 100644 index 000000000..d5ce8aff3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-too-many-arguments.stderr @@ -0,0 +1,18 @@ +error: incorrect number of arguments to `#[link_ordinal]` + --> $DIR/link-ordinal-too-many-arguments.rs:3:5 + | +LL | #[link_ordinal(3, 4)] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: the attribute requires exactly one argument + +error: incorrect number of arguments to `#[link_ordinal]` + --> $DIR/link-ordinal-too-many-arguments.rs:6:5 + | +LL | #[link_ordinal(3, 4)] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: the attribute requires exactly one argument + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs new file mode 100644 index 000000000..14e915d60 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.rs @@ -0,0 +1,15 @@ +#[link(name = "foo")] +extern "C" { + #[link_ordinal(3)] + //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib` + fn foo(); +} + +#[link(name = "bar", kind = "static")] +extern "C" { + #[link_ordinal(3)] + //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib` + fn bar(); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr new file mode 100644 index 000000000..200b8f628 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-unsupported-link-kind.stderr @@ -0,0 +1,14 @@ +error: `#[link_ordinal]` is only supported if link kind is `raw-dylib` + --> $DIR/link-ordinal-unsupported-link-kind.rs:3:5 + | +LL | #[link_ordinal(3)] + | ^^^^^^^^^^^^^^^^^^ + +error: `#[link_ordinal]` is only supported if link kind is `raw-dylib` + --> $DIR/link-ordinal-unsupported-link-kind.rs:10:5 + | +LL | #[link_ordinal(3)] + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs new file mode 100644 index 000000000..b4173f3b6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.rs @@ -0,0 +1,18 @@ +// only-x86 +// only-windows +// compile-flags: --crate-type lib --emit link +#![allow(clashing_extern_declarations)] +#[link(name = "foo", kind = "raw-dylib")] +extern "C" { + fn f(x: i32); +} + +pub fn lib_main() { + #[link(name = "foo", kind = "raw-dylib")] + extern "stdcall" { + fn f(x: i32); + //~^ ERROR multiple declarations of external function `f` from library `foo.dll` have different calling conventions + } + + unsafe { f(42); } +} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr new file mode 100644 index 000000000..510108405 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/multiple-declarations.stderr @@ -0,0 +1,8 @@ +error: multiple declarations of external function `f` from library `foo.dll` have different calling conventions + --> $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/raw-dylib-windows-only.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs new file mode 100644 index 000000000..d4c6658a3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.rs @@ -0,0 +1,5 @@ +// ignore-windows +// compile-flags: --crate-type lib +#[link(name = "foo", kind = "raw-dylib")] +//~^ ERROR: link kind `raw-dylib` is only supported on Windows targets +extern "C" {} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr new file mode 100644 index 000000000..b635a09af --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr @@ -0,0 +1,9 @@ +error[E0455]: link kind `raw-dylib` is only supported on Windows targets + --> $DIR/raw-dylib-windows-only.rs:3:29 + | +LL | #[link(name = "foo", kind = "raw-dylib")] + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0455`. diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs new file mode 100644 index 000000000..2f5a23e47 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.rs @@ -0,0 +1,12 @@ +// only-x86_64 +// only-windows +// compile-flags: --crate-type lib --emit link +#[link(name = "foo", kind = "raw-dylib")] +extern "stdcall" { + fn f(x: i32); + //~^ ERROR ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture +} + +pub fn lib_main() { + unsafe { f(42); } +} diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr new file mode 100644 index 000000000..f8265ae69 --- /dev/null +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/unsupported-abi.stderr @@ -0,0 +1,8 @@ +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 new file mode 100644 index 000000000..780a510c5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type-const-bound-usage.rs @@ -0,0 +1,14 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + type Assoc: ~const Foo; + fn foo() {} +} + +const fn foo() { + ::Assoc::foo(); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs new file mode 100644 index 000000000..96790a873 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.rs @@ -0,0 +1,33 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +struct NonConstAdd(i32); + +impl std::ops::Add for NonConstAdd { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + NonConstAdd(self.0 + rhs.0) + } +} + +#[const_trait] +trait Foo { + type Bar: ~const std::ops::Add; +} + +impl const Foo for NonConstAdd { + type Bar = NonConstAdd; +} + +#[const_trait] +trait Baz { + type Qux: std::ops::Add; +} + +impl const Baz for NonConstAdd { + type Qux = NonConstAdd; // OK +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr new file mode 100644 index 000000000..0cffae1da --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr @@ -0,0 +1,8 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/assoc-type.rs:17:22 + | +LL | type Bar: ~const std::ops::Add; + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.rs new file mode 100644 index 000000000..01ac74fef --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.rs @@ -0,0 +1,10 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait A { + #[const_trait] //~ ERROR attribute should be applied + fn foo(self); +} + +#[const_trait] //~ ERROR attribute should be applied +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.stderr new file mode 100644 index 000000000..998958ced --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/attr-misuse.stderr @@ -0,0 +1,18 @@ +error: attribute should be applied to a trait + --> $DIR/attr-misuse.rs:9:1 + | +LL | #[const_trait] + | ^^^^^^^^^^^^^^ +LL | fn main() {} + | ------------ not a trait + +error: attribute should be applied to a trait + --> $DIR/attr-misuse.rs:5:5 + | +LL | #[const_trait] + | ^^^^^^^^^^^^^^ +LL | fn foo(self); + | ------------- not a trait + +error: aborting due to 2 previous errors + 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 new file mode 100644 index 000000000..e73082c11 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/cross-crate.rs @@ -0,0 +1,23 @@ +#![feature(const_trait_impl)] + +#[const_trait] +pub trait MyTrait { + fn defaulted_func(&self) {} + fn func(self); +} + +pub struct NonConst; + +impl MyTrait for NonConst { + fn func(self) { + + } +} + +pub struct Const; + +impl const MyTrait for Const { + fn func(self) { + + } +} 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 new file mode 100644 index 000000000..589e3f024 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/auxiliary/staged-api.rs @@ -0,0 +1,19 @@ +#![feature(const_trait_impl)] +#![feature(staged_api)] +#![stable(feature = "rust1", since = "1.0.0")] + +#[stable(feature = "rust1", since = "1.0.0")] +#[const_trait] +pub trait MyTrait { + #[stable(feature = "rust1", since = "1.0.0")] + fn func(); +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Unstable; + +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "unstable", issue = "none")] +impl const MyTrait for Unstable { + fn func() {} +} 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 new file mode 100644 index 000000000..dd9933974 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.rs @@ -0,0 +1,29 @@ +#![feature(const_trait_impl)] + +#[const_trait] +pub trait Plus { + fn plus(self, rhs: Self) -> Self; +} + +impl const Plus for i32 { + fn plus(self, rhs: Self) -> Self { + self + rhs + } +} + +impl Plus for u32 { + fn plus(self, rhs: Self) -> Self { + self + rhs + } +} + +pub const fn add_i32(a: i32, b: i32) -> i32 { + a.plus(b) // ok +} + +pub const fn add_u32(a: u32, b: u32) -> u32 { + a.plus(b) + //~^ ERROR the trait bound +} + +fn main() {} 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 new file mode 100644 index 000000000..7350909ba --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-fail.stderr @@ -0,0 +1,15 @@ +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` + | +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) + | ^^^^ + +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-const-trait-method-pass.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs new file mode 100644 index 000000000..ae0c2e6bc --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.rs @@ -0,0 +1,43 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +struct Int(i32); + +impl const std::ops::Add for Int { + type Output = Int; + + fn add(self, rhs: Self) -> Self { + Int(self.0.plus(rhs.0)) + } +} + +impl const PartialEq for Int { + fn eq(&self, rhs: &Self) -> bool { + self.0 == rhs.0 + } + fn ne(&self, other: &Self) -> bool { + !self.eq(other) + } +} + +#[const_trait] +pub trait Plus { + fn plus(self, rhs: Self) -> Self; +} + +impl const Plus for i32 { + fn plus(self, rhs: Self) -> Self { + self + rhs + } +} + +pub const fn add_i32(a: i32, b: i32) -> i32 { + a.plus(b) +} + +const ADD_INT: Int = Int(1i32) + Int(2i32); + +fn main() { + assert!(ADD_INT == Int(3i32)); +} 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 new file mode 100644 index 000000000..ff53eea11 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-const-trait-method-pass.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/call-const-trait-method-pass.rs:7:12 + | +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 + +error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` + --> $DIR/call-const-trait-method-pass.rs:15:12 + | +LL | impl const PartialEq 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 + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs new file mode 100644 index 000000000..5120e6bfb --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.rs @@ -0,0 +1,15 @@ +// known-bug: #110395 +#![feature(const_trait_impl)] + +#[const_trait] +trait MyPartialEq { + fn eq(&self, other: &Self) -> bool; +} + +impl const MyPartialEq for T { + fn eq(&self, other: &Self) -> bool { + PartialEq::eq(self, other) + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr new file mode 100644 index 000000000..02d53cc78 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-in-impl.stderr @@ -0,0 +1,8 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-in-impl.rs:9:16 + | +LL | impl const MyPartialEq for T { + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs new file mode 100644 index 000000000..3febb328a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.rs @@ -0,0 +1,28 @@ +//! Basic test for calling methods on generic type parameters in `const fn`. + +// known-bug: #110395 + +#![feature(const_trait_impl)] + +struct S; + +impl const PartialEq for S { + fn eq(&self, _: &S) -> bool { + true + } + fn ne(&self, other: &S) -> bool { + !self.eq(other) + } +} + +const fn equals_self(t: &T) -> bool { + *t == *t +} + +const fn equals_self_wrapper(t: &T) -> bool { + equals_self(t) +} + +pub const EQ: bool = equals_self_wrapper(&S); + +fn main() {} 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 new file mode 100644 index 000000000..529a472e0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-chain.stderr @@ -0,0 +1,23 @@ +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 + | +LL | const fn equals_self(t: &T) -> bool { + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-chain.rs:22:40 + | +LL | const fn equals_self_wrapper(t: &T) -> bool { + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs new file mode 100644 index 000000000..e618160d3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs @@ -0,0 +1,31 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +struct S; + +impl const PartialEq for S { + fn eq(&self, _: &S) -> bool { + true + } + fn ne(&self, other: &S) -> bool { + !self.eq(other) + } +} + +// This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const +// bound. +const fn equals_self(t: &T) -> bool { + *t == *t +} + +trait A: PartialEq {} +impl A for T {} + +const fn equals_self2(t: &T) -> bool { + *t == *t +} + +pub const EQ: bool = equals_self(&S) && equals_self2(&S); + +fn main() {} 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 new file mode 100644 index 000000000..bdc6ccc8a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-dup-bound.stderr @@ -0,0 +1,23 @@ +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 + | +LL | const fn equals_self(t: &T) -> bool { + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/call-generic-method-dup-bound.rs:25:37 + | +LL | const fn equals_self2(t: &T) -> bool { + | ^^^^^^^^^ + +error: aborting due to 3 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 new file mode 100644 index 000000000..fe1abbf42 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.rs @@ -0,0 +1,9 @@ +// known-bug: #110395 +#![feature(const_trait_impl)] + +pub const fn equals_self(t: &T) -> bool { + *t == *t + // (remove this) ~^ ERROR can't compare +} + +fn main() {} 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 new file mode 100644 index 000000000..3963f64ad --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-fail.stderr @@ -0,0 +1,28 @@ +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-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs new file mode 100644 index 000000000..e197c8b73 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs @@ -0,0 +1,17 @@ +// check-pass + +struct S; + +impl PartialEq for S { + fn eq(&self, _: &S) -> bool { + true + } +} + +const fn equals_self(t: &T) -> bool { + true +} + +pub const EQ: bool = equals_self(&S); + +fn main() {} 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 new file mode 100644 index 000000000..414a8c87d --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs @@ -0,0 +1,26 @@ +#![feature(const_trait_impl)] + +struct S; + +#[const_trait] +trait Foo { + fn eq(&self, _: &Self) -> bool; +} + +impl Foo for S { + fn eq(&self, _: &S) -> bool { + true + } +} + +const fn equals_self(t: &T) -> bool { + true +} + +// Calling `equals_self` with something that has a non-const impl should throw an error, despite +// it not using the impl. + +pub const EQ: bool = equals_self(&S); +//~^ 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 new file mode 100644 index 000000000..a28d6ce05 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr @@ -0,0 +1,15 @@ +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.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs new file mode 100644 index 000000000..09f35a277 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.rs @@ -0,0 +1,24 @@ +//! Basic test for calling methods on generic type parameters in `const fn`. + +// known-bug: #110395 + +#![feature(const_trait_impl)] + +struct S; + +impl const PartialEq for S { + fn eq(&self, _: &S) -> bool { + true + } + fn ne(&self, other: &S) -> bool { + !self.eq(other) + } +} + +const fn equals_self(t: &T) -> bool { + *t == *t +} + +pub const EQ: bool = equals_self(&S); + +fn main() {} 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 new file mode 100644 index 000000000..7fbe89dba --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call-generic-method-pass.stderr @@ -0,0 +1,17 @@ +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 + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs new file mode 100644 index 000000000..5f48c2353 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/call.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(const_closures, const_trait_impl)] +#![allow(incomplete_features)] + +pub const _: () = { + assert!((const || true)()); +}; + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.rs new file mode 100644 index 000000000..9ba19e800 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.rs @@ -0,0 +1,31 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +pub struct Int(i32); + +impl const std::ops::Add for i32 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + +impl std::ops::Add for Int { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + Int(self.0 + rhs.0) + } +} + +impl const std::ops::Add for Int { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + Int(self.0 + rhs.0) + } +} + +fn main() {} 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 new file mode 100644 index 000000000..4f858d61e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-and-non-const-impl.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/const-and-non-const-impl.rs:7:12 + | +LL | impl const std::ops::Add for i32 { + | ^^^^^^^^^^^^^ + | + = 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 `Add` which is not marked with `#[const_trait]` + --> $DIR/const-and-non-const-impl.rs:23:12 + | +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 + +error: aborting due to 2 previous errors + 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 new file mode 100644 index 000000000..52984fb6b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.rs @@ -0,0 +1,16 @@ +#![feature(const_trait_impl)] + +struct S; +#[const_trait] +trait T { + fn foo(); +} + +fn non_const() {} + +impl const T for S { + fn foo() { non_const() } + //~^ ERROR cannot call non-const fn +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr new file mode 100644 index 000000000..c8783de4c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-check-fns-in-const-impl.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `non_const` in constant functions + --> $DIR/const-check-fns-in-const-impl.rs:12:16 + | +LL | fn foo() { non_const() } + | ^^^^^^^^^^^ + | + = 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/const-closure-parse-not-item.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs new file mode 100644 index 000000000..2c99d8bf1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-parse-not-item.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(const_trait_impl, const_closures)] +#![allow(incomplete_features)] + +const fn test() -> impl ~const Fn() { + const move || {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs new file mode 100644 index 000000000..b4cc7a9e1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.rs @@ -0,0 +1,20 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn a(self) -> i32; +} + +impl Tr for () { + fn a(self) -> i32 { 42 } +} + +const fn need_const_closure i32>(x: T) -> i32 { + x(()) +} + +const _: () = assert!(need_const_closure(Tr::a) == 42); + +fn main() {} 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 new file mode 100644 index 000000000..112416a35 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -0,0 +1,16 @@ +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 + | +LL | const _: () = assert!(need_const_closure(Tr::a) == 42); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` + | +note: the trait `Tr` is implemented for `()`, but that implementation is not `const` + --> $DIR/const-closure-trait-method-fail.rs:18:23 + | +LL | const _: () = assert!(need_const_closure(Tr::a) == 42); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required because it appears within the type `fn(()) -> i32 {<() as Tr>::a}` + +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/const-closure-trait-method.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs new file mode 100644 index 000000000..3e6d19088 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closure-trait-method.rs @@ -0,0 +1,19 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn a(self) -> i32; +} + +impl const Tr for () { + fn a(self) -> i32 { 42 } +} + +const fn need_const_closure i32>(x: T) -> i32 { + x(()) +} + +const _: () = assert!(need_const_closure(Tr::a) == 42); + +fn main() {} 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 new file mode 100644 index 000000000..7c55b51c8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-closures.rs @@ -0,0 +1,30 @@ +// check-pass + +#![feature(const_trait_impl)] + +const fn answer_p1(f: &F) -> u8 + where + F: ~const FnOnce() -> u8, + F: ~const FnMut() -> u8, + F: ~const Fn() -> u8, +{ + f() * 7 +} + +const fn three() -> u8 { + 3 +} + +const fn answer_p2() -> u8 { + answer_p1(&three) +} + +const fn answer u8>(f: &F) -> u8 { + f() + f() +} + +const ANSWER: u8 = answer(&answer_p2); + +fn main() { + assert_eq!(ANSWER, 42) +} 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 new file mode 100644 index 000000000..140a06a73 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.rs @@ -0,0 +1,29 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait ConstDefaultFn: Sized { + fn b(self); + + fn a(self) { + self.b(); + } +} + +struct NonConstImpl; +struct ConstImpl; + +impl ConstDefaultFn for NonConstImpl { + fn b(self) {} +} + +impl const ConstDefaultFn for ConstImpl { + fn b(self) {} +} + +const fn test() { + NonConstImpl.a(); + //~^ ERROR the trait bound + ConstImpl.a(); +} + +fn main() {} 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 new file mode 100644 index 000000000..f9d0d1f78 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-default-method-bodies.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied + --> $DIR/const-default-method-bodies.rs:24:18 + | +LL | NonConstImpl.a(); + | ^ the trait `~const 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(); + | ^^^^^^^^^^^^ + +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/const-drop-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs new file mode 100644 index 000000000..948f0efbc --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-bound.rs @@ -0,0 +1,25 @@ +// check-pass + +#![feature(const_trait_impl)] +#![feature(const_precise_live_drops)] + +use std::marker::Destruct; + +const fn foo(res: Result) -> Option where E: ~const Destruct { + match res { + Ok(t) => Some(t), + Err(_e) => None, + } +} + +pub struct Foo(T); + +const fn baz(res: Result, Foo>) -> Option> +where + T: ~const Destruct, + E: ~const Destruct, +{ + foo(res) +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr new file mode 100644 index 000000000..13350a6d1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr @@ -0,0 +1,26 @@ +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:23:25 + | +LL | impl const Drop for ConstDropImplWithBounds { + | ^^^^ + | + = 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/const-drop-fail-2.rs:29:26 + | +LL | const fn check(_: T) {} + | ^^^^^^^^ + +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:39:25 + | +LL | impl const Drop for ConstDropImplWithNonConstBounds { + | ^^^^ + | + = 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 3 previous errors + 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 new file mode 100644 index 000000000..3de9d37d4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.rs @@ -0,0 +1,43 @@ +// known-bug: #110395 +#![feature(const_trait_impl)] +#![feature(const_mut_refs)] +#![cfg_attr(precise, feature(const_precise_live_drops))] + +use std::marker::{Destruct, PhantomData}; + +struct NonTrivialDrop; + +impl Drop for NonTrivialDrop { + fn drop(&mut self) { + println!("Non trivial drop"); + } +} + +#[const_trait] +trait A { fn a() { } } + +impl A for NonTrivialDrop {} + +struct ConstDropImplWithBounds(PhantomData); + +impl const Drop for ConstDropImplWithBounds { + fn drop(&mut self) { + T::a(); + } +} + +const fn check(_: T) {} + +const _: () = check::>( + ConstDropImplWithBounds(PhantomData) +); + +struct ConstDropImplWithNonConstBounds(PhantomData); + +impl const Drop for ConstDropImplWithNonConstBounds { + fn drop(&mut self) { + T::a(); + } +} + +fn main() {} 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 new file mode 100644 index 000000000..375f5d2c5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stderr @@ -0,0 +1,50 @@ +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:31:23 + | +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); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr new file mode 100644 index 000000000..13350a6d1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr @@ -0,0 +1,26 @@ +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:23:25 + | +LL | impl const Drop for ConstDropImplWithBounds { + | ^^^^ + | + = 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/const-drop-fail-2.rs:29:26 + | +LL | const fn check(_: T) {} + | ^^^^^^^^ + +error: const `impl` for trait `Drop` which is not marked with `#[const_trait]` + --> $DIR/const-drop-fail-2.rs:39:25 + | +LL | impl const Drop for ConstDropImplWithNonConstBounds { + | ^^^^ + | + = 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 3 previous errors + 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 new file mode 100644 index 000000000..e745cbd24 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -0,0 +1,58 @@ +error[E0277]: can't drop `NonTrivialDrop` in const contexts + --> $DIR/const-drop-fail.rs:28:23 + | +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) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs new file mode 100644 index 000000000..1c37648ff --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs @@ -0,0 +1,37 @@ +// known-bug: #110395 + +// revisions: stock precise +#![feature(const_trait_impl)] +#![feature(const_mut_refs)] +#![cfg_attr(precise, feature(const_precise_live_drops))] + +use std::marker::{Destruct, PhantomData}; + +struct NonTrivialDrop; + +impl Drop for NonTrivialDrop { + fn drop(&mut self) { + println!("Non trivial drop"); + } +} + +struct ConstImplWithDropGlue(NonTrivialDrop); + +impl const Drop for ConstImplWithDropGlue { + fn drop(&mut self) {} +} + +const fn check(_: T) {} + +macro_rules! check_all { + ($($exp:expr),*$(,)?) => {$( + const _: () = check($exp); + )*}; +} + +check_all! { + NonTrivialDrop, + ConstImplWithDropGlue(NonTrivialDrop), +} + +fn main() {} 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 new file mode 100644 index 000000000..e745cbd24 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -0,0 +1,58 @@ +error[E0277]: can't drop `NonTrivialDrop` in const contexts + --> $DIR/const-drop-fail.rs:28:23 + | +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) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. 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 new file mode 100644 index 000000000..b0fc3adf9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs @@ -0,0 +1,113 @@ +// run-pass +// revisions: stock precise +#![feature(const_trait_impl)] +#![feature(const_mut_refs)] +#![feature(never_type)] +#![cfg_attr(precise, feature(const_precise_live_drops))] + +use std::marker::Destruct; + +struct S<'a>(&'a mut u8); + +impl<'a> const Drop for S<'a> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +const fn a(_: T) {} + +const fn b() -> u8 { + let mut c = 0; + let _ = S(&mut c); + a(S(&mut c)); + c +} + +const C: u8 = b(); + +macro_rules! implements_const_drop { + ($($exp:expr),*$(,)?) => { + $( + const _: () = a($exp); + )* + } +} + +#[allow(dead_code)] +mod t { + pub struct Foo; + pub enum Bar { A } + pub fn foo() {} + pub struct ConstDrop; + + impl const Drop for ConstDrop { + fn drop(&mut self) {} + } + + pub struct HasConstDrop(pub ConstDrop); + pub struct TrivialFields(pub u8, pub i8, pub usize, pub isize); + + #[const_trait] + pub trait SomeTrait { + fn foo(); + } + impl const SomeTrait for () { + fn foo() {} + } + // non-const impl + impl SomeTrait for i32 { + fn foo() {} + } + + pub struct ConstDropWithBound(pub core::marker::PhantomData); + + impl const Drop for ConstDropWithBound { + fn drop(&mut self) { + T::foo(); + } + } + + pub struct ConstDropWithNonconstBound(pub core::marker::PhantomData); + + impl const Drop for ConstDropWithNonconstBound { + fn drop(&mut self) { + // Note: we DON'T use the `T: SomeTrait` bound + } + } +} + +use t::*; + +implements_const_drop! { + 1u8, + 2, + 3.0, + Foo, + Bar::A, + foo, + ConstDrop, + HasConstDrop(ConstDrop), + TrivialFields(1, 2, 3, 4), + &1, + &1 as *const i32, + ConstDropWithBound::<()>, + ConstDropWithNonconstBound::, + Result::::Ok(1), +} + +fn main() { + struct HasDropGlue(#[allow(unused_tuple_struct_fields)] Box); + struct HasDropImpl; + impl Drop for HasDropImpl { + fn drop(&mut self) { + println!("not trivial drop"); + } + } + + // These types should pass because ~const in a non-const context should have no effect. + a(HasDropGlue(Box::new(0))); + a(HasDropImpl); + + assert_eq!(C, 2); +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.rs new file mode 100644 index 000000000..bed4e9fd1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.rs @@ -0,0 +1,12 @@ +#![feature(const_trait_impl)] + +struct Foo; + +const impl Foo { //~ ERROR: expected identifier, found keyword + fn bar() {} +} + +fn main() { + // shouldn't error here because we shouldn't have been able to recover above + Foo::bar(); +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.stderr new file mode 100644 index 000000000..603f6b7d2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-norecover.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `impl` + --> $DIR/const-impl-norecover.rs:5:7 + | +LL | const impl Foo { + | ^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.rs new file mode 100644 index 000000000..837124db0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.rs @@ -0,0 +1,17 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo {} + +const impl Foo for i32 {} //~ ERROR: expected identifier, found keyword + +#[const_trait] +trait Bar {} + +const impl Bar for T {} //~ ERROR: expected identifier, found keyword + +const fn still_implements() {} + +const _: () = still_implements::(); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.stderr new file mode 100644 index 000000000..7217fc855 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-recovery.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `impl` + --> $DIR/const-impl-recovery.rs:6:7 + | +LL | const impl Foo for i32 {} + | ^^^^ expected identifier, found keyword + | +help: you might have meant to write a const trait impl + | +LL - const impl Foo for i32 {} +LL + impl const Foo for i32 {} + | + +error: expected identifier, found keyword `impl` + --> $DIR/const-impl-recovery.rs:11:7 + | +LL | const impl Bar for T {} + | ^^^^ expected identifier, found keyword + | +help: you might have meant to write a const trait impl + | +LL - const impl Bar for T {} +LL + impl const Bar for T {} + | + +error: aborting due to 2 previous errors + 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 new file mode 100644 index 000000000..2b4963991 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.rs @@ -0,0 +1,9 @@ +#![feature(const_trait_impl)] + +pub trait A {} +//~^ HELP: mark `A` as const + +impl const A for () {} +//~^ 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 new file mode 100644 index 000000000..478adcf3e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-requires-const-trait.stderr @@ -0,0 +1,14 @@ +error: const `impl` for trait `A` which is not marked with `#[const_trait]` + --> $DIR/const-impl-requires-const-trait.rs:6:12 + | +LL | pub trait A {} + | - help: mark `A` as const: `#[const_trait]` +... +LL | impl const A for () {} + | ^ + | + = 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 + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs new file mode 100644 index 000000000..f396deff4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.rs @@ -0,0 +1,55 @@ +// known-bug: #110395 +#![allow(incomplete_features)] +#![feature( + associated_type_bounds, + const_trait_impl, + const_cmp, + return_position_impl_trait_in_trait, +)] + +use std::marker::Destruct; + +const fn cmp(a: &impl ~const PartialEq) -> bool { + a == a +} + +const fn wrap(x: impl ~const PartialEq + ~const Destruct) + -> impl ~const PartialEq + ~const Destruct +{ + x +} + +#[const_trait] +trait Foo { + fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; +} + +impl const Foo for () { + fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + 123 + } +} + +const _: () = { + assert!(cmp(&0xDEADBEEFu32)); + assert!(cmp(&())); + assert!(wrap(123) == wrap(123)); + assert!(wrap(123) != wrap(456)); + let x = <() as Foo>::huh(); + assert!(x == x); +}; + +#[const_trait] +trait T {} +struct S; +impl const T for S {} + +const fn rpit() -> impl ~const T { S } + +const fn apit(_: impl ~const T + ~const Destruct) {} + +const fn rpit_assoc_bound() -> impl IntoIterator { Some(S) } + +const fn apit_assoc_bound(_: impl IntoIterator + ~const Destruct) {} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr new file mode 100644 index 000000000..f9078e227 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-impl-trait.stderr @@ -0,0 +1,39 @@ +error[E0635]: unknown feature `const_cmp` + --> $DIR/const-impl-trait.rs:6:5 + | +LL | const_cmp, + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:12:30 + | +LL | const fn cmp(a: &impl ~const PartialEq) -> bool { + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:16:30 + | +LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct) + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:17:20 + | +LL | -> impl ~const PartialEq + ~const Destruct + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:24:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/const-impl-trait.rs:28:29 + | +LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + | ^^^^^^^^^ + +error: aborting due to 6 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-gate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs new file mode 100644 index 000000000..dba3ad7f8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.rs @@ -0,0 +1,5 @@ +#[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 new file mode 100644 index 000000000..6a81f96d8 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-gate.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'derive_const' + --> $DIR/derive-const-gate.rs:1:3 + | +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 + +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 new file mode 100644 index 000000000..b575ea8da --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs @@ -0,0 +1,13 @@ +// known-bug: #110395 +#![feature(derive_const)] + +pub struct A; + +impl Default for A { + fn default() -> A { A } +} + +#[derive_const(Default)] +pub struct S(A); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr new file mode 100644 index 000000000..1c69ad431 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr @@ -0,0 +1,12 @@ +error: const `impl` for trait `Default` which is not marked with `#[const_trait]` + --> $DIR/derive-const-non-const-type.rs:10: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 previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs new file mode 100644 index 000000000..69098542b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.rs @@ -0,0 +1,19 @@ +// known-bug: #110395 +#![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] + +pub struct A; + +impl const Default for A { + fn default() -> A { A } +} + +impl const PartialEq for A { + fn eq(&self, _: &A) -> bool { true } +} + +#[derive_const(Default, PartialEq)] +pub struct S((), A); + +const _: () = assert!(S((), A) == S::default()); + +fn main() {} 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 new file mode 100644 index 000000000..88054096e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-use.stderr @@ -0,0 +1,53 @@ +error[E0635]: unknown feature `const_cmp` + --> $DIR/derive-const-use.rs:2:30 + | +LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] + | ^^^^^^^^^ + +error[E0635]: unknown feature `const_default_impls` + --> $DIR/derive-const-use.rs:2:41 + | +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 + +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.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs new file mode 100644 index 000000000..2a5d0176b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.rs @@ -0,0 +1,13 @@ +// known-bug: #110395 + +#![feature(derive_const)] +#![feature(const_trait_impl)] + +#[derive_const(PartialEq)] +pub struct Reverse(T); + +const fn foo(a: Reverse, b: Reverse) -> bool { + a == b +} + +fn main() {} 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 new file mode 100644 index 000000000..fa7832658 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const_derives/derive-const-with-params.stderr @@ -0,0 +1,20 @@ +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 + | +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 + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs new file mode 100644 index 000000000..bde8bf20f --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate-default-method-body-is-const.rs @@ -0,0 +1,18 @@ +// This tests that `const_trait` default methods can +// be called from a const context when used across crates. +// +// check-pass + +#![feature(const_trait_impl)] + +// aux-build: cross-crate.rs +extern crate cross_crate; + +use cross_crate::*; + +const _: () = { + Const.func(); + Const.defaulted_func(); +}; + +fn main() {} 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 new file mode 100644 index 000000000..633b7cc25 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.gatednc.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrait` is not satisfied + --> $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 + | +LL | NonConst.func(); + | ^^^^^^^^ + +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/cross-crate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs new file mode 100644 index 000000000..6df47022c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.rs @@ -0,0 +1,24 @@ +// revisions: stock gated stocknc gatednc +// [gated] check-pass +#![cfg_attr(any(gated, gatednc), feature(const_trait_impl))] + +// aux-build: cross-crate.rs +extern crate cross_crate; + +use cross_crate::*; + +fn non_const_context() { + NonConst.func(); + Const.func(); +} + +const fn const_context() { + #[cfg(any(stocknc, gatednc))] + NonConst.func(); + //[stocknc]~^ ERROR: the trait bound + //[gatednc]~^^ ERROR: the trait bound + Const.func(); + //[stock]~^ ERROR: cannot call +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stock.stderr new file mode 100644 index 000000000..22f13a741 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stock.stderr @@ -0,0 +1,12 @@ +error[E0015]: cannot call non-const fn `::func` in constant functions + --> $DIR/cross-crate.rs:20:11 + | +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 + +For more information about this error, try `rustc --explain E0015`. 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 new file mode 100644 index 000000000..9e97d3f11 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/cross-crate.stocknc.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `cross_crate::NonConst: cross_crate::MyTrait` is not satisfied + --> $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 + | +LL | NonConst.func(); + | ^^^^^^^^ + +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-body-checking.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs new file mode 100644 index 000000000..96acdc300 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.rs @@ -0,0 +1,17 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr {} +impl Tr for () {} + +const fn foo() where T: ~const Tr {} + +#[const_trait] +pub trait Foo { + fn foo() { + foo::<()>(); + //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + } +} + +fn main() {} 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 new file mode 100644 index 000000000..26644f72c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr @@ -0,0 +1,15 @@ +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 new file mode 100644 index 000000000..f70ecbc37 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.rs @@ -0,0 +1,15 @@ +#![feature(const_trait_impl)] + +#[const_trait] +pub trait Tr { + fn a(&self) {} + + fn b(&self) { + ().a() + //~^ ERROR the trait bound + } +} + +impl Tr for () {} + +fn main() {} 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 new file mode 100644 index 000000000..21ecddaff --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-same-trait-ck.stderr @@ -0,0 +1,15 @@ +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 `()` + | +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() + | ^^ + +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-with-staged-api.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs new file mode 100644 index 000000000..1b45cd9aa --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/default-method-body-is-const-with-staged-api.rs @@ -0,0 +1,17 @@ +// check-pass + +// This was an ICE, because the compiler ensures the +// function to be const when performing const checking, +// but functions marked with the attribute are not const +// *and* subject to const checking. + +#![feature(staged_api)] +#![feature(const_trait_impl)] +#![stable(since = "1", feature = "foo")] + +#[const_trait] +trait Tr { + fn a() {} +} + +fn main() {} 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 new file mode 100644 index 000000000..730e268c0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check-override.rs @@ -0,0 +1,19 @@ +// check-pass +#![feature(const_trait_impl, rustc_attrs)] + +#[const_trait] +trait Foo { + #[rustc_do_not_const_check] + fn into_iter(&self) { println!("FEAR ME!") } +} + + +impl const Foo for () { + fn into_iter(&self) { + // ^_^ + } +} + +const _: () = Foo::into_iter(&()); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check.rs new file mode 100644 index 000000000..3c39c53de --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/do-not-const-check.rs @@ -0,0 +1,18 @@ +// check-pass +#![feature(const_trait_impl, rustc_attrs)] + +#[const_trait] +trait IntoIter { + fn into_iter(self); +} + +#[const_trait] +trait Hmm: Sized { + #[rustc_do_not_const_check] + fn chain(self, other: U) where U: IntoIter, + { + other.into_iter() + } +} + +fn main() {} 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 new file mode 100644 index 000000000..49457354c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/effects/helloworld.rs @@ -0,0 +1,29 @@ +// check-pass + +// gate-test-effects +// ^ effects doesn't have a gate so we will trick tidy into thinking this is a gate test + +#![feature(const_trait_impl, effects, rustc_attrs)] + +// ensure we are passing in the correct host effect in always const contexts. + +pub const fn hmm() -> usize { + if host { + 1 + } else { + 0 + } +} + +const _: () = { + 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/feature-gate.gated.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr new file mode 100644 index 000000000..4c630d33c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.gated.stderr @@ -0,0 +1,8 @@ +error: fatal error triggered by #[rustc_error] + --> $DIR/feature-gate.rs:14:1 + | +LL | fn main() {} + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs new file mode 100644 index 000000000..0b409fbaa --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.rs @@ -0,0 +1,14 @@ +// revisions: stock gated +// gate-test-const_trait_impl + +#![cfg_attr(gated, feature(const_trait_impl))] +#![feature(rustc_attrs)] + +struct S; +#[const_trait] //[stock]~ ERROR `const_trait` is a temporary placeholder +trait T {} +impl const T for S {} +//[stock]~^ ERROR const trait impls are experimental + +#[rustc_error] +fn main() {} //[gated]~ ERROR fatal error triggered by #[rustc_error] diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr new file mode 100644 index 000000000..0e938c1c5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/feature-gate.stock.stderr @@ -0,0 +1,21 @@ +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:10:6 + | +LL | impl const T for S {} + | ^^^^^ + | + = note: see issue #67792 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. + --> $DIR/feature-gate.rs:8:1 + | +LL | #[const_trait] + | ^^^^^^^^^^^^^^ + | + = note: see issue #67792 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs new file mode 100644 index 000000000..60790e297 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs @@ -0,0 +1,15 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +pub trait Test {} + +impl Test for () {} + +pub const fn test() {} + +pub const fn min_by_i32() -> fn() { + test::<()> +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/gate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/gate.rs new file mode 100644 index 000000000..d1c93ab9f --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/gate.rs @@ -0,0 +1,13 @@ +// gate-test-const_closures + +fn main() { + (const || {})(); + //~^ ERROR: const closures are experimental +} + +macro_rules! e { + ($e:expr) => {} +} + +e!((const || {})); +//~^ ERROR const closures are experimental diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/gate.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/gate.stderr new file mode 100644 index 000000000..11cc2cd56 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/gate.stderr @@ -0,0 +1,21 @@ +error[E0658]: const closures are experimental + --> $DIR/gate.rs:4:6 + | +LL | (const || {})(); + | ^^^^^ + | + = note: see issue #106003 for more information + = help: add `#![feature(const_closures)]` to the crate attributes to enable + +error[E0658]: const closures are experimental + --> $DIR/gate.rs:12:5 + | +LL | e!((const || {})); + | ^^^^^ + | + = note: see issue #106003 for more information + = help: add `#![feature(const_closures)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.rs new file mode 100644 index 000000000..d665c4479 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.rs @@ -0,0 +1,30 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +use std::marker::PhantomData; + +struct S(PhantomData); + +impl Copy for S {} +impl Clone for S { + fn clone(&self) -> Self { + S(PhantomData) + } +} + +impl const std::ops::Add for S { + type Output = Self; + + fn add(self, _: Self) -> Self { + S(std::marker::PhantomData) + } +} + +const fn twice(arg: S) -> S { + arg + arg +} + +fn main() { + let _ = twice(S(PhantomData::)); +} 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 new file mode 100644 index 000000000..1b21d7c0e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/generic-bound.stderr @@ -0,0 +1,11 @@ +error: const `impl` for trait `Add` which is not marked with `#[const_trait]` + --> $DIR/generic-bound.rs:16:15 + | +LL | impl const std::ops::Add 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: aborting due to previous error + 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 new file mode 100644 index 000000000..337c73340 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.rs @@ -0,0 +1,17 @@ +// Regression test for #69615. + +#![feature(const_trait_impl)] + +#[const_trait] +pub trait MyTrait { + fn method(&self) -> Option<()>; +} + +impl const MyTrait for () { + fn method(&self) -> Option<()> { + Some(())?; //~ ERROR `?` is not allowed in a `const fn` + None + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.stderr new file mode 100644 index 000000000..6d2be1daa --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/hir-const-check.stderr @@ -0,0 +1,12 @@ +error[E0658]: `?` is not allowed in a `const fn` + --> $DIR/hir-const-check.rs:12:9 + | +LL | Some(())?; + | ^^^^^^^^^ + | + = note: see issue #74935 for more information + = help: add `#![feature(const_try)]` 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/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs new file mode 100644 index 000000000..05b26465c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs @@ -0,0 +1,9 @@ +#![feature(const_trait_impl)] + +struct S; +trait T {} + +impl ~const T for S {} +//~^ ERROR expected a trait, found type + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr new file mode 100644 index 000000000..0a91719e1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr @@ -0,0 +1,8 @@ +error: expected a trait, found type + --> $DIR/impl-tilde-const-trait.rs:6:6 + | +LL | impl ~const T for S {} + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs new file mode 100644 index 000000000..6df9696f2 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.rs @@ -0,0 +1,17 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn req(&self); + + fn default() {} +} + +struct S; + +impl const Tr for u16 { + fn default() {} +} //~^^ ERROR not all trait items implemented + + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr new file mode 100644 index 000000000..6c6ca9f5d --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-fail.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `req` + --> $DIR/impl-with-default-fn-fail.rs:12:1 + | +LL | fn req(&self); + | -------------- `req` from trait +... +LL | impl const Tr for u16 { + | ^^^^^^^^^^^^^^^^^^^^^ missing `req` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs new file mode 100644 index 000000000..ae81421e9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/impl-with-default-fn-pass.rs @@ -0,0 +1,26 @@ +// check-pass + +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn req(&self); + + fn default() {} +} + +impl const Tr for u8 { + fn req(&self) {} +} + +macro_rules! impl_tr { + ($ty: ty) => { + impl const Tr for $ty { + fn req(&self) {} + } + } +} + +impl_tr!(u64); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs new file mode 100644 index 000000000..f8ac793e4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs @@ -0,0 +1,22 @@ +// check-pass +#![feature(const_trait_impl)] + +struct S; + +#[const_trait] +trait A {} +#[const_trait] +trait B {} + +impl const A for S {} +impl const B for S {} + +impl S { + const fn a() where T: ~const B { + + } +} + +const _: () = S::a::(); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.rs new file mode 100644 index 000000000..afd0d137b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.rs @@ -0,0 +1,13 @@ +#![feature(const_trait_impl)] +#![allow(bare_trait_objects)] + +struct S; +trait T {} + +impl const S {} +//~^ ERROR inherent impls cannot be `const` + +impl const T {} +//~^ ERROR inherent impls cannot be `const` + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.stderr new file mode 100644 index 000000000..8c5562703 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/inherent-impl.stderr @@ -0,0 +1,22 @@ +error: inherent impls cannot be `const` + --> $DIR/inherent-impl.rs:7:12 + | +LL | impl const S {} + | ----- ^ inherent impl for this type + | | + | `const` because of this + | + = note: only trait implementations may be annotated with `const` + +error: inherent impls cannot be `const` + --> $DIR/inherent-impl.rs:10:12 + | +LL | impl const T {} + | ----- ^ inherent impl for this type + | | + | `const` because of this + | + = note: only trait implementations may be annotated with `const` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs new file mode 100644 index 000000000..9f3f38ad4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-100222.rs @@ -0,0 +1,39 @@ +// revisions: nn ny yn yy +// check-pass +#![feature(const_trait_impl, associated_type_defaults, const_mut_refs)] + +#[cfg_attr(any(yn, yy), const_trait)] +pub trait Index { + type Output; +} + +#[cfg_attr(any(ny, yy), const_trait)] +pub trait IndexMut where Self: Index { + const C: ::Output; + type Assoc = ::Output; + fn foo(&mut self, x: ::Output) -> ::Output; +} + +impl Index for () { type Output = (); } + +#[cfg(not(any(nn, yn)))] +impl const IndexMut for <() as Index>::Output { + const C: ::Output = (); + type Assoc = ::Output; + fn foo(&mut self, x: ::Output) -> ::Output + where ::Output:, + {} +} + +#[cfg(any(nn, yn))] +impl IndexMut for <() as Index>::Output { + const C: ::Output = (); + type Assoc = ::Output; + fn foo(&mut self, x: ::Output) -> ::Output + where ::Output:, + {} +} + +const C: <() as Index>::Output = (); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.rs new file mode 100644 index 000000000..fe4e91081 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.rs @@ -0,0 +1,15 @@ +#![feature(allocator_api)] +#![feature(const_trait_impl)] + +use core::convert::{From, TryFrom}; +//~^ ERROR +//~| ERROR + +use std::pin::Pin; +use std::alloc::Allocator; +impl const From> for Pin> +where + A: 'static, +{} + +pub fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr new file mode 100644 index 000000000..8bf00eaff --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102156.stderr @@ -0,0 +1,19 @@ +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/issue-102156.rs:4:5 + | +LL | use core::convert::{From, TryFrom}; + | ^^^^ maybe a missing crate `core`? + | + = help: consider adding `extern crate core` to use the `core` crate + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/issue-102156.rs:4:5 + | +LL | use core::convert::{From, TryFrom}; + | ^^^^ maybe a missing crate `core`? + | + = help: consider adding `extern crate core` to use the `core` crate + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. 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 new file mode 100644 index 000000000..07d3f51ed --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.rs @@ -0,0 +1,12 @@ +#![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 + }], +} + +fn main() {} 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 new file mode 100644 index 000000000..b98ccbe5d --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-102985.stderr @@ -0,0 +1,41 @@ +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 + | +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 + +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/issue-103677.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-103677.rs new file mode 100644 index 000000000..d81724a36 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-103677.rs @@ -0,0 +1,5 @@ +// check-pass + +const _: fn(&String) = |s| { &*s as &str; }; + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs new file mode 100644 index 000000000..b604c65d7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.rs @@ -0,0 +1,20 @@ +#![feature(const_fmt_arguments_new)] +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + fn req(&self); + + fn prov(&self) { + println!("lul"); //~ ERROR: cannot call non-const fn `_print` in constant functions + self.req(); + } +} + +struct S; + +impl const Tr for S { + fn req(&self) {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr new file mode 100644 index 000000000..082c0333f --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-79450.stderr @@ -0,0 +1,12 @@ +error[E0015]: cannot call non-const fn `_print` in constant functions + --> $DIR/issue-79450.rs:9:9 + | +LL | println!("lul"); + | ^^^^^^^^^^^^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `println` (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 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 new file mode 100644 index 000000000..b132c395a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.rs @@ -0,0 +1,13 @@ +#![feature(const_trait_impl)] + +pub trait A { + fn assoc() -> bool; +} + +pub const fn foo() -> bool { + T::assoc() + //~^ ERROR the trait bound + //~| 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 new file mode 100644 index 000000000..955923505 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-88155.stderr @@ -0,0 +1,24 @@ +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 + | +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 + +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/issue-90052.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.rs new file mode 100644 index 000000000..21ddf4ab4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.rs @@ -0,0 +1,9 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Bar {} + +fn foo() where T: ~const Bar {} +//~^ ERROR `~const` is not allowed + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.stderr new file mode 100644 index 000000000..b2a936537 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-90052.stderr @@ -0,0 +1,14 @@ +error: `~const` is not allowed here + --> $DIR/issue-90052.rs:6:22 + | +LL | fn foo() where T: ~const Bar {} + | ^^^^^^^^^^ + | +note: this function is not `const`, so it cannot have `~const` trait bounds + --> $DIR/issue-90052.rs:6:4 + | +LL | fn foo() where T: ~const Bar {} + | ^^^ + +error: aborting due to previous error + 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 new file mode 100644 index 000000000..96a3e386e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92111.rs @@ -0,0 +1,23 @@ +// Regression test for #92111. +// +// check-pass + +#![feature(const_trait_impl)] + +use std::marker::Destruct; + +pub trait Tr {} + +#[allow(drop_bounds)] +impl Tr for T {} + +#[derive(Debug)] +pub struct S(i32); + +impl Tr for S {} + +const fn a(t: T) {} + +fn main() { + a(S(0)); +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs new file mode 100644 index 000000000..4d3469653 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/issue-92230-wf-super-trait-env.rs @@ -0,0 +1,15 @@ +// Regression test for #92230. +// +// check-pass + +#![feature(const_trait_impl)] + +#[const_trait] +pub trait Super {} +#[const_trait] +pub trait Sub: Super {} + +impl const Super for &A where A: ~const Super {} +impl const Sub for &A where A: ~const Sub {} + +fn main() {} 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 new file mode 100644 index 000000000..bd0dd126c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.gated.stderr @@ -0,0 +1,26 @@ +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 + | +LL | "a" => (), + | ^^^ + | + = 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 + +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/match-non-const-eq.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs new file mode 100644 index 000000000..0d04101a3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.rs @@ -0,0 +1,12 @@ +// 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 + _ => (), + } +} + +fn main() {} 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 new file mode 100644 index 000000000..dcb9b49ea --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/match-non-const-eq.stock.stderr @@ -0,0 +1,13 @@ +error[E0015]: cannot match on `str` in constant functions + --> $DIR/match-non-const-eq.rs:6:9 + | +LL | "a" => (), + | ^^^ + | + = 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 + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + +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/nested-closure.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/nested-closure.rs new file mode 100644 index 000000000..0b423b340 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/nested-closure.rs @@ -0,0 +1,12 @@ +// check-pass + +#![feature(const_trait_impl, lazy_cell)] + +use std::sync::LazyLock; + +static EXTERN_FLAGS: LazyLock = LazyLock::new(|| { + let x = || String::new(); + x() +}); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs new file mode 100644 index 000000000..cd8bb5963 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.rs @@ -0,0 +1,15 @@ +#![feature(const_closures, const_trait_impl)] +#![allow(incomplete_features)] + +trait Foo { + fn foo(&self); +} + +impl Foo for () { + fn foo(&self) {} +} + +fn main() { + (const || { (()).foo() })(); + //~^ ERROR: cannot call non-const fn +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr new file mode 100644 index 000000000..979d7febb --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-const-closure-non-const-outer.stderr @@ -0,0 +1,11 @@ +error[E0015]: cannot call non-const fn `<() as Foo>::foo` in constant functions + --> $DIR/non-const-op-const-closure-non-const-outer.rs:13:22 + | +LL | (const || { (()).foo() })(); + | ^^^^^ + | + = 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/non-const-op-in-closure-in-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs new file mode 100644 index 000000000..dff8a2444 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.rs @@ -0,0 +1,18 @@ +// known-bug: #110395 + +#![feature(const_trait_impl)] + +#[const_trait] +trait Convert { + fn to(self) -> T; +} + +impl const Convert for A where B: ~const From { + fn to(self) -> B { + B::from(self) + } +} + +const FOO: fn() -> String = || "foo".to(); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr new file mode 100644 index 000000000..cfdda4713 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/non-const-op-in-closure-in-const.stderr @@ -0,0 +1,8 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/non-const-op-in-closure-in-const.rs:10:51 + | +LL | impl const Convert for A where B: ~const From { + | ^^^^^^^ + +error: aborting due to previous error + 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 new file mode 100644 index 000000000..f31123f16 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.rs @@ -0,0 +1,58 @@ +// 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. + +#![feature(const_trait_impl)] +#![feature(rustc_attrs)] +#![feature(min_specialization)] + +#[rustc_specialization_trait] +trait Specialize {} + +#[const_trait] +trait Foo {} + +#[const_trait] +trait Bar { + fn bar(); +} + +// bgr360: I was only able to exercise the code path that raises the +// "missing ~const qualifier" error by making this base impl non-const, even +// though that doesn't really make sense to do. As seen below, if the base impl +// is made const, rustc fails earlier with an overlapping impl failure. +impl Bar for T +where + T: ~const Foo, +{ + default fn bar() {} +} + +impl Bar for T +where + T: Foo, //~ ERROR missing `~const` qualifier + T: Specialize, +{ + fn bar() {} +} + +#[const_trait] +trait Baz { + fn baz(); +} + +impl const Baz for T +where + T: ~const Foo, +{ + default fn baz() {} +} + +impl const Baz for T //~ ERROR conflicting implementations of trait `Baz` +where + T: Foo, + T: Specialize, +{ + fn baz() {} +} + +fn main() {} 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 new file mode 100644 index 000000000..057cf4aea --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -0,0 +1,18 @@ +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 new file mode 100644 index 000000000..9ddea427c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-const-specialized.rs @@ -0,0 +1,39 @@ +// Tests that a const default trait impl can be specialized by another const +// trait impl and that the specializing impl will be used during const-eval. + +// run-pass + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +const fn get_value() -> u32 { + T::value() +} + +impl const Value for T { + default fn value() -> u32 { + 0 + } +} + +struct FortyTwo; + +impl const Value for FortyTwo { + fn value() -> u32 { + 42 + } +} + +const ZERO: u32 = get_value::<()>(); + +const FORTY_TWO: u32 = get_value::(); + +fn main() { + assert_eq!(ZERO, 0); + assert_eq!(FORTY_TWO, 42); +} 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 new file mode 100644 index 000000000..a3bb9b3f9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.rs @@ -0,0 +1,26 @@ +// Tests that specializing trait impls must be at least as const as the default impl. + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +impl const Value for T { + default fn value() -> u32 { + 0 + } +} + +struct FortyTwo; + +impl Value for FortyTwo { //~ ERROR cannot specialize on const impl with non-const impl + fn value() -> u32 { + println!("You can't do that (constly)"); + 42 + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr new file mode 100644 index 000000000..247668047 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/const-default-impl-non-const-specialized-impl.stderr @@ -0,0 +1,8 @@ +error: cannot specialize on const impl with non-const impl + --> $DIR/const-default-impl-non-const-specialized-impl.rs:19:1 + | +LL | impl Value for FortyTwo { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/default-keyword.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/default-keyword.rs new file mode 100644 index 000000000..2aac0a2b4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/default-keyword.rs @@ -0,0 +1,15 @@ +// check-pass + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Foo { + fn foo(); +} + +impl const Foo for u32 { + default fn foo() {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs new file mode 100644 index 000000000..92d8be6bb --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95186-specialize-on-tilde-const.rs @@ -0,0 +1,49 @@ +// Tests that `~const` trait bounds can be used to specialize const trait impls. + +// check-pass + +#![feature(const_trait_impl)] +#![feature(rustc_attrs)] +#![feature(min_specialization)] + +#[const_trait] +#[rustc_specialization_trait] +trait Specialize {} + +#[const_trait] +trait Foo { + fn foo(); +} + +impl const Foo for T { + default fn foo() {} +} + +impl const Foo for T +where + T: ~const Specialize, +{ + fn foo() {} +} + +#[const_trait] +trait Bar { + fn bar() {} +} + +impl const Bar for T +where + T: ~const Foo, +{ + default fn bar() {} +} + +impl const Bar for T +where + T: ~const Foo, + T: ~const Specialize, +{ + fn bar() {} +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs new file mode 100644 index 000000000..51bfaf73b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/issue-95187-same-trait-bound-different-constness.rs @@ -0,0 +1,57 @@ +// Tests that `T: ~const Foo` in a specializing impl is treated as equivalent to +// `T: Foo` in the default impl for the purposes of specialization (i.e., it +// does not think that the user is attempting to specialize on trait `Foo`). + +// check-pass + +#![feature(rustc_attrs)] +#![feature(min_specialization)] +#![feature(const_trait_impl)] + +#[rustc_specialization_trait] +trait Specialize {} + +#[const_trait] +trait Foo {} + +#[const_trait] +trait Bar { + fn bar(); +} + +impl Bar for T +where + T: Foo, +{ + default fn bar() {} +} + +impl const Bar for T +where + T: ~const Foo, + T: Specialize, +{ + fn bar() {} +} + +#[const_trait] +trait Baz { + fn baz(); +} + +impl const Baz for T +where + T: Foo, +{ + default fn baz() {} +} + +impl const Baz for T +where + T: ~const Foo, + T: Specialize, +{ + fn baz() {} +} + +fn main() {} 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 new file mode 100644 index 000000000..35aa52fbd --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specialization/non-const-default-const-specialized.rs @@ -0,0 +1,39 @@ +// 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. + +// run-pass + +#![feature(const_trait_impl)] +#![feature(min_specialization)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +const fn get_value() -> u32 { + T::value() +} + +impl Value for T { + default fn value() -> u32 { + println!("You can't do that (constly)"); + 0 + } +} + +struct FortyTwo; + +impl const Value for FortyTwo { + fn value() -> u32 { + 42 + } +} + +fn main() { + let zero = get_value::<()>(); + assert_eq!(zero, 0); + + const FORTY_TWO: u32 = get_value::(); + assert_eq!(FORTY_TWO, 42); +} 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 new file mode 100644 index 000000000..633543700 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.rs @@ -0,0 +1,31 @@ +#![feature(const_trait_impl, min_specialization, rustc_attrs)] + +#[rustc_specialization_trait] +#[const_trait] +pub trait Sup {} + +impl const Sup for () {} + +#[const_trait] +pub trait A { + fn a() -> u32; +} + +impl A for T { + default fn a() -> u32 { + 2 + } +} + +impl const A for T { + fn a() -> u32 { + 3 + } +} + +const fn generic() { + ::a(); + //~^ 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 new file mode 100644 index 000000000..8923416f4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness-2.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `T: ~const Sup` is not satisfied + --> $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() { + | ++++++++++++ + +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/specializing-constness.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs new file mode 100644 index 000000000..5c2a3f801 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.rs @@ -0,0 +1,31 @@ +#![feature(const_trait_impl, min_specialization, rustc_attrs)] + +#[rustc_specialization_trait] +#[const_trait] +pub trait Sup {} + +impl const Sup for () {} + +#[const_trait] +pub trait A { + fn a() -> u32; +} + +#[const_trait] +pub trait Spec {} + +impl const A for T { + default fn a() -> u32 { + 2 + } +} + +impl A for T { +//~^ ERROR: cannot specialize +//~| ERROR: missing `~const` qualifier + fn a() -> u32 { + 3 + } +} + +fn main() {} 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 new file mode 100644 index 000000000..1ffdc50e5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/specializing-constness.stderr @@ -0,0 +1,14 @@ +error: cannot specialize on const impl with non-const impl + --> $DIR/specializing-constness.rs:23:1 + | +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 + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.rs new file mode 100644 index 000000000..fc0d82727 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.rs @@ -0,0 +1,16 @@ +// aux-build: staged-api.rs +extern crate staged_api; + +use staged_api::*; + +// Const stability has no impact on usage in non-const contexts. +fn non_const_context() { + Unstable::func(); +} + +const fn stable_const_context() { + Unstable::func(); + //~^ ERROR cannot call non-const fn `::func` in constant functions +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.stderr new file mode 100644 index 000000000..d7aa0d95c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api-user-crate.stderr @@ -0,0 +1,12 @@ +error[E0015]: cannot call non-const fn `::func` in constant functions + --> $DIR/staged-api-user-crate.rs:12:5 + | +LL | Unstable::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 + +For more information about this error, try `rustc --explain E0015`. 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 new file mode 100644 index 000000000..1d79f5adf --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.rs @@ -0,0 +1,63 @@ +// revisions: stable unstable + +#![cfg_attr(unstable, feature(unstable))] // The feature from the ./auxiliary/staged-api.rs file. +#![feature(const_trait_impl)] +#![feature(staged_api)] +#![stable(feature = "rust1", since = "1.0.0")] + +// aux-build: staged-api.rs +extern crate staged_api; + +use staged_api::*; + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Foo; + +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))] +#[cfg_attr(stable, rustc_const_stable(feature = "foo", since = "1.0.0"))] +impl const MyTrait for Foo { + //[stable]~^ ERROR trait implementations cannot be const stable yet + fn func() {} +} + +// Const stability has no impact on usage in non-const contexts. +fn non_const_context() { + Unstable::func(); + Foo::func(); +} + +#[unstable(feature = "none", issue = "none")] +const fn const_context() { + Unstable::func(); + // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is + // not const-stable. + Foo::func(); + //[unstable]~^ ERROR not yet stable as a const fn + // ^ fails, because the `foo` feature is not active +} + +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(unstable, rustc_const_unstable(feature = "foo", issue = "none"))] +pub const fn const_context_not_const_stable() { + //[stable]~^ ERROR function has missing const stability attribute + Unstable::func(); + // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is + // not const-stable. + Foo::func(); + //[unstable]~^ ERROR not yet stable as a const fn + // ^ fails, because the `foo` feature is not active +} + +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_stable(feature = "cheese", since = "1.0.0")] +const fn stable_const_context() { + Unstable::func(); + //[unstable]~^ ERROR not yet stable as a const fn + Foo::func(); + //[unstable]~^ ERROR not yet stable as a const fn + const_context_not_const_stable() + //[unstable]~^ ERROR not yet stable as a const fn +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.stable.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.stable.stderr new file mode 100644 index 000000000..a1aca762e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.stable.stderr @@ -0,0 +1,25 @@ +error: trait implementations cannot be const stable yet + --> $DIR/staged-api.rs:19:1 + | +LL | / impl const MyTrait for Foo { +LL | | +LL | | fn func() {} +LL | | } + | |_^ + | + = note: see issue #67792 for more information + +error: function has missing const stability attribute + --> $DIR/staged-api.rs:42:1 + | +LL | / pub const fn const_context_not_const_stable() { +LL | | +LL | | Unstable::func(); +LL | | // ^ This is okay regardless of whether the `unstable` feature is enabled, as this function is +... | +LL | | // ^ fails, because the `foo` feature is not active +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.unstable.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.unstable.stderr new file mode 100644 index 000000000..c38d1a81a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/staged-api.unstable.stderr @@ -0,0 +1,42 @@ +error: `::func` is not yet stable as a const fn + --> $DIR/staged-api.rs:35:5 + | +LL | Foo::func(); + | ^^^^^^^^^^^ + | + = help: add `#![feature(foo)]` to the crate attributes to enable + +error: `::func` is not yet stable as a const fn + --> $DIR/staged-api.rs:47:5 + | +LL | Foo::func(); + | ^^^^^^^^^^^ + | + = help: add `#![feature(foo)]` to the crate attributes to enable + +error: `::func` is not yet stable as a const fn + --> $DIR/staged-api.rs:55:5 + | +LL | Unstable::func(); + | ^^^^^^^^^^^^^^^^ + | + = help: const-stable functions can only call other const-stable functions + +error: `::func` is not yet stable as a const fn + --> $DIR/staged-api.rs:57:5 + | +LL | Foo::func(); + | ^^^^^^^^^^^ + | + = help: const-stable functions can only call other const-stable functions + +error: `const_context_not_const_stable` is not yet stable as a const fn + --> $DIR/staged-api.rs:59:5 + | +LL | const_context_not_const_stable() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: const-stable functions can only call other const-stable functions + +error: aborting due to 5 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/static-const-trait-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/static-const-trait-bound.rs new file mode 100644 index 000000000..4520a3696 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/static-const-trait-bound.rs @@ -0,0 +1,18 @@ +// check-pass +pub struct S T = fn() -> T> { + f: F, + x: Option, +} + +impl T> S { + pub const fn new(f: F) -> Self { + Self { f, x: None } + } +} + +#[derive(Default)] +pub struct Foo; + +static LOCKED_CALLSITES: S = S::new(Default::default); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr new file mode 100644 index 000000000..78aab9469 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.gated.stderr @@ -0,0 +1,9 @@ +error[E0635]: unknown feature `const_default_impls` + --> $DIR/std-impl-gate.rs:6:46 + | +LL | #![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.rs new file mode 100644 index 000000000..e9e5e0235 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.rs @@ -0,0 +1,21 @@ +// This tests feature gates for const impls in the standard library. + +// revisions: stock gated +//[gated] known-bug: #110395 + +#![cfg_attr(gated, feature(const_trait_impl, const_default_impls))] + +fn non_const_context() -> Vec { + Default::default() +} + +const fn const_context() -> Vec { + Default::default() + //[stock]~^ ERROR cannot call non-const fn +} + +fn main() { + const VAL: Vec = const_context(); + + assert_eq!(VAL, non_const_context()); +} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr new file mode 100644 index 000000000..6a3396401 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/std-impl-gate.stock.stderr @@ -0,0 +1,12 @@ +error[E0015]: cannot call non-const fn ` as Default>::default` in constant functions + --> $DIR/std-impl-gate.rs:13:5 + | +LL | Default::default() + | ^^^^^^^^^^^^^^^^^^ + | + = 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 + +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.nn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr new file mode 100644 index 000000000..97f346e8c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.nn.stderr @@ -0,0 +1,14 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr new file mode 100644 index 000000000..97f346e8c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.ny.stderr @@ -0,0 +1,14 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-2.rs:11:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: aborting due to 2 previous errors + 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 new file mode 100644 index 000000000..ecb06271c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.rs @@ -0,0 +1,20 @@ +#![feature(const_trait_impl)] + +// revisions: yy yn ny nn + +#[cfg_attr(any(yy, yn), const_trait)] +trait Foo { + fn a(&self); +} + +#[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]` + +const fn foo(x: &T) { + x.a(); + //[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 new file mode 100644 index 000000000..c9fa19554 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yn.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `T: ~const Foo` is not satisfied + --> $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) { + | ++++++++++++ + +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-fail-2.yy.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr new file mode 100644 index 000000000..c9fa19554 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-2.yy.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `T: ~const Foo` is not satisfied + --> $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) { + | ++++++++++++ + +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-fail-3.nn.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr new file mode 100644 index 000000000..fdc6b8058 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.nn.stderr @@ -0,0 +1,20 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:16:24 + | +LL | const fn foo(x: &T) { + | ^^^ + +error: aborting due to 3 previous errors + 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 new file mode 100644 index 000000000..7375b8c81 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.ny.stderr @@ -0,0 +1,14 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:12:19 + | +LL | trait Bar: ~const Foo {} + | ^^^ + +error: aborting due to 2 previous errors + 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 new file mode 100644 index 000000000..8cf64944a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.rs @@ -0,0 +1,21 @@ +#![feature(const_trait_impl)] + +// revisions: yy yn ny nn +//[yy] check-pass + +#[cfg_attr(any(yy, yn), const_trait)] +trait Foo { + fn a(&self); +} + +#[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]` + +const fn foo(x: &T) { + //[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]` + x.a(); +} + +fn main() {} 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 new file mode 100644 index 000000000..7a152914b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail-3.yn.stderr @@ -0,0 +1,8 @@ +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/super-traits-fail-3.rs:16:24 + | +LL | const fn foo(x: &T) { + | ^^^ + +error: aborting due to previous error + 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 new file mode 100644 index 000000000..3e2b81368 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.rs @@ -0,0 +1,18 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + fn a(&self); +} +#[const_trait] +trait Bar: ~const Foo {} + +struct S; +impl Foo for S { + fn a(&self) {} +} + +impl const Bar for S {} +//~^ 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 new file mode 100644 index 000000000..bf12ef1ca --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits-fail.stderr @@ -0,0 +1,20 @@ +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 new file mode 100644 index 000000000..df96f6fb4 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/super-traits.rs @@ -0,0 +1,25 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + fn a(&self); +} + +#[const_trait] +trait Bar: ~const Foo {} + +struct S; +impl const Foo for S { + fn a(&self) {} +} + +impl const Bar for S {} + +const fn foo(t: &T) { + t.a(); +} + +const _: () = foo(&S); + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/syntax.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/syntax.rs new file mode 100644 index 000000000..7ac2458e3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/syntax.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z parse-only +// check-pass + +#![feature(const_trait_bound_opt_out)] +#![feature(const_trait_impl)] + +// For now, this parses since an error does not occur until AST lowering. +impl ~const T {} 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 new file mode 100644 index 000000000..78a64b901 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs @@ -0,0 +1,34 @@ +#![feature(const_trait_impl)] +#![feature(generic_arg_infer)] +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct Foo; + +impl Foo { + fn add(self) -> Foo<{ A::add(N) }> { + Foo + } +} + +#[const_trait] +trait Add42 { + fn add(a: usize) -> usize; +} + +impl const Add42 for () { + fn add(a: usize) -> usize { + a + 42 + } +} + +fn bar(_: Foo) -> Foo<{ A::add(N) }> { + //~^ ERROR `~const` is not allowed here + Foo +} + +fn main() { + let foo = Foo::<0>; + let foo = bar::<(), _>(foo); + let _foo = bar::<(), _>(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 new file mode 100644 index 000000000..aae72f36e --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.stderr @@ -0,0 +1,14 @@ +error: `~const` is not allowed here + --> $DIR/tilde-const-and-const-params.rs:25: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 + | +LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { + | ^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs new file mode 100644 index 000000000..95f7aaba0 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs @@ -0,0 +1,7 @@ +#![feature(const_trait_impl)] +#![feature(associated_type_bounds)] + +struct TildeQuestion(std::marker::PhantomData); +//~^ ERROR `~const` and `?` are mutually exclusive + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr new file mode 100644 index 000000000..d20f146df --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr @@ -0,0 +1,8 @@ +error: `~const` and `?` are mutually exclusive + --> $DIR/tilde-const-invalid-places.rs:4:25 + | +LL | struct TildeQuestion(std::marker::PhantomData); + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-syntax.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-syntax.rs new file mode 100644 index 000000000..9b3c2cf2a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-syntax.rs @@ -0,0 +1,9 @@ +// compile-flags: -Z parse-only +// check-pass + +#![feature(const_trait_impl)] + +struct S< + T: ~const ?for<'a> Tr<'a> + 'static + ~const std::ops::Add, + T: ~const ?for<'a: 'b> m::Trait<'a>, +>; diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.rs new file mode 100644 index 000000000..06e4ede8b --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.rs @@ -0,0 +1,6 @@ +// compile-flags: -Z parse-only + +#![feature(const_trait_impl)] + +struct S; +//~^ ERROR expected identifier, found `~` diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.stderr new file mode 100644 index 000000000..928d23e8a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-twice.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `~` + --> $DIR/tilde-twice.rs:5:20 + | +LL | struct S; + | ^ expected identifier + +error: aborting due to previous error + 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 new file mode 100644 index 000000000..285cef571 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde_const_on_impl_bound.rs @@ -0,0 +1,17 @@ +// check-pass +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + fn foo(&self) {} +} + +struct Bar(T); + +impl Bar { + const fn foo(&self) { + self.0.foo() + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs new file mode 100644 index 000000000..8d56295e7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs @@ -0,0 +1,50 @@ +// known-bug: #110395 + +#![feature(staged_api)] +#![feature(const_trait_impl)] +#![feature(const_t_try)] +#![feature(const_try)] +#![feature(try_trait_v2)] + +#![stable(feature = "foo", since = "1.0")] + +use std::ops::{ControlFlow, FromResidual, Try}; + +#[stable(feature = "foo", since = "1.0")] +pub struct T; + +#[stable(feature = "foo", since = "1.0")] +#[rustc_const_unstable(feature = "const_t_try", issue = "none")] +impl const Try for T { + type Output = T; + type Residual = T; + + fn from_output(t: T) -> T { + t + } + + fn branch(self) -> ControlFlow { + ControlFlow::Continue(self) + } +} + +#[stable(feature = "foo", since = "1.0")] +#[rustc_const_unstable(feature = "const_t_try", issue = "none")] +impl const FromResidual for T { + fn from_residual(t: T) -> T { + t + } +} + +#[stable(feature = "foo", since = "1.0")] +#[const_trait] +pub trait Tr { + #[stable(feature = "foo", since = "1.0")] + fn bar() -> T { + T? + // Should be allowed. + // Must enable unstable features to call this trait fn in const contexts. + } +} + +fn main() {} 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 new file mode 100644 index 000000000..35dc1ca12 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr @@ -0,0 +1,20 @@ +error: const `impl` for trait `Try` which is not marked with `#[const_trait]` + --> $DIR/trait-default-body-stability.rs:18:12 + | +LL | impl const Try for T { + | ^^^ + | + = 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 `FromResidual` which is not marked with `#[const_trait]` + --> $DIR/trait-default-body-stability.rs:33:12 + | +LL | impl const FromResidual for T { + | ^^^^^^^^^^^^ + | + = 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 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs new file mode 100644 index 000000000..7d7cb967c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-method-ptr-in-consts-ice.rs @@ -0,0 +1,23 @@ +// check-pass + +struct LazyLock { + data: (Option, fn() -> T), +} + +impl LazyLock { + pub const fn new(f: fn() -> T) -> LazyLock { + LazyLock { data: (None, f) } + } +} + +struct A(Option); + +impl Default for A { + fn default() -> Self { + A(None) + } +} + +static EMPTY_SET: LazyLock> = LazyLock::new(A::default); + +fn main() {} 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 new file mode 100644 index 000000000..bfe98b98c --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.rs @@ -0,0 +1,31 @@ +// Like trait-where-clause.rs, but we are calling from a const context. +// 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)] + +#[const_trait] +trait Bar {} + +#[const_trait] +trait Foo { + fn a(); + fn b() where Self: ~const Bar; + fn c(); +} + +const fn test1() { + T::a(); + T::b(); + //~^ ERROR the trait bound + T::c::(); + //~^ ERROR the trait bound +} + +const fn test2() { + T::a(); + T::b(); + T::c::(); +} + +fn main() {} 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 new file mode 100644 index 000000000..f2846b6a6 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-const.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `T: ~const Bar` is not satisfied + --> $DIR/trait-where-clause-const.rs:19:5 + | +LL | T::b(); + | ^^^^^^ the trait `~const 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 + | +LL | T::b(); + | ^^^^^^ +help: consider further restricting this bound + | +LL | const fn test1() { + | ++++++++++++ + +error[E0277]: the trait bound `T: ~const Bar` is not satisfied + --> $DIR/trait-where-clause-const.rs:21:5 + | +LL | T::c::(); + | ^^^^^^^^^^^ the trait `~const 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 + | +LL | T::c::(); + | ^^^^^^^^^^^ +help: consider further restricting this bound + | +LL | const fn test1() { + | ++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. 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 new file mode 100644 index 000000000..4b8b00406 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-run.rs @@ -0,0 +1,41 @@ +// run-pass + +#![feature(const_trait_impl)] + +#[const_trait] +trait Bar { + fn bar() -> u8; +} + +#[const_trait] +trait Foo { + fn foo() -> u8 where Self: ~const Bar { + ::bar() * 6 + } +} + +struct NonConst; +struct Const; + +impl Bar for NonConst { + fn bar() -> u8 { + 3 + } +} + +impl Foo for NonConst {} + +impl const Bar for Const { + fn bar() -> u8 { + 4 + } +} + +impl const Foo for Const {} + +fn main() { + const ANS1: u8 = Const::foo(); + let ans2 = NonConst::foo(); + + assert_eq!(ANS1 + ans2, 42); +} 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 new file mode 100644 index 000000000..3b028ac48 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs @@ -0,0 +1,24 @@ +// check-pass + +#![feature(const_trait_impl)] + +#[const_trait] +trait Foo { + fn bar() where Self: ~const Foo; +} + +struct S; + +impl Foo for S { + fn bar() {} +} + +fn baz() { + T::bar(); +} + +const fn qux() { + T::bar(); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.rs new file mode 100644 index 000000000..85ca5fc90 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.rs @@ -0,0 +1,26 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Bar {} + +trait Foo { + fn a(); + fn b() where Self: ~const Bar; + fn c(); +} + +fn test1() { + T::a(); + T::b(); + //~^ ERROR the trait bound + T::c::(); + //~^ ERROR the trait bound +} + +fn test2() { + T::a(); + T::b(); + T::c::(); +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr new file mode 100644 index 000000000..11f0c4016 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/trait-where-clause.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `T: Bar` is not satisfied + --> $DIR/trait-where-clause.rs:14:5 + | +LL | T::b(); + | ^^^^ the trait `Bar` is not implemented for `T` + | +note: required by a bound in `Foo::b` + --> $DIR/trait-where-clause.rs:8:24 + | +LL | fn b() where Self: ~const Bar; + | ^^^^^^^^^^ required by this bound in `Foo::b` +help: consider further restricting this bound + | +LL | fn test1() { + | +++++ + +error[E0277]: the trait bound `T: Bar` is not satisfied + --> $DIR/trait-where-clause.rs:16:12 + | +LL | T::c::(); + | ^ the trait `Bar` is not implemented for `T` + | +note: required by a bound in `Foo::c` + --> $DIR/trait-where-clause.rs:9:13 + | +LL | fn c(); + | ^^^^^^^^^^ required by this bound in `Foo::c` +help: consider further restricting this bound + | +LL | fn test1() { + | +++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs new file mode 100644 index 000000000..d63381b5f --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.rs @@ -0,0 +1,6 @@ +// compile-flags: -Z parse-only + +#![feature(const_trait_impl)] + +struct S; +//~^ ERROR const bounds must start with `~` diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr new file mode 100644 index 000000000..31300354a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/without-tilde.stderr @@ -0,0 +1,10 @@ +error: const bounds must start with `~` + --> $DIR/without-tilde.rs:5:13 + | +LL | struct S; + | -^^^^ + | | + | help: add `~`: `~` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs b/tests/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs deleted file mode 100644 index 17174e22c..000000000 --- a/tests/ui/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -#![allow(dead_code)] - -macro_rules! foo { - (#[$attr:meta] $x:ident) => { - #[$attr] - struct $x { - x: u32 - } - } -} - -foo! { #[derive(PartialEq, Eq)] Foo } - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff --git a/tests/ui/rfcs/rfc1445/eq-allows-match.rs b/tests/ui/rfcs/rfc1445/eq-allows-match.rs deleted file mode 100644 index 405a69c94..000000000 --- a/tests/ui/rfcs/rfc1445/eq-allows-match.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![allow(dead_code)] - -#[derive(PartialEq, Eq)] -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff --git a/tests/ui/rfcs/rfc1623-2.rs b/tests/ui/rfcs/rfc1623-2.rs deleted file mode 100644 index c0e13a5f5..000000000 --- a/tests/ui/rfcs/rfc1623-2.rs +++ /dev/null @@ -1,99 +0,0 @@ -#![allow(dead_code)] - -fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { - a -} - -// The incorrect case without `for<'a>` is tested for in `rfc1623-2.rs` -static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = - &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); - -struct SomeStruct<'x, 'y, 'z: 'x> { - foo: &'x Foo<'z>, - bar: &'x Bar<'z>, - f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Foo<'b>, -} - -// Without this, the wf-check will fail early so we'll never see the -// error in SOME_STRUCT's body. -unsafe impl<'x, 'y, 'z: 'x> Sync for SomeStruct<'x, 'y, 'z> {} - -fn id(t: T) -> T { - t -} - -static SOME_STRUCT: &SomeStruct = &SomeStruct { - foo: &Foo { bools: &[false, true] }, - bar: &Bar { bools: &[true, true] }, - f: &id, - //~^ ERROR mismatched types - //~| ERROR mismatched types - //~| ERROR implementation of `FnOnce` is not general enough - //~| ERROR implementation of `FnOnce` is not general enough -}; - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &'static str = "&'static str"; -const CONST_STR: &'static str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(a: &u8, b: &u8, c: &u8) {} - -static STATIC_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo<'static> = Foo { bools: &[true, false] }; -const CONST_FOO: Foo<'static> = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar<'static> = Bar { bools: &[true, false] }; -const CONST_BAR: Bar<'static> = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &'static Baz<'static> = &(baz as Baz); -const CONST_BAZ: &'static Baz<'static> = &(baz as Baz); - -static BYTES: &'static [u8] = &[1, 2, 3]; - -fn main() { - let x = &[1u8, 2, 3]; - let y = x; - - // this works, so lifetime < `'static` is valid - assert_eq!(Some(1), STATIC_BAZ(y)); - assert_eq!(Some(1), CONST_BAZ(y)); - - let y = &[1u8, 2, 3]; - - STATIC_BAZ(BYTES); // BYTES has static lifetime - CONST_BAZ(y); // interestingly this does not get reported -} diff --git a/tests/ui/rfcs/rfc1623-2.stderr b/tests/ui/rfcs/rfc1623-2.stderr deleted file mode 100644 index d183eaaa6..000000000 --- a/tests/ui/rfcs/rfc1623-2.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>` - found trait `Fn<(&Foo<'_>,)>` - -error[E0308]: mismatched types - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> Fn<(&'a Foo<'b>,)>` - found trait `Fn<(&Foo<'_>,)>` - -error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ implementation of `FnOnce` is not general enough - | - = note: `fn(&'2 Foo<'_>) -> &'2 Foo<'_> {id::<&'2 Foo<'_>>}` must implement `FnOnce<(&'1 Foo<'b>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 Foo<'_>,)>`, for some specific lifetime `'2` - -error: implementation of `FnOnce` is not general enough - --> $DIR/rfc1623-2.rs:28:8 - | -LL | f: &id, - | ^^^ implementation of `FnOnce` is not general enough - | - = note: `fn(&Foo<'2>) -> &Foo<'2> {id::<&Foo<'2>>}` must implement `FnOnce<(&'a Foo<'1>,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&Foo<'2>,)>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc1623-3.rs b/tests/ui/rfcs/rfc1623-3.rs deleted file mode 100644 index 26fa6fdb5..000000000 --- a/tests/ui/rfcs/rfc1623-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![allow(dead_code)] - -fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { - a -} - -// the boundaries of elision -static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = -//~^ ERROR missing lifetime specifier [E0106] - &(non_elidable as fn(&u8, &u8) -> &u8); - //~^ ERROR missing lifetime specifier [E0106] - //~| ERROR non-primitive cast - -fn main() {} diff --git a/tests/ui/rfcs/rfc1623-3.stderr b/tests/ui/rfcs/rfc1623-3.stderr deleted file mode 100644 index 77fc3f041..000000000 --- a/tests/ui/rfcs/rfc1623-3.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-3.rs:8:42 - | -LL | static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = - | --- --- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html -help: consider making the type lifetime-generic with a new `'a` lifetime - | -LL | static NON_ELIDABLE_FN: &for<'a> fn(&'a u8, &'a u8) -> &'a u8 = - | +++++++ ++ ++ ++ - -error[E0106]: missing lifetime specifier - --> $DIR/rfc1623-3.rs:10:39 - | -LL | &(non_elidable as fn(&u8, &u8) -> &u8); - | --- --- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 -help: consider making the type lifetime-generic with a new `'a` lifetime - | -LL | &(non_elidable as for<'a> fn(&'a u8, &'a u8) -> &'a u8); - | +++++++ ++ ++ ++ - -error[E0605]: non-primitive cast: `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {non_elidable}` as `for<'a, 'b> fn(&'a u8, &'b u8) -> &u8` - --> $DIR/rfc1623-3.rs:10:6 - | -LL | &(non_elidable as fn(&u8, &u8) -> &u8); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid cast - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0106, E0605. -For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/rfcs/rfc1623.rs b/tests/ui/rfcs/rfc1623.rs deleted file mode 100644 index adaf25c6b..000000000 --- a/tests/ui/rfcs/rfc1623.rs +++ /dev/null @@ -1,75 +0,0 @@ -// run-pass -#![allow(unused_variables)] -#![allow(non_upper_case_globals)] - -#![allow(dead_code)] - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &str = "&'static str"; -const CONST_STR: &str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(a: &u8, b: &u8, c: &u8) {} - -static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo = Foo { bools: &[true, false] }; -const CONST_FOO: Foo = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar = Bar { bools: &[true, false] }; -const CONST_BAR: Bar = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &Baz = &(baz as Baz); -const CONST_BAZ: &Baz = &(baz as Baz); - -static BYTES: &[u8] = &[1, 2, 3]; - -fn main() { - // make sure that the lifetime is actually elided (and not defaulted) - let x = &[1u8, 2, 3]; - STATIC_SIMPLE_FN(x); - CONST_SIMPLE_FN(x); - - STATIC_BAZ(BYTES); // neees static lifetime - CONST_BAZ(BYTES); - - // make sure this works with different lifetimes - let a = &1; - { - let b = &2; - let c = &3; - CONST_MULTI_FN(a, b, c); - } -} diff --git a/tests/ui/rfcs/rfc1717/library-override.rs b/tests/ui/rfcs/rfc1717/library-override.rs deleted file mode 100644 index 014ccac31..000000000 --- a/tests/ui/rfcs/rfc1717/library-override.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -// ignore-wasm32-bare no libc to test ffi with -// compile-flags: -lstatic=wronglibrary:rust_test_helpers - -#[link(name = "wronglibrary", kind = "dylib")] -extern "C" { - pub fn rust_dbg_extern_identity_u32(x: u32) -> u32; -} - -fn main() { - unsafe { - rust_dbg_extern_identity_u32(42); - } -} diff --git a/tests/ui/rfcs/rfc1857-drop-order.rs b/tests/ui/rfcs/rfc1857-drop-order.rs deleted file mode 100644 index 4c4816c2f..000000000 --- a/tests/ui/rfcs/rfc1857-drop-order.rs +++ /dev/null @@ -1,224 +0,0 @@ -// run-pass -// needs-unwind - -#![allow(dead_code, unreachable_code)] - -use std::cell::RefCell; -use std::rc::Rc; -use std::panic::{self, AssertUnwindSafe, UnwindSafe}; - -// This struct is used to record the order in which elements are dropped -struct PushOnDrop { - vec: Rc>>, - val: u32 -} - -impl PushOnDrop { - fn new(val: u32, vec: Rc>>) -> PushOnDrop { - PushOnDrop { vec, val } - } -} - -impl Drop for PushOnDrop { - fn drop(&mut self) { - self.vec.borrow_mut().push(self.val) - } -} - -impl UnwindSafe for PushOnDrop { } - -// Structs -struct TestStruct { - x: PushOnDrop, - y: PushOnDrop, - z: PushOnDrop -} - -// Tuple structs -struct TestTupleStruct(PushOnDrop, PushOnDrop, PushOnDrop); - -// Enum variants -enum TestEnum { - Tuple(PushOnDrop, PushOnDrop, PushOnDrop), - Struct { x: PushOnDrop, y: PushOnDrop, z: PushOnDrop } -} - -fn test_drop_tuple() { - // Tuple fields are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple = (PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone())); - drop(test_tuple); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Panic during construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - (PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_struct() { - // Struct fields are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_struct = TestStruct { - x: PushOnDrop::new(1, dropped_fields.clone()), - y: PushOnDrop::new(2, dropped_fields.clone()), - z: PushOnDrop::new(3, dropped_fields.clone()), - }; - drop(test_struct); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for tuple structs - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple_struct = TestTupleStruct(PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())); - drop(test_tuple_struct); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during struct construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestStruct { - x: PushOnDrop::new(2, cloned.clone()), - y: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Test with different initialization order - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestStruct { - y: PushOnDrop::new(2, cloned.clone()), - x: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for tuple structs - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestTupleStruct(PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_enum() { - // Enum variants are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_struct_enum = TestEnum::Struct { - x: PushOnDrop::new(1, dropped_fields.clone()), - y: PushOnDrop::new(2, dropped_fields.clone()), - z: PushOnDrop::new(3, dropped_fields.clone()) - }; - drop(test_struct_enum); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for tuple enum variants - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple_enum = TestEnum::Tuple(PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())); - drop(test_tuple_enum); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during enum construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Struct { - x: PushOnDrop::new(2, cloned.clone()), - y: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Test with different initialization order - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Struct { - y: PushOnDrop::new(2, cloned.clone()), - x: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for tuple enum variants - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Tuple(PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_list() { - // Elements in a Vec are dropped in the same order they are pushed - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let xs = vec![PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())]; - drop(xs); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for arrays - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let xs = [PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())]; - drop(xs); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during vec construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - vec![ - PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D") - ]; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for arrays - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - [ - PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D") - ]; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn main() { - test_drop_tuple(); - test_drop_struct(); - test_drop_enum(); - test_drop_list(); -} diff --git a/tests/ui/rust-2018/edition-lint-infer-outlives.fixed b/tests/ui/rust-2018/edition-lint-infer-outlives.fixed index 868bdf2e0..5058d61b5 100644 --- a/tests/ui/rust-2018/edition-lint-infer-outlives.fixed +++ b/tests/ui/rust-2018/edition-lint-infer-outlives.fixed @@ -801,4 +801,10 @@ where yoo: &'a U } +// https://github.com/rust-lang/rust/issues/105150 +struct InferredWhereBoundWithInlineBound<'a, T: ?Sized> +{ + data: &'a T, +} + fn main() {} diff --git a/tests/ui/rust-2018/edition-lint-infer-outlives.rs b/tests/ui/rust-2018/edition-lint-infer-outlives.rs index 75783764a..3f63cb8e9 100644 --- a/tests/ui/rust-2018/edition-lint-infer-outlives.rs +++ b/tests/ui/rust-2018/edition-lint-infer-outlives.rs @@ -801,4 +801,12 @@ where yoo: &'a U } +// https://github.com/rust-lang/rust/issues/105150 +struct InferredWhereBoundWithInlineBound<'a, T: ?Sized> +//~^ ERROR outlives requirements can be inferred + where T: 'a, +{ + data: &'a T, +} + fn main() {} diff --git a/tests/ui/rust-2018/edition-lint-infer-outlives.stderr b/tests/ui/rust-2018/edition-lint-infer-outlives.stderr index e655fb484..dbf301fd8 100644 --- a/tests/ui/rust-2018/edition-lint-infer-outlives.stderr +++ b/tests/ui/rust-2018/edition-lint-infer-outlives.stderr @@ -10,6 +10,15 @@ note: the lint level is defined here LL | #![deny(explicit_outlives_requirements)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:805:56 + | +LL | struct InferredWhereBoundWithInlineBound<'a, T: ?Sized> + | ________________________________________________________^ +LL | | +LL | | where T: 'a, + | |________________^ help: remove this bound + error: outlives requirements can be inferred --> $DIR/edition-lint-infer-outlives.rs:26:31 | @@ -922,5 +931,5 @@ error: outlives requirements can be inferred LL | union BeeWhereOutlivesAyTeeWhereDebug<'a, 'b, T> where 'b: 'a, T: Debug { | ^^^^^^^^ help: remove this bound -error: aborting due to 153 previous errors +error: aborting due to 154 previous errors diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr index 7e008d465..a5c79366b 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr @@ -4,7 +4,7 @@ error[E0659]: `std` is ambiguous LL | pub use std::io; | ^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution = note: `std` could refer to a built-in crate = help: use `::std` to refer to this crate unambiguously note: `std` could also refer to the module defined here diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr index 771d2c10c..8045f3a45 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr @@ -4,7 +4,7 @@ error[E0659]: `std` is ambiguous LL | use std::io; | ^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution = note: `std` could refer to a built-in crate = help: use `::std` to refer to this crate unambiguously note: `std` could also refer to the module defined here diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs b/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs index 50c8fc822..0ef580d7a 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 // This test is similar to `ambiguity.rs`, but nested in a module. @@ -5,8 +6,7 @@ #![allow(non_camel_case_types)] mod foo { - pub use std::io; - //~^ ERROR `std` is ambiguous + pub use std::io; // OK mod std { pub struct io; diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr deleted file mode 100644 index defb16f79..000000000 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `std` is ambiguous - --> $DIR/ambiguity-nested.rs:8:13 - | -LL | pub use std::io; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources - = note: `std` could refer to a built-in crate - = help: use `::std` to refer to this crate unambiguously -note: `std` could also refer to the module defined here - --> $DIR/ambiguity-nested.rs:11:5 - | -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_____^ - = help: use `self::std` to refer to this module unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity.rs b/tests/ui/rust-2018/uniform-paths/ambiguity.rs index 60f77a1c6..890e8b7b3 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity.rs +++ b/tests/ui/rust-2018/uniform-paths/ambiguity.rs @@ -1,9 +1,9 @@ +// check-pass // edition:2018 #![allow(non_camel_case_types)] -use std::io; -//~^ ERROR `std` is ambiguous +use std::io; // OK mod std { pub struct io; diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity.stderr deleted file mode 100644 index 2d735c7e3..000000000 --- a/tests/ui/rust-2018/uniform-paths/ambiguity.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `std` is ambiguous - --> $DIR/ambiguity.rs:5:5 - | -LL | use std::io; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources - = note: `std` could refer to a built-in crate - = help: use `::std` to refer to this crate unambiguously -note: `std` could also refer to the module defined here - --> $DIR/ambiguity.rs:8:1 - | -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_^ - = help: use `crate::std` to refer to this module unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs index 3f5897901..4cba09498 100644 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs +++ b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 mod my { @@ -13,7 +14,7 @@ mod sub { fn foo() { use my::sub; { - use sub::bar; //~ ERROR `sub` is ambiguous + use sub::bar; // OK } } diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr deleted file mode 100644 index 3d45a8140..000000000 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0659]: `sub` is ambiguous - --> $DIR/block-scoped-shadow-nested.rs:16:13 - | -LL | use sub::bar; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `sub` could refer to the module imported here - --> $DIR/block-scoped-shadow-nested.rs:14:9 - | -LL | use my::sub; - | ^^^^^^^ -note: `sub` could also refer to the module defined here - --> $DIR/block-scoped-shadow-nested.rs:9:1 - | -LL | / mod sub { -LL | | pub fn bar() {} -LL | | } - | |_^ - = help: use `crate::sub` to refer to this module unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs index 828ee4fe4..c902d133e 100644 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs +++ b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 #![allow(non_camel_case_types)] @@ -8,14 +9,11 @@ struct std; fn main() { enum Foo { A, B } - use Foo::*; - //~^ ERROR `Foo` is ambiguous + use Foo::*; // OK let _ = (A, B); fn std() {} enum std {} - use std as foo; - //~^ ERROR `std` is ambiguous - //~| ERROR `std` is ambiguous + use std as foo; // OK } diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr deleted file mode 100644 index b068312ce..000000000 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error[E0659]: `Foo` is ambiguous - --> $DIR/block-scoped-shadow.rs:11:9 - | -LL | use Foo::*; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `Foo` could refer to the enum defined here - --> $DIR/block-scoped-shadow.rs:10:5 - | -LL | enum Foo { A, B } - | ^^^^^^^^^^^^^^^^^ -note: `Foo` could also refer to the enum defined here - --> $DIR/block-scoped-shadow.rs:5:1 - | -LL | enum Foo {} - | ^^^^^^^^^^^ - = help: use `crate::Foo` to refer to this enum unambiguously - -error[E0659]: `std` is ambiguous - --> $DIR/block-scoped-shadow.rs:18:9 - | -LL | use std as foo; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `std` could refer to the enum defined here - --> $DIR/block-scoped-shadow.rs:17:5 - | -LL | enum std {} - | ^^^^^^^^^^^ -note: `std` could also refer to the struct defined here - --> $DIR/block-scoped-shadow.rs:7:1 - | -LL | struct std; - | ^^^^^^^^^^^ - = help: use `crate::std` to refer to this struct unambiguously - -error[E0659]: `std` is ambiguous - --> $DIR/block-scoped-shadow.rs:18:9 - | -LL | use std as foo; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `std` could refer to the function defined here - --> $DIR/block-scoped-shadow.rs:16:5 - | -LL | fn std() {} - | ^^^^^^^^^^^ -note: `std` could also refer to the unit struct defined here - --> $DIR/block-scoped-shadow.rs:7:1 - | -LL | struct std; - | ^^^^^^^^^^^ - = help: use `crate::std` to refer to this unit struct unambiguously - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/issue-56596.stderr b/tests/ui/rust-2018/uniform-paths/issue-56596.stderr index 8b8ab26dc..849d6275e 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-56596.stderr +++ b/tests/ui/rust-2018/uniform-paths/issue-56596.stderr @@ -4,7 +4,7 @@ error[E0659]: `issue_56596` is ambiguous LL | use issue_56596; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56596` could refer to a crate passed with `--extern` = help: use `::issue_56596` to refer to this crate unambiguously note: `issue_56596` could also refer to the module imported here @@ -12,7 +12,8 @@ note: `issue_56596` could also refer to the module imported here | LL | use m::*; | ^^^^ - = help: use `crate::issue_56596` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56596` to disambiguate + = help: or use `crate::issue_56596` to refer to this module unambiguously error: aborting due to previous error diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.rs b/tests/ui/rust-2018/uniform-paths/macro-rules.rs index 2d9a6a9a9..1084f5e8b 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.rs +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.rs @@ -27,8 +27,7 @@ mod m3 { fn f() { macro_rules! legacy_macro { () => () } - // Legacy macro imports create ambiguities with other names in the same namespace. - use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous + use legacy_macro as _; // OK } } diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr index 9f8c928c3..8a978c98a 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr @@ -10,26 +10,6 @@ help: consider adding a `#[macro_export]` to the macro in the imported module LL | macro_rules! legacy_macro { () => () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0659]: `legacy_macro` is ambiguous - --> $DIR/macro-rules.rs:31:13 - | -LL | use legacy_macro as _; - | ^^^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `legacy_macro` could refer to the macro defined here - --> $DIR/macro-rules.rs:28:9 - | -LL | macro_rules! legacy_macro { () => () } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `legacy_macro` could also refer to the macro defined here - --> $DIR/macro-rules.rs:25:5 - | -LL | macro legacy_macro() {} - | ^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `self::legacy_macro` to refer to this macro unambiguously - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0364, E0659. -For more information about an error, try `rustc --explain E0364`. +For more information about this error, try `rustc --explain E0364`. diff --git a/tests/ui/sanitize/issue-111184-generator-witness.rs b/tests/ui/sanitize/issue-111184-generator-witness.rs new file mode 100644 index 000000000..8f4118057 --- /dev/null +++ b/tests/ui/sanitize/issue-111184-generator-witness.rs @@ -0,0 +1,17 @@ +// Regression test for issue 111184, where ty::GeneratorWitness were not expected to occur in +// encode_ty and caused the compiler to ICE. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +// no-prefer-dynamic +// only-x86_64-unknown-linux-gnu +// run-pass + +use std::future::Future; + +async fn foo() {} +fn bar(_: impl Future) {} + +fn main() { + bar(foo()); +} diff --git a/tests/ui/simd/shuffle.rs b/tests/ui/simd/shuffle.rs index 3592adfdc..461243d48 100644 --- a/tests/ui/simd/shuffle.rs +++ b/tests/ui/simd/shuffle.rs @@ -1,14 +1,24 @@ -//run-pass +// run-pass +// revisions: opt noopt +//[noopt] compile-flags: -Copt-level=0 +//[opt] compile-flags: -O #![feature(repr_simd, platform_intrinsics)] +#![allow(incomplete_features)] +#![feature(adt_const_params)] 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)] #[repr(simd)] struct Simd([T; N]); +pub unsafe fn __shuffle_vector16(x: T, y: T) -> U { + simd_shuffle16(x, y, IDX) +} + fn main() { const I1: [u32; 4] = [0, 2, 4, 6]; const I2: [u32; 2] = [1, 5]; @@ -21,4 +31,16 @@ fn main() { let y: Simd = simd_shuffle(a, b, I2); assert_eq!(y.0, [1, 5]); } + // Test that an indirection (via an unnamed constant) + // through a const generic parameter also works. + // See https://github.com/rust-lang/rust/issues/113500 for details. + let a = Simd::([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + let b = Simd::([16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]); + unsafe { + __shuffle_vector16::< + { [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] }, + Simd, + Simd, + >(a, b); + } } diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs index a776e5089..a9d678c1e 100644 --- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs +++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs @@ -1,4 +1,4 @@ -// compile-flags -Wrust-2021-incompatible-closure-captures +#![warn(rust_2021_incompatible_closure_captures)] fn main() {} @@ -9,7 +9,7 @@ impl Numberer { //~^ ERROR `async fn` is not permitted in Rust 2015 interval: Duration, //~^ ERROR cannot find type `Duration` in this scope - ) -> Numberer { + ) -> Numberer { //~WARN: changes to closure capture in Rust 2021 Numberer {} } } diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr index 60433e1c2..71e9e7602 100644 --- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr +++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr @@ -18,7 +18,32 @@ help: consider importing this struct LL + use std::time::Duration; | -error: aborting due to 2 previous errors +warning: changes to closure capture in Rust 2021 will affect drop order + --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:12:19 + | +LL | interval: Duration, + | -------- in Rust 2018, this causes the closure to capture `interval`, but in Rust 2021, it has no effect +LL | +LL | ) -> Numberer { + | _________________-_^ + | | | + | | in Rust 2018, `interval` is dropped here along with the closure, but in Rust 2021 `interval` is not part of the closure +LL | | Numberer {} +LL | | } + | |_____^ + | + = note: for more information, see +note: the lint level is defined here + --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:1:9 + | +LL | #![warn(rust_2021_incompatible_closure_captures)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: add a dummy let to cause `interval` to be fully captured + | +LL | ) -> Numberer { let _ = &interval; + | ++++++++++++++++++ + +error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0412, E0670. For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/span/multiline-span-simple.stderr b/tests/ui/span/multiline-span-simple.stderr index b44df962a..b6052a209 100644 --- a/tests/ui/span/multiline-span-simple.stderr +++ b/tests/ui/span/multiline-span-simple.stderr @@ -6,10 +6,10 @@ LL | foo(1 as u32 + | = help: the trait `Add<()>` is not implemented for `u32` = help: the following other types implement trait `Add`: + + > <&'a u32 as Add> <&u32 as Add<&u32>> - > - error: aborting due to previous error diff --git a/tests/ui/specialization/specialization-default-items-drop-coherence.coherence.stderr b/tests/ui/specialization/specialization-default-items-drop-coherence.coherence.stderr new file mode 100644 index 000000000..578db0cc6 --- /dev/null +++ b/tests/ui/specialization/specialization-default-items-drop-coherence.coherence.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Overlap` for type `u32` + --> $DIR/specialization-default-items-drop-coherence.rs:29:1 + | +LL | impl Overlap for u32 { + | -------------------- first implementation here +... +LL | impl Overlap for ::Id { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/specialization/specialization-default-items-drop-coherence.next.stderr b/tests/ui/specialization/specialization-default-items-drop-coherence.next.stderr new file mode 100644 index 000000000..578db0cc6 --- /dev/null +++ b/tests/ui/specialization/specialization-default-items-drop-coherence.next.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Overlap` for type `u32` + --> $DIR/specialization-default-items-drop-coherence.rs:29:1 + | +LL | impl Overlap for u32 { + | -------------------- first implementation here +... +LL | impl Overlap for ::Id { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/specialization/specialization-default-items-drop-coherence.rs b/tests/ui/specialization/specialization-default-items-drop-coherence.rs index 16ad942d5..44c598f19 100644 --- a/tests/ui/specialization/specialization-default-items-drop-coherence.rs +++ b/tests/ui/specialization/specialization-default-items-drop-coherence.rs @@ -1,5 +1,8 @@ -// check-pass -// known-bug: #105782 +// revisions: classic coherence next +//[next] compile-flags: -Ztrait-solver=next +//[coherence] compile-flags: -Ztrait-solver=next-coherence +//[classic] check-pass +//[classic] known-bug: #105782 // Should fail. Default items completely drop candidates instead of ambiguity, // which is unsound during coherence, since coherence requires completeness. @@ -24,6 +27,8 @@ impl Overlap for u32 { } impl Overlap for ::Id { + //[coherence]~^ ERROR conflicting implementations of trait `Overlap` for type `u32` + //[next]~^^ ERROR conflicting implementations of trait `Overlap` for type `u32` type Assoc = Box; } diff --git a/tests/ui/stability-attribute/auxiliary/default_body.rs b/tests/ui/stability-attribute/auxiliary/default_body.rs index 3a177419d..2f315eb1b 100644 --- a/tests/ui/stability-attribute/auxiliary/default_body.rs +++ b/tests/ui/stability-attribute/auxiliary/default_body.rs @@ -11,6 +11,10 @@ pub trait JustTrait { #[rustc_default_body_unstable(feature = "fun_default_body", issue = "none")] #[stable(feature = "stable_feature", since = "1.0.0")] fn fun() {} + + #[rustc_default_body_unstable(feature = "fun_default_body", issue = "none", reason = "reason")] + #[stable(feature = "stable_feature", since = "1.0.0")] + fn fun2() {} } #[rustc_must_implement_one_of(eq, neq)] diff --git a/tests/ui/stability-attribute/default-body-stability-err.rs b/tests/ui/stability-attribute/default-body-stability-err.rs index ecb281bcc..d1a359768 100644 --- a/tests/ui/stability-attribute/default-body-stability-err.rs +++ b/tests/ui/stability-attribute/default-body-stability-err.rs @@ -10,6 +10,7 @@ struct Type; impl JustTrait for Type {} //~^ ERROR not all trait items implemented, missing: `CONSTANT` [E0046] //~| ERROR not all trait items implemented, missing: `fun` [E0046] +//~| ERROR not all trait items implemented, missing: `fun2` [E0046] impl Equal for Type { //~^ ERROR not all trait items implemented, missing: `eq` [E0046] diff --git a/tests/ui/stability-attribute/default-body-stability-err.stderr b/tests/ui/stability-attribute/default-body-stability-err.stderr index ef666f30f..12ec9ea3a 100644 --- a/tests/ui/stability-attribute/default-body-stability-err.stderr +++ b/tests/ui/stability-attribute/default-body-stability-err.stderr @@ -18,8 +18,18 @@ LL | impl JustTrait for Type {} = note: use of unstable library feature 'fun_default_body' = help: add `#![feature(fun_default_body)]` to the crate attributes to enable +error[E0046]: not all trait items implemented, missing: `fun2` + --> $DIR/default-body-stability-err.rs:10:1 + | +LL | impl JustTrait for Type {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: default implementation of `fun2` is unstable + = note: use of unstable library feature 'fun_default_body': reason + = help: add `#![feature(fun_default_body)]` to the crate attributes to enable + error[E0046]: not all trait items implemented, missing: `eq` - --> $DIR/default-body-stability-err.rs:14:1 + --> $DIR/default-body-stability-err.rs:15:1 | LL | / impl Equal for Type { LL | | @@ -33,6 +43,6 @@ LL | | } = note: use of unstable library feature 'eq_default_body' = help: add `#![feature(eq_default_body)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/stability-attribute/default-body-stability-ok-impls.rs b/tests/ui/stability-attribute/default-body-stability-ok-impls.rs index e1f5c0170..b29d45256 100644 --- a/tests/ui/stability-attribute/default-body-stability-ok-impls.rs +++ b/tests/ui/stability-attribute/default-body-stability-ok-impls.rs @@ -12,6 +12,8 @@ impl JustTrait for Type { const CONSTANT: usize = 1; fn fun() {} + + fn fun2() {} } impl Equal for Type { diff --git a/tests/ui/stability-attribute/stability-in-private-module.stderr b/tests/ui/stability-attribute/stability-in-private-module.stderr index 2f02a2496..cc8758714 100644 --- a/tests/ui/stability-attribute/stability-in-private-module.stderr +++ b/tests/ui/stability-attribute/stability-in-private-module.stderr @@ -2,7 +2,9 @@ error[E0603]: module `thread_info` is private --> $DIR/stability-in-private-module.rs:2:26 | LL | let _ = std::thread::thread_info::current_thread(); - | ^^^^^^^^^^^ private module + | ^^^^^^^^^^^ -------------- function `current_thread` is not publicly re-exported + | | + | private module | note: the module `thread_info` is defined here --> $SRC_DIR/std/src/thread/mod.rs:LL:COL diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index 35fdcae6a..926093047 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -47,7 +47,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/uninhabited-static.rs:12:31 | LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` warning: the type `Void` does not permit zero-initialization --> $DIR/uninhabited-static.rs:12:31 @@ -66,7 +66,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/uninhabited-static.rs:16:32 | LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` warning: the type `Void` does not permit zero-initialization --> $DIR/uninhabited-static.rs:16:32 diff --git a/tests/ui/std/slice-from-array-issue-113238.rs b/tests/ui/std/slice-from-array-issue-113238.rs new file mode 100644 index 000000000..e9e1bfb8d --- /dev/null +++ b/tests/ui/std/slice-from-array-issue-113238.rs @@ -0,0 +1,9 @@ +// check-pass + +// This intends to use the unsizing coercion from array to slice, but it only +// works if we resolve `<&[u8]>::from` as the reflexive `From for T`. In +// #113238, we found that gimli had added its own `From for &[u8]` +// that affected all `std/backtrace` users. +fn main() { + let _ = <&[u8]>::from(&[]); +} diff --git a/tests/ui/stdlib-unit-tests/not-sync.rs b/tests/ui/stdlib-unit-tests/not-sync.rs index f4648994f..e9395ae9e 100644 --- a/tests/ui/stdlib-unit-tests/not-sync.rs +++ b/tests/ui/stdlib-unit-tests/not-sync.rs @@ -17,6 +17,4 @@ fn main() { test::>(); //~^ ERROR `std::sync::mpsc::Receiver` cannot be shared between threads safely [E0277] - test::>(); - //~^ ERROR `Sender` cannot be shared between threads safely [E0277] } diff --git a/tests/ui/stdlib-unit-tests/not-sync.stderr b/tests/ui/stdlib-unit-tests/not-sync.stderr index 4e34e10e3..b9a266e4e 100644 --- a/tests/ui/stdlib-unit-tests/not-sync.stderr +++ b/tests/ui/stdlib-unit-tests/not-sync.stderr @@ -65,19 +65,6 @@ note: required by a bound in `test` LL | fn test() {} | ^^^^ required by this bound in `test` -error[E0277]: `Sender` cannot be shared between threads safely - --> $DIR/not-sync.rs:20:12 - | -LL | test::>(); - | ^^^^^^^^^^^ `Sender` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Sender` -note: required by a bound in `test` - --> $DIR/not-sync.rs:5:12 - | -LL | fn test() {} - | ^^^^ required by this bound in `test` - -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/structs-enums/issue-3008-1.rs b/tests/ui/structs-enums/issue-3008-1.rs new file mode 100644 index 000000000..1124969e6 --- /dev/null +++ b/tests/ui/structs-enums/issue-3008-1.rs @@ -0,0 +1,12 @@ +enum Foo { + Foo_(Bar) +} + +enum Bar { + //~^ ERROR recursive type `Bar` has infinite size + BarNone, + BarSome(Bar) +} + +fn main() { +} diff --git a/tests/ui/structs-enums/issue-3008-1.stderr b/tests/ui/structs-enums/issue-3008-1.stderr new file mode 100644 index 000000000..be25b9091 --- /dev/null +++ b/tests/ui/structs-enums/issue-3008-1.stderr @@ -0,0 +1,17 @@ +error[E0072]: recursive type `Bar` has infinite size + --> $DIR/issue-3008-1.rs:5:1 + | +LL | enum Bar { + | ^^^^^^^^ +... +LL | BarSome(Bar) + | --- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | BarSome(Box) + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/structs-enums/issue-3008-2.rs b/tests/ui/structs-enums/issue-3008-2.rs new file mode 100644 index 000000000..5846c69da --- /dev/null +++ b/tests/ui/structs-enums/issue-3008-2.rs @@ -0,0 +1,6 @@ +enum Foo { Foo_(Bar) } +struct Bar { x: Bar } +//~^ ERROR E0072 + +fn main() { +} diff --git a/tests/ui/structs-enums/issue-3008-2.stderr b/tests/ui/structs-enums/issue-3008-2.stderr new file mode 100644 index 000000000..858a8fd6a --- /dev/null +++ b/tests/ui/structs-enums/issue-3008-2.stderr @@ -0,0 +1,14 @@ +error[E0072]: recursive type `Bar` has infinite size + --> $DIR/issue-3008-2.rs:2:1 + | +LL | struct Bar { x: Bar } + | ^^^^^^^^^^ --- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | struct Bar { x: Box } + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/structs-enums/issue-3008-3.rs b/tests/ui/structs-enums/issue-3008-3.rs new file mode 100644 index 000000000..212eb2eb8 --- /dev/null +++ b/tests/ui/structs-enums/issue-3008-3.rs @@ -0,0 +1,10 @@ +use std::marker; + +enum E1 { V1(E2), } +enum E2 { V2(E2, marker::PhantomData), } +//~^ ERROR recursive type `E2` has infinite size + +impl E1 { fn foo(&self) {} } + +fn main() { +} diff --git a/tests/ui/structs-enums/issue-3008-3.stderr b/tests/ui/structs-enums/issue-3008-3.stderr new file mode 100644 index 000000000..a1a81e293 --- /dev/null +++ b/tests/ui/structs-enums/issue-3008-3.stderr @@ -0,0 +1,14 @@ +error[E0072]: recursive type `E2` has infinite size + --> $DIR/issue-3008-3.rs:4:1 + | +LL | enum E2 { V2(E2, marker::PhantomData), } + | ^^^^^^^^^^ ------ recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | enum E2 { V2(Box>, marker::PhantomData), } + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/structs/struct-field-cfg.stderr b/tests/ui/structs/struct-field-cfg.stderr index 5ec47c093..2b9ba85dd 100644 --- a/tests/ui/structs/struct-field-cfg.stderr +++ b/tests/ui/structs/struct-field-cfg.stderr @@ -10,7 +10,7 @@ error[E0560]: struct `Foo` has no field named `absent` LL | let _ = Foo { present: (), #[cfg(all())] absent: () }; | ^^^^^^ `Foo` does not have this field | - = note: available fields are: `present` + = note: all struct fields are already assigned error[E0027]: pattern does not mention field `present` --> $DIR/struct-field-cfg.rs:13:9 diff --git a/tests/ui/structs/struct-fields-shorthand.stderr b/tests/ui/structs/struct-fields-shorthand.stderr index a285a3921..d89d45b39 100644 --- a/tests/ui/structs/struct-fields-shorthand.stderr +++ b/tests/ui/structs/struct-fields-shorthand.stderr @@ -4,7 +4,7 @@ error[E0560]: struct `Foo` has no field named `z` LL | x, y, z | ^ `Foo` does not have this field | - = note: available fields are: `x`, `y` + = note: all struct fields are already assigned error: aborting due to previous error diff --git a/tests/ui/structs/struct-fields-too-many.stderr b/tests/ui/structs/struct-fields-too-many.stderr index a1b7a7a31..9342607eb 100644 --- a/tests/ui/structs/struct-fields-too-many.stderr +++ b/tests/ui/structs/struct-fields-too-many.stderr @@ -4,7 +4,7 @@ error[E0560]: struct `BuildData` has no field named `bar` LL | bar: 0 | ^^^ `BuildData` does not have this field | - = note: available fields are: `foo` + = note: all struct fields are already assigned error: aborting due to previous error diff --git a/tests/ui/structs/struct-variant-privacy-xc.stderr b/tests/ui/structs/struct-variant-privacy-xc.stderr index 1c1caaef8..7a1c84bad 100644 --- a/tests/ui/structs/struct-variant-privacy-xc.stderr +++ b/tests/ui/structs/struct-variant-privacy-xc.stderr @@ -14,7 +14,9 @@ error[E0603]: enum `Bar` is private --> $DIR/struct-variant-privacy-xc.rs:7:33 | LL | struct_variant_privacy::Bar::Baz { a: _a } => {} - | ^^^ private enum + | ^^^ --- variant `Baz` is not publicly re-exported + | | + | private enum | note: the enum `Bar` is defined here --> $DIR/auxiliary/struct_variant_privacy.rs:1:1 diff --git a/tests/ui/structs/struct-variant-privacy.stderr b/tests/ui/structs/struct-variant-privacy.stderr index eafd26c71..eabd66907 100644 --- a/tests/ui/structs/struct-variant-privacy.stderr +++ b/tests/ui/structs/struct-variant-privacy.stderr @@ -14,7 +14,9 @@ error[E0603]: enum `Bar` is private --> $DIR/struct-variant-privacy.rs:10:14 | LL | foo::Bar::Baz { a: _a } => {} - | ^^^ private enum + | ^^^ --- variant `Baz` is not publicly re-exported + | | + | private enum | note: the enum `Bar` is defined here --> $DIR/struct-variant-privacy.rs:2:5 diff --git a/tests/ui/suggestions/adt-param-with-implicit-sized-bound.stderr b/tests/ui/suggestions/adt-param-with-implicit-sized-bound.stderr index b77c8c7fd..d136f5ff6 100644 --- a/tests/ui/suggestions/adt-param-with-implicit-sized-bound.stderr +++ b/tests/ui/suggestions/adt-param-with-implicit-sized-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/adt-param-with-implicit-sized-bound.rs:25:9 | LL | struct Struct5{ - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | _t: X, | ^^^^ doesn't have a size known at compile-time | diff --git a/tests/ui/suggestions/as-ref.rs b/tests/ui/suggestions/as-ref.rs index a05353441..0d9790ac2 100644 --- a/tests/ui/suggestions/as-ref.rs +++ b/tests/ui/suggestions/as-ref.rs @@ -24,4 +24,6 @@ fn main() { let multiple_ref_result = &&Ok(Foo); multiple_ref_result.map(|arg| takes_ref(arg)); //~ ERROR mismatched types [E0308] multiple_ref_result.and_then(|arg| Ok(takes_ref(arg))); //~ ERROR mismatched types [E0308] + + let _: Result<&usize, _> = &Ok(42); //~ ERROR mismatched types [E0308] } diff --git a/tests/ui/suggestions/as-ref.stderr b/tests/ui/suggestions/as-ref.stderr index 2147d2d92..c5b2bb126 100644 --- a/tests/ui/suggestions/as-ref.stderr +++ b/tests/ui/suggestions/as-ref.stderr @@ -74,14 +74,16 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:13:29 | LL | let y: Option<&usize> = x; - | -------------- ^ - | | | - | | expected `Option<&usize>`, found `&Option` - | | help: you can convert from `&Option` to `Option<&T>` using `.as_ref()`: `x.as_ref()` + | -------------- ^ expected `Option<&usize>`, found `&Option` + | | | expected due to this | = note: expected enum `Option<&usize>` found reference `&Option` +help: try using `.as_ref()` to convert `&Option` to `Option<&usize>` + | +LL | let y: Option<&usize> = x.as_ref(); + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:15:37 @@ -93,10 +95,10 @@ LL | let y: Result<&usize, &usize> = x; | = note: expected enum `Result<&usize, &usize>` found reference `&Result` -help: you can convert from `&Result` to `Result<&T, &E>` using `.as_ref()` +help: try using `.as_ref()` to convert `&Result` to `Result<&usize, &usize>` | LL | let y: Result<&usize, &usize> = x.as_ref(); - | ~~~~~~~~~~ + | +++++++++ error[E0308]: mismatched types --> $DIR/as-ref.rs:19:36 @@ -181,6 +183,22 @@ help: consider using `as_ref` instead LL | multiple_ref_result.as_ref().and_then(|arg| Ok(takes_ref(arg))); | +++++++++ -error: aborting due to 11 previous errors +error[E0308]: mismatched types + --> $DIR/as-ref.rs:28:32 + | +LL | let _: Result<&usize, _> = &Ok(42); + | ----------------- ^^^^^^^ expected `Result<&usize, _>`, found `&Result<{integer}, _>` + | | + | expected due to this + | + = note: expected enum `Result<&usize, _>` + found reference `&Result<{integer}, _>` +help: try using `.as_ref()` to convert `&Result<{integer}, _>` to `Result<&usize, _>` + | +LL - let _: Result<&usize, _> = &Ok(42); +LL + let _: Result<&usize, _> = Ok(42).as_ref(); + | + +error: aborting due to 12 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 98b88b4fb..5e7a7685a 100644 --- a/tests/ui/suggestions/crate-or-module-typo.stderr +++ b/tests/ui/suggestions/crate-or-module-typo.stderr @@ -36,6 +36,11 @@ error[E0433]: failed to resolve: use of undeclared crate or module `bar` | 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/dont-suggest-try_into-in-macros.stderr b/tests/ui/suggestions/dont-suggest-try_into-in-macros.stderr index bc6342004..319d86600 100644 --- a/tests/ui/suggestions/dont-suggest-try_into-in-macros.stderr +++ b/tests/ui/suggestions/dont-suggest-try_into-in-macros.stderr @@ -1,13 +1,13 @@ error[E0308]: mismatched types - --> $DIR/dont-suggest-try_into-in-macros.rs:2:5 + --> $DIR/dont-suggest-try_into-in-macros.rs:2:23 | LL | assert_eq!(10u64, 10usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected `u64`, found `usize` - | expected because this is `u64` + | ^^^^^^^ expected `u64`, found `usize` | - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: change the type of the numeric literal from `usize` to `u64` + | +LL | assert_eq!(10u64, 10u64); + | ~~~ error: aborting due to previous error diff --git a/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr index e74c2c421..6465eeb8b 100644 --- a/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr +++ b/tests/ui/suggestions/impl-trait-return-trailing-semicolon.stderr @@ -16,8 +16,8 @@ LL | fn bar() -> impl Bar { | ^^^^^^^^ the trait `Bar` is not implemented for `()` | = help: the following other types implement trait `Bar`: - Qux i32 + Qux error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/into-str.stderr b/tests/ui/suggestions/into-str.stderr index a56a2a188..7e24150e7 100644 --- a/tests/ui/suggestions/into-str.stderr +++ b/tests/ui/suggestions/into-str.stderr @@ -8,12 +8,12 @@ LL | foo(String::new()); | = note: to coerce a `String` into a `&str`, use `&*` as a prefix = help: the following other types implement trait `From`: - > - > - > + > >> >> - > + > + > + > = note: required for `String` to implement `Into<&str>` note: required by a bound in `foo` --> $DIR/into-str.rs:1:31 diff --git a/tests/ui/suggestions/issue-102972.rs b/tests/ui/suggestions/issue-102972.rs new file mode 100644 index 000000000..106288b05 --- /dev/null +++ b/tests/ui/suggestions/issue-102972.rs @@ -0,0 +1,16 @@ +fn test1() { + let mut chars = "Hello".chars(); + for _c in chars.by_ref() { + chars.next(); //~ ERROR cannot borrow `chars` as mutable more than once at a time + } +} + +fn test2() { + let v = vec![1, 2, 3]; + let mut iter = v.iter(); + for _i in iter { + iter.next(); //~ ERROR borrow of moved value: `iter` + } +} + +fn main() { } diff --git a/tests/ui/suggestions/issue-102972.stderr b/tests/ui/suggestions/issue-102972.stderr new file mode 100644 index 000000000..03f9dbb6c --- /dev/null +++ b/tests/ui/suggestions/issue-102972.stderr @@ -0,0 +1,33 @@ +error[E0499]: cannot borrow `chars` as mutable more than once at a time + --> $DIR/issue-102972.rs:4:9 + | +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`. + +error[E0382]: borrow of moved value: `iter` + --> $DIR/issue-102972.rs:12:9 + | +LL | let mut iter = v.iter(); + | -------- move occurs because `iter` has type `std::slice::Iter<'_, i32>`, which does not implement the `Copy` trait +LL | for _i in iter { + | ---- `iter` moved due to this implicit call to `.into_iter()` +LL | iter.next(); + | ^^^^^^^^^^^ 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 + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0382, E0499. +For more information about an error, try `rustc --explain E0382`. diff --git a/tests/ui/suggestions/issue-103646.rs b/tests/ui/suggestions/issue-103646.rs new file mode 100644 index 000000000..f679640c5 --- /dev/null +++ b/tests/ui/suggestions/issue-103646.rs @@ -0,0 +1,11 @@ +trait Cat { + fn nya() {} +} + +fn uwu(c: T) { + c.nya(); + //~^ ERROR no method named `nya` found for type parameter `T` in the current scope + //~| Suggestion T::nya() +} + +fn main() {} diff --git a/tests/ui/suggestions/issue-103646.stderr b/tests/ui/suggestions/issue-103646.stderr new file mode 100644 index 000000000..3ae9813d4 --- /dev/null +++ b/tests/ui/suggestions/issue-103646.stderr @@ -0,0 +1,21 @@ +error[E0599]: no method named `nya` found for type parameter `T` in the current scope + --> $DIR/issue-103646.rs:6:7 + | +LL | fn uwu(c: T) { + | - method `nya` not found for this type parameter +LL | c.nya(); + | --^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `T::nya()` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in the trait `Cat` + --> $DIR/issue-103646.rs:2:5 + | +LL | fn nya() {} + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/suggestions/issue-109991.rs b/tests/ui/suggestions/issue-109991.rs new file mode 100644 index 000000000..918451cb8 --- /dev/null +++ b/tests/ui/suggestions/issue-109991.rs @@ -0,0 +1,27 @@ +struct S { + a: usize, + b: usize, +} + +fn main() { + let a: usize; + let b: usize; + let c: usize; + + (c) = (&123); //~ ERROR mismatched types + (a, b) = (123, &mut 123); //~ ERROR mismatched types + + let x: String; + (x,) = (1,); //~ ERROR mismatched types + + let x: i32; + [x] = [&1]; //~ ERROR mismatched types + + let x: &i32; + [x] = [1]; //~ ERROR mismatched types + + let x = (1, &mut 2); + (a, b) = x; //~ ERROR mismatched types + + S { a, b } = S { a: 1, b: &mut 2 }; //~ ERROR mismatched types +} diff --git a/tests/ui/suggestions/issue-109991.stderr b/tests/ui/suggestions/issue-109991.stderr new file mode 100644 index 000000000..bd21e4de6 --- /dev/null +++ b/tests/ui/suggestions/issue-109991.stderr @@ -0,0 +1,72 @@ +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:11:11 + | +LL | let c: usize; + | ----- expected due to this type +LL | +LL | (c) = (&123); + | ^^^^^^ expected `usize`, found `&{integer}` + | +help: consider removing the borrow + | +LL - (c) = (&123); +LL + (c) = (123); + | + +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:12:9 + | +LL | let b: usize; + | ----- expected due to this type +... +LL | (a, b) = (123, &mut 123); + | ^ expected `usize`, found `&mut {integer}` + +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:15:6 + | +LL | let x: String; + | ------ expected due to this type +LL | (x,) = (1,); + | ^ expected `String`, found integer + +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:18:6 + | +LL | let x: i32; + | --- expected due to this type +LL | [x] = [&1]; + | ^ expected `i32`, found `&{integer}` + +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:21:6 + | +LL | let x: &i32; + | ---- expected due to this type +LL | [x] = [1]; + | ^ expected `&i32`, found integer + +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:24:9 + | +LL | let b: usize; + | ----- expected due to this type +... +LL | (a, b) = x; + | ^ expected `usize`, found `&mut {integer}` + +error[E0308]: mismatched types + --> $DIR/issue-109991.rs:26:31 + | +LL | S { a, b } = S { a: 1, b: &mut 2 }; + | ^^^^^^ expected `usize`, found `&mut {integer}` + | +help: consider removing the borrow + | +LL - S { a, b } = S { a: 1, b: &mut 2 }; +LL + S { a, b } = S { a: 1, b: 2 }; + | + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/issue-112590-suggest-import.rs b/tests/ui/suggestions/issue-112590-suggest-import.rs new file mode 100644 index 000000000..0938814c5 --- /dev/null +++ b/tests/ui/suggestions/issue-112590-suggest-import.rs @@ -0,0 +1,10 @@ +pub struct S; + +impl fmt::Debug for S { //~ ERROR failed to resolve: use of undeclared crate or module `fmt` + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { //~ ERROR failed to resolve: use of undeclared crate or module `fmt` + //~^ ERROR failed to resolve: use of undeclared crate or module `fmt` + Ok(()) + } +} + +fn main() { } diff --git a/tests/ui/suggestions/issue-112590-suggest-import.stderr b/tests/ui/suggestions/issue-112590-suggest-import.stderr new file mode 100644 index 000000000..aeac18c16 --- /dev/null +++ b/tests/ui/suggestions/issue-112590-suggest-import.stderr @@ -0,0 +1,36 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `fmt` + --> $DIR/issue-112590-suggest-import.rs:3:6 + | +LL | impl fmt::Debug for S { + | ^^^ use of undeclared crate or module `fmt` + | +help: consider importing this module + | +LL + use std::fmt; + | + +error[E0433]: failed to resolve: use of undeclared crate or module `fmt` + --> $DIR/issue-112590-suggest-import.rs:4:28 + | +LL | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + | ^^^ use of undeclared crate or module `fmt` + | +help: consider importing this module + | +LL + use std::fmt; + | + +error[E0433]: failed to resolve: use of undeclared crate or module `fmt` + --> $DIR/issue-112590-suggest-import.rs:4:51 + | +LL | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + | ^^^ use of undeclared crate or module `fmt` + | +help: consider importing this module + | +LL + use std::fmt; + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.stderr b/tests/ui/suggestions/issue-71394-no-from-impl.stderr index 2cd036d2b..80be252a0 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/tests/ui/suggestions/issue-71394-no-from-impl.stderr @@ -5,14 +5,14 @@ LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | = help: the following other types implement trait `From`: - <[T; 10] as From<(T, T, T, T, T, T, T, T, T, T)>> - <[T; 11] as From<(T, T, T, T, T, T, T, T, T, T, T)>> - <[T; 12] as From<(T, T, T, T, T, T, T, T, T, T, T, T)>> + <[bool; LANES] as From>> + <[T; N] as From>> <[T; 1] as From<(T,)>> <[T; 2] as From<(T, T)>> <[T; 3] as From<(T, T, T)>> <[T; 4] as From<(T, T, T, T)>> <[T; 5] as From<(T, T, T, T, T)>> + <[T; 6] as From<(T, T, T, T, T, T)>> and 6 others = note: required for `&[u8]` to implement `Into<&[i8]>` diff --git a/tests/ui/suggestions/issue-88696.rs b/tests/ui/suggestions/issue-88696.rs new file mode 100644 index 000000000..745fdef15 --- /dev/null +++ b/tests/ui/suggestions/issue-88696.rs @@ -0,0 +1,14 @@ +// This test case should ensure that miniz_oxide isn't +// suggested, since it's not a direct dependency. + +fn a() -> Result { + Err(1) +} + +fn b() -> Result { + a().into() //~ERROR [E0277] +} + +fn main() { + let _ = dbg!(b()); +} diff --git a/tests/ui/suggestions/issue-88696.stderr b/tests/ui/suggestions/issue-88696.stderr new file mode 100644 index 000000000..4947269d7 --- /dev/null +++ b/tests/ui/suggestions/issue-88696.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Result: From>` is not satisfied + --> $DIR/issue-88696.rs:9:9 + | +LL | a().into() + | ^^^^ the trait `From>` is not implemented for `Result` + | + = note: required for `Result` to implement `Into>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/issue-89640.rs b/tests/ui/suggestions/issue-89640.rs new file mode 100644 index 000000000..6bb33ad8f --- /dev/null +++ b/tests/ui/suggestions/issue-89640.rs @@ -0,0 +1,3 @@ +fn main() { + le t x: i32 = 3; //~ ERROR expected one of +} diff --git a/tests/ui/suggestions/issue-89640.stderr b/tests/ui/suggestions/issue-89640.stderr new file mode 100644 index 000000000..8ff4ef4f0 --- /dev/null +++ b/tests/ui/suggestions/issue-89640.stderr @@ -0,0 +1,13 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `t` + --> $DIR/issue-89640.rs:2:8 + | +LL | le t x: i32 = 3; + | ^ expected one of 8 possible tokens + | +help: consider removing the space to spell keyword `let` + | +LL | let x: i32 = 3; + | ~~~ + +error: aborting due to previous error + diff --git a/tests/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr b/tests/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr index 6071b10d3..eb74679d6 100644 --- a/tests/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr +++ b/tests/ui/suggestions/removal-of-multiline-trait-bound-in-where-clause.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn foo(foo: Wrapper) | - ^^^^^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Wrapper` --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 @@ -33,7 +33,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn bar(foo: Wrapper) | - ^^^^^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Wrapper` --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 @@ -58,7 +58,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn qux(foo: Wrapper) | - ^^^^^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Wrapper` --> $DIR/removal-of-multiline-trait-bound-in-where-clause.rs:1:16 diff --git a/tests/ui/suggestions/suggest-split-at-mut.stderr b/tests/ui/suggestions/suggest-split-at-mut.stderr index 330f012b2..bb1851383 100644 --- a/tests/ui/suggestions/suggest-split-at-mut.stderr +++ b/tests/ui/suggestions/suggest-split-at-mut.stderr @@ -9,6 +9,7 @@ LL | *a = 5; | ------ first borrow later used here | = help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices + = help: consider using `.swap(index_1, index_2)` to swap elements at the specified indices error: aborting due to previous error diff --git a/tests/ui/suggestions/while-let-typo.rs b/tests/ui/suggestions/while-let-typo.rs index dbbcdee3c..21b254054 100644 --- a/tests/ui/suggestions/while-let-typo.rs +++ b/tests/ui/suggestions/while-let-typo.rs @@ -2,7 +2,7 @@ fn main() { let foo = Some(0); let bar = None; while Some(x) = foo {} //~ ERROR cannot find value `x` in this scope - while Some(foo) = bar {} + while Some(foo) = bar {} //~ ERROR mismatched types while 3 = foo {} //~ ERROR mismatched types while Some(3) = foo {} //~ ERROR invalid left-hand side of assignment while x = 5 {} //~ ERROR cannot find value `x` in this scope diff --git a/tests/ui/suggestions/while-let-typo.stderr b/tests/ui/suggestions/while-let-typo.stderr index 7cc2ed314..69a7e5761 100644 --- a/tests/ui/suggestions/while-let-typo.stderr +++ b/tests/ui/suggestions/while-let-typo.stderr @@ -20,6 +20,17 @@ help: you might have meant to use pattern matching LL | while let x = 5 {} | +++ +error[E0308]: mismatched types + --> $DIR/while-let-typo.rs:5:11 + | +LL | while Some(foo) = bar {} + | ^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | while let Some(foo) = bar {} + | +++ + error[E0308]: mismatched types --> $DIR/while-let-typo.rs:6:11 | @@ -39,7 +50,7 @@ help: you might have meant to use pattern destructuring LL | while let Some(3) = foo {} | +++ -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0070, E0308, E0425. For more information about an error, try `rustc --explain E0070`. diff --git a/tests/ui/switched-expectations.stderr b/tests/ui/switched-expectations.stderr index 744d8483b..6e1bbf701 100644 --- a/tests/ui/switched-expectations.stderr +++ b/tests/ui/switched-expectations.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/switched-expectations.rs:3:30 | LL | let ref string: String = var; - | ^^^ expected `String`, found `i32` + | ^^^- help: try using a conversion method: `.to_string()` + | | + | expected `String`, found `i32` error: aborting due to previous error diff --git a/tests/ui/symbol-names/const-generics-structural-demangling.rs b/tests/ui/symbol-names/const-generics-structural-demangling.rs index df09ba494..947fddf3f 100644 --- a/tests/ui/symbol-names/const-generics-structural-demangling.rs +++ b/tests/ui/symbol-names/const-generics-structural-demangling.rs @@ -1,14 +1,13 @@ // build-fail // compile-flags: -C symbol-mangling-version=v0 --crate-name=c -// NOTE(eddyb) we need `core` for `core::option::Option`, normalize away its -// disambiguator hash, which can/should change (including between stage{1,2}). -// normalize-stderr-test: "core\[[0-9a-f]+\]" -> "core[HASH]" // normalize-stderr-test: "c\[[0-9a-f]+\]" -> "c[HASH]" #![feature(adt_const_params, decl_macro, rustc_attrs)] #![allow(incomplete_features)] +use std::marker::ConstParamTy; + pub struct RefByte; #[rustc_symbol_name] @@ -43,25 +42,31 @@ pub struct TupleByteBool; //~| ERROR demangling-alt(>) impl TupleByteBool<{(1, false)}> {} -pub struct OptionUsize>; +#[derive(PartialEq, Eq, ConstParamTy)] +pub enum MyOption { + Some(T), + None, +} + +pub struct OptionUsize>; // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize // the `core` disambiguator hash away there, but not here. #[rustc_symbol_name] //~^ ERROR symbol-name //~| ERROR demangling -//~| ERROR demangling-alt(::None}>>) -impl OptionUsize<{None}> {} +//~| ERROR demangling-alt(::None}>>) +impl OptionUsize<{MyOption::None}> {} // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize // the `core` disambiguator hash away there, but not here. #[rustc_symbol_name] //~^ ERROR symbol-name //~| ERROR demangling -//~| ERROR demangling-alt(::Some(0)}>>) -impl OptionUsize<{Some(0)}> {} +//~| ERROR demangling-alt(::Some(0)}>>) +impl OptionUsize<{MyOption::Some(0)}> {} -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, ConstParamTy)] pub struct Foo { s: &'static str, ch: char, @@ -78,7 +83,7 @@ impl Foo_<{Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}> {} // NOTE(eddyb) this tests specifically the use of disambiguators in field names, // using macros 2.0 hygiene to create a `struct` with conflicting field names. macro duplicate_field_name_test($x:ident) { - #[derive(PartialEq, Eq)] + #[derive(PartialEq, Eq, ConstParamTy)] pub struct Bar { $x: u8, x: u16, diff --git a/tests/ui/symbol-names/const-generics-structural-demangling.stderr b/tests/ui/symbol-names/const-generics-structural-demangling.stderr index a4c997477..96dea154d 100644 --- a/tests/ui/symbol-names/const-generics-structural-demangling.stderr +++ b/tests/ui/symbol-names/const-generics-structural-demangling.stderr @@ -1,131 +1,131 @@ error: symbol-name(_RMCsCRATE_HASH_1cINtB_7RefByteKRh7b_E) - --> $DIR/const-generics-structural-demangling.rs:14:1 + --> $DIR/const-generics-structural-demangling.rs:13:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:14:1 + --> $DIR/const-generics-structural-demangling.rs:13:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:14:1 + --> $DIR/const-generics-structural-demangling.rs:13:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs_CsCRATE_HASH_1cINtB_6RefZstKRAEE) - --> $DIR/const-generics-structural-demangling.rs:24:1 + --> $DIR/const-generics-structural-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:24:1 + --> $DIR/const-generics-structural-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:24:1 + --> $DIR/const-generics-structural-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs0_CsCRATE_HASH_1cINtB_11Array3BytesKAh1_h2_h3_EE) - --> $DIR/const-generics-structural-demangling.rs:32:1 + --> $DIR/const-generics-structural-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:32:1 + --> $DIR/const-generics-structural-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:32:1 + --> $DIR/const-generics-structural-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs1_CsCRATE_HASH_1cINtB_13TupleByteBoolKTh1_b0_EE) - --> $DIR/const-generics-structural-demangling.rs:40:1 + --> $DIR/const-generics-structural-demangling.rs:39:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:40:1 + --> $DIR/const-generics-structural-demangling.rs:39:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:40:1 + --> $DIR/const-generics-structural-demangling.rs:39:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs2_CsCRATE_HASH_1cINtB_11OptionUsizeKVNtINtNtCsCRATE_HASH_4core6option6OptionjE4NoneUE) - --> $DIR/const-generics-structural-demangling.rs:50:1 +error: symbol-name(_RMs2_CsCRATE_HASH_1cINtB_11OptionUsizeKVNtINtB_8MyOptionjE4NoneUE) + --> $DIR/const-generics-structural-demangling.rs:55:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(::None}>>) - --> $DIR/const-generics-structural-demangling.rs:50:1 +error: demangling(::None}>>) + --> $DIR/const-generics-structural-demangling.rs:55:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(::None}>>) - --> $DIR/const-generics-structural-demangling.rs:50:1 +error: demangling-alt(::None}>>) + --> $DIR/const-generics-structural-demangling.rs:55:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs3_CsCRATE_HASH_1cINtB_11OptionUsizeKVNtINtNtCsCRATE_HASH_4core6option6OptionjE4SomeTj0_EE) - --> $DIR/const-generics-structural-demangling.rs:58:1 +error: symbol-name(_RMs3_CsCRATE_HASH_1cINtB_11OptionUsizeKVNtINtB_8MyOptionjE4SomeTj0_EE) + --> $DIR/const-generics-structural-demangling.rs:63:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(::Some(0usize)}>>) - --> $DIR/const-generics-structural-demangling.rs:58:1 +error: demangling(::Some(0usize)}>>) + --> $DIR/const-generics-structural-demangling.rs:63:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(::Some(0)}>>) - --> $DIR/const-generics-structural-demangling.rs:58:1 +error: demangling-alt(::Some(0)}>>) + --> $DIR/const-generics-structural-demangling.rs:63:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs4_CsCRATE_HASH_1cINtB_4Foo_KVNtB_3FooS1sRe616263_2chc78_5sliceRAh1_h2_h3_EEE) - --> $DIR/const-generics-structural-demangling.rs:72:1 + --> $DIR/const-generics-structural-demangling.rs:77:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:72:1 + --> $DIR/const-generics-structural-demangling.rs:77:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:72:1 + --> $DIR/const-generics-structural-demangling.rs:77:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs9_CsCRATE_HASH_1cINtB_4Bar_KVNtB_3BarS1xh7b_s_1xt1000_EE) - --> $DIR/const-generics-structural-demangling.rs:88:5 +error: symbol-name(_RMsf_CsCRATE_HASH_1cINtB_4Bar_KVNtB_3BarS1xh7b_s_1xt1000_EE) + --> $DIR/const-generics-structural-demangling.rs:93:5 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | duplicate_field_name_test!(x); = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:88:5 + --> $DIR/const-generics-structural-demangling.rs:93:5 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ @@ -147,7 +147,7 @@ LL | duplicate_field_name_test!(x); = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:88:5 + --> $DIR/const-generics-structural-demangling.rs:93:5 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs b/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs index 585874e27..02fee1a00 100644 --- a/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs +++ b/tests/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs @@ -1,5 +1,5 @@ // run-pass -// needs-unwind (#73509) +// ignore-fuchsia Test must be run out-of-process #![feature(test)] diff --git a/tests/ui/test-attrs/test-function-signature.rs b/tests/ui/test-attrs/test-function-signature.rs new file mode 100644 index 000000000..9e86e9209 --- /dev/null +++ b/tests/ui/test-attrs/test-function-signature.rs @@ -0,0 +1,31 @@ +// compile-flags: --test + +#[test] +fn foo() -> Result<(), ()> { + Ok(()) +} + +#[test] +fn bar() -> i32 { //~ ERROR the trait bound `i32: Termination` is not satisfied + 0 +} + +#[test] +fn baz(val: i32) {} //~ ERROR functions used as tests can not have any arguments + +#[test] +fn lifetime_generic<'a>() -> Result<(), &'a str> { + Err("coerce me to any lifetime") +} + +#[test] +fn type_generic() {} //~ ERROR functions used as tests can not have any non-lifetime generic parameters + +#[test] +fn const_generic() {} //~ ERROR functions used as tests can not have any non-lifetime generic parameters + +// Regression test for . This used to ICE. +fn nested() { + #[test] + fn foo(arg: ()) {} //~ ERROR functions used as tests can not have any arguments +} diff --git a/tests/ui/test-attrs/test-function-signature.stderr b/tests/ui/test-attrs/test-function-signature.stderr new file mode 100644 index 000000000..abdb30dc9 --- /dev/null +++ b/tests/ui/test-attrs/test-function-signature.stderr @@ -0,0 +1,39 @@ +error: functions used as tests can not have any arguments + --> $DIR/test-function-signature.rs:14:1 + | +LL | fn baz(val: i32) {} + | ^^^^^^^^^^^^^^^^^^^ + +error: functions used as tests can not have any non-lifetime generic parameters + --> $DIR/test-function-signature.rs:22:1 + | +LL | fn type_generic() {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions used as tests can not have any non-lifetime generic parameters + --> $DIR/test-function-signature.rs:25:1 + | +LL | fn const_generic() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions used as tests can not have any arguments + --> $DIR/test-function-signature.rs:30:5 + | +LL | fn foo(arg: ()) {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `i32: Termination` is not satisfied + --> $DIR/test-function-signature.rs:9:13 + | +LL | #[test] + | ------- in this procedural macro expansion +LL | fn bar() -> i32 { + | ^^^ the trait `Termination` is not implemented for `i32` + | +note: required by a bound in `assert_test_result` + --> $SRC_DIR/test/src/lib.rs:LL:COL + = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/test-attrs/test-panic-abort-disabled.rs b/tests/ui/test-attrs/test-panic-abort-disabled.rs index 874dbdb42..fa67a784d 100644 --- a/tests/ui/test-attrs/test-panic-abort-disabled.rs +++ b/tests/ui/test-attrs/test-panic-abort-disabled.rs @@ -3,6 +3,7 @@ // compile-flags: --test -Cpanic=abort -Zpanic-abort-tests=no // run-flags: --test-threads=1 +// needs-unwind // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support diff --git a/tests/ui/test-attrs/test-panic-abort.rs b/tests/ui/test-attrs/test-panic-abort.rs index 931b7993c..08e5242af 100644 --- a/tests/ui/test-attrs/test-panic-abort.rs +++ b/tests/ui/test-attrs/test-panic-abort.rs @@ -11,9 +11,13 @@ // ignore-sgx no subprocess support #![cfg(test)] +#![feature(test)] + +extern crate test; use std::io::Write; use std::env; +use test::Bencher; #[test] fn it_works() { @@ -48,3 +52,8 @@ fn no_residual_environment() { } } } + +#[bench] +fn benchmark(b: &mut Bencher) { + b.iter(|| assert_eq!(1 + 1, 2)); +} diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout index f608a8cdc..b6b9c2560 100644 --- a/tests/ui/test-attrs/test-panic-abort.run.stdout +++ b/tests/ui/test-attrs/test-panic-abort.run.stdout @@ -1,5 +1,6 @@ -running 5 tests +running 6 tests +test benchmark ... ok test it_exits ... FAILED test it_fails ... FAILED test it_panics - should panic ... ok @@ -18,7 +19,7 @@ testing123 testing321 thread 'main' panicked at 'assertion failed: `(left == right)` left: `2`, - right: `5`', $DIR/test-panic-abort.rs:34:5 + right: `5`', $DIR/test-panic-abort.rs:38:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace @@ -26,5 +27,5 @@ failures: it_exits it_fails -test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +test result: FAILED. 4 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/tests/ui/test-attrs/test-type.rs b/tests/ui/test-attrs/test-type.rs index 8416270fd..d6d44a6b4 100644 --- a/tests/ui/test-attrs/test-type.rs +++ b/tests/ui/test-attrs/test-type.rs @@ -1,9 +1,8 @@ -// compile-flags: --test +// compile-flags: --test -Zpanic-abort-tests // run-flags: --test-threads=1 // check-run-results // normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" // ignore-emscripten no threads support -// needs-unwind // run-pass #[test] diff --git a/tests/ui/thir-print/thir-flat-const-variant.rs b/tests/ui/thir-print/thir-flat-const-variant.rs new file mode 100644 index 000000000..2cd87a5cb --- /dev/null +++ b/tests/ui/thir-print/thir-flat-const-variant.rs @@ -0,0 +1,18 @@ +// compile-flags: -Z unpretty=thir-flat +// check-pass + +// Previously, the constants with `Self::Bar(())` would be `Call`s instead of +// `Adt`s in THIR. + +pub enum Foo { + Bar(()), +} + +impl Foo { + const BAR1: Foo = Foo::Bar(()); + const BAR2: Foo = Self::Bar(()); + const BAR3: Self = Foo::Bar(()); + const BAR4: Self = Self::Bar(()); +} + +fn main() {} diff --git a/tests/ui/thir-print/thir-flat-const-variant.stdout b/tests/ui/thir-print/thir-flat-const-variant.stdout new file mode 100644 index 000000000..1b76f07c3 --- /dev/null +++ b/tests/ui/thir-print/thir-flat-const-variant.stdout @@ -0,0 +1,399 @@ +DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:32: 12:34 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(7), + lint_level: Explicit( + HirId(DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1).7), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:32: 12:34 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:8 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR1).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:33: 13:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(8), + lint_level: Explicit( + HirId(DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2).8), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:33: 13:35 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:9 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR2).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:33: 14:35 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(7), + lint_level: Explicit( + HirId(DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3).7), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:33: 14:35 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:10 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR3).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4): +Thir { + body_type: Const( + Foo, + ), + arms: [], + blocks: [], + exprs: [ + Expr { + kind: Tuple { + fields: [], + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:34: 15:36 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(8), + lint_level: Explicit( + HirId(DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4).8), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:34: 15:36 (#0), + }, + Expr { + kind: Adt( + AdtExpr { + adt_def: Foo, + variant_index: 0, + substs: [], + user_ty: None, + fields: [ + FieldExpr { + name: 0, + expr: e1, + }, + ], + base: None, + }, + ), + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(3), + lint_level: Explicit( + HirId(DefId(0:11 ~ thir_flat_const_variant[1f54]::{impl#0}::BAR4).3), + ), + value: e2, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(3), + lint_level: Inherited, + value: e3, + }, + ty: Foo, + temp_lifetime: Some( + Node(3), + ), + span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), + }, + ], + stmts: [], + params: [], +} + +DefId(0:12 ~ thir_flat_const_variant[1f54]::main): +Thir { + body_type: Fn( + fn(), + ), + arms: [], + blocks: [ + Block { + targeted_by_break: false, + region_scope: Node(1), + opt_destruction_scope: None, + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + stmts: [], + expr: None, + safety_mode: Safe, + }, + ], + exprs: [ + Expr { + kind: Block { + block: b0, + }, + ty: (), + temp_lifetime: Some( + Node(2), + ), + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + }, + Expr { + kind: Scope { + region_scope: Node(2), + lint_level: Explicit( + HirId(DefId(0:12 ~ thir_flat_const_variant[1f54]::main).2), + ), + value: e0, + }, + ty: (), + temp_lifetime: Some( + Node(2), + ), + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + }, + Expr { + kind: Scope { + region_scope: Destruction(2), + lint_level: Inherited, + value: e1, + }, + ty: (), + temp_lifetime: Some( + Node(2), + ), + span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), + }, + ], + stmts: [], + params: [], +} + diff --git a/tests/ui/thir-print/thir-flat.stdout b/tests/ui/thir-print/thir-flat.stdout index 9d467f73d..b0aa44b56 100644 --- a/tests/ui/thir-print/thir-flat.stdout +++ b/tests/ui/thir-print/thir-flat.stdout @@ -1,7 +1,7 @@ DefId(0:3 ~ thir_flat[7b97]::main): Thir { body_type: Fn( - ([]; c_variadic: false)->(), + fn(), ), arms: [], blocks: [ diff --git a/tests/ui/track-diagnostics/track6.stderr b/tests/ui/track-diagnostics/track6.stderr index 89438aea9..583b02555 100644 --- a/tests/ui/track-diagnostics/track6.stderr +++ b/tests/ui/track-diagnostics/track6.stderr @@ -3,7 +3,7 @@ error[E0658]: specialization is unstable | LL | default fn bar() {} | ^^^^^^^^^^^^^^^^^^^ --Ztrack-diagnostics: created at $COMPILER_DIR/rustc_session/src/parse.rs:LL:CC +-Ztrack-diagnostics: created at compiler/rustc_ast_passes/src/feature_gate.rs:LL:CC | = note: see issue #31844 for more information = help: add `#![feature(specialization)]` to the crate attributes to enable diff --git a/tests/ui/trait-bounds/apit-unsized.rs b/tests/ui/trait-bounds/apit-unsized.rs new file mode 100644 index 000000000..469d6a634 --- /dev/null +++ b/tests/ui/trait-bounds/apit-unsized.rs @@ -0,0 +1,4 @@ +fn foo(_: impl Iterator + ?Sized) {} //~ ERROR [E0277] +fn bar(_: impl ?Sized) {} //~ ERROR [E0277] + +fn main() {} diff --git a/tests/ui/trait-bounds/apit-unsized.stderr b/tests/ui/trait-bounds/apit-unsized.stderr new file mode 100644 index 000000000..0f2dc5259 --- /dev/null +++ b/tests/ui/trait-bounds/apit-unsized.stderr @@ -0,0 +1,41 @@ +error[E0277]: the size for values of type `impl Iterator + ?Sized` cannot be known at compilation time + --> $DIR/apit-unsized.rs:1:8 + | +LL | fn foo(_: impl Iterator + ?Sized) {} + | ^ ---------------------------------- this type parameter needs to be `Sized` + | | + | doesn't have a size known at compile-time + | + = help: unsized fn params are gated as an unstable feature +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - fn foo(_: impl Iterator + ?Sized) {} +LL + fn foo(_: impl Iterator) {} + | +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn foo(_: &impl Iterator + ?Sized) {} + | + + +error[E0277]: the size for values of type `impl ?Sized` cannot be known at compilation time + --> $DIR/apit-unsized.rs:2:8 + | +LL | fn bar(_: impl ?Sized) {} + | ^ ----------- this type parameter needs to be `Sized` + | | + | doesn't have a size known at compile-time + | + = help: unsized fn params are gated as an unstable feature +help: consider replacing `?Sized` with `Sized` + | +LL - fn bar(_: impl ?Sized) {} +LL + fn bar(_: impl Sized) {} + | +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn bar(_: &impl ?Sized) {} + | + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/trait-bounds/unsized-bound.stderr b/tests/ui/trait-bounds/unsized-bound.stderr index da27ba1c5..4d45bffab 100644 --- a/tests/ui/trait-bounds/unsized-bound.stderr +++ b/tests/ui/trait-bounds/unsized-bound.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = note: required because it appears within the type `(A, B)` note: required by a bound in `Trait` @@ -28,7 +28,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim LL | impl Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {} | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -43,7 +43,7 @@ error[E0277]: the size for values of type `C` cannot be known at compilation tim LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} | - ^^^^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = note: required because it appears within the type `(A, B, C)` note: required by a bound in `Trait` @@ -65,9 +65,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/unsized-bound.rs:5:52 | LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | - ^^^^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time | = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -80,9 +78,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim --> $DIR/unsized-bound.rs:5:52 | LL | impl Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {} - | - ^^^^^^^^^ doesn't have a size known at compile-time - | | - | this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ^^^^^^^^^ doesn't have a size known at compile-time | = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -97,7 +93,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim LL | impl Trait2<(A, B)> for (A, B) {} | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = note: required because it appears within the type `(A, B)` note: required by a bound in `Trait2` @@ -121,7 +117,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim LL | impl Trait2<(A, B)> for (A, B) {} | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = note: only the last element of a tuple may have a dynamically sized type help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -136,7 +132,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim LL | impl Trait3 for A where A: ?Sized {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Trait3` --> $DIR/unsized-bound.rs:13:14 @@ -159,7 +155,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim LL | impl Trait4 for A {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Trait4` --> $DIR/unsized-bound.rs:16:14 @@ -182,7 +178,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | impl Trait5 for X where X: ?Sized {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Trait5` --> $DIR/unsized-bound.rs:19:14 @@ -205,7 +201,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | impl Trait6 for X {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Trait6` --> $DIR/unsized-bound.rs:22:14 @@ -228,7 +224,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim LL | impl Trait7 for X where Y: ?Sized {} | - ^^^^^^^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Trait7` --> $DIR/unsized-bound.rs:25:17 @@ -251,7 +247,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim LL | impl Trait8 for X {} | - ^^^^^^^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Trait8` --> $DIR/unsized-bound.rs:28:17 diff --git a/tests/ui/traits/auxiliary/trivial3.rs b/tests/ui/traits/auxiliary/trivial3.rs new file mode 100644 index 000000000..0a47fdc74 --- /dev/null +++ b/tests/ui/traits/auxiliary/trivial3.rs @@ -0,0 +1 @@ +pub trait Trait {} diff --git a/tests/ui/traits/auxiliary/trivial4.rs b/tests/ui/traits/auxiliary/trivial4.rs new file mode 100644 index 000000000..a527d1a95 --- /dev/null +++ b/tests/ui/traits/auxiliary/trivial4.rs @@ -0,0 +1,3 @@ +pub trait Trait {} + +impl Trait for () {} diff --git a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr index ce9ab2d81..b1c683e47 100644 --- a/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr +++ b/tests/ui/traits/bound/assoc-fn-bound-root-obligation.stderr @@ -6,13 +6,13 @@ LL | s.strip_suffix(b'\n').unwrap_or(s) | = help: the trait `FnMut<(char,)>` is not implemented for `u8` = help: the following other types implement trait `Pattern<'a>`: + char + [char; N] &'b String &'b [char; N] &'b [char] - &'b str &'c &'b str - [char; N] - char + &'b str = note: required for `u8` to implement `Pattern<'_>` error: aborting due to previous error diff --git a/tests/ui/traits/bound/generic_trait.rs b/tests/ui/traits/bound/generic_trait.rs index 18382bb59..2484c5a88 100644 --- a/tests/ui/traits/bound/generic_trait.rs +++ b/tests/ui/traits/bound/generic_trait.rs @@ -24,7 +24,7 @@ impl connection_factory for my_connection_factory { pub fn main() { let factory = (); - let connection = factory.create(); + let connection: () = factory.create(); let result = connection.read(); assert_eq!(result, 43); } diff --git a/tests/ui/traits/cache-reached-depth-ice.rs b/tests/ui/traits/cache-reached-depth-ice.rs index c36ac0857..8c2391113 100644 --- a/tests/ui/traits/cache-reached-depth-ice.rs +++ b/tests/ui/traits/cache-reached-depth-ice.rs @@ -41,5 +41,5 @@ fn test() {} fn main() { test::(); - //~^ ERROR evaluate(Binder(TraitPredicate(, polarity:Positive), [])) = Ok(EvaluatedToOk) + //~^ ERROR evaluate(Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) } diff --git a/tests/ui/traits/cache-reached-depth-ice.stderr b/tests/ui/traits/cache-reached-depth-ice.stderr index 082aa0f5c..7cd758192 100644 --- a/tests/ui/traits/cache-reached-depth-ice.stderr +++ b/tests/ui/traits/cache-reached-depth-ice.stderr @@ -1,4 +1,4 @@ -error: evaluate(Binder(TraitPredicate(, polarity:Positive), [])) = Ok(EvaluatedToOk) +error: evaluate(Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) --> $DIR/cache-reached-depth-ice.rs:43:5 | LL | fn test() {} diff --git a/tests/ui/traits/deny-builtin-object-impl.current.stderr b/tests/ui/traits/deny-builtin-object-impl.current.stderr new file mode 100644 index 000000000..5c1987426 --- /dev/null +++ b/tests/ui/traits/deny-builtin-object-impl.current.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `dyn NotObject: NotObject` is not satisfied + --> $DIR/deny-builtin-object-impl.rs:18:23 + | +LL | test_not_object::(); + | ^^^^^^^^^^^^^ the trait `NotObject` is not implemented for `dyn NotObject` + | +note: required by a bound in `test_not_object` + --> $DIR/deny-builtin-object-impl.rs:14:23 + | +LL | fn test_not_object() {} + | ^^^^^^^^^ required by this bound in `test_not_object` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/deny-builtin-object-impl.next.stderr b/tests/ui/traits/deny-builtin-object-impl.next.stderr new file mode 100644 index 000000000..5c1987426 --- /dev/null +++ b/tests/ui/traits/deny-builtin-object-impl.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `dyn NotObject: NotObject` is not satisfied + --> $DIR/deny-builtin-object-impl.rs:18:23 + | +LL | test_not_object::(); + | ^^^^^^^^^^^^^ the trait `NotObject` is not implemented for `dyn NotObject` + | +note: required by a bound in `test_not_object` + --> $DIR/deny-builtin-object-impl.rs:14:23 + | +LL | fn test_not_object() {} + | ^^^^^^^^^ required by this bound in `test_not_object` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/deny-builtin-object-impl.rs b/tests/ui/traits/deny-builtin-object-impl.rs new file mode 100644 index 000000000..dce03a43b --- /dev/null +++ b/tests/ui/traits/deny-builtin-object-impl.rs @@ -0,0 +1,20 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + +#![feature(rustc_attrs)] + +#[rustc_deny_explicit_impl(implement_via_object = true)] +trait YesObject {} + +#[rustc_deny_explicit_impl(implement_via_object = false)] +trait NotObject {} + +fn test_yes_object() {} + +fn test_not_object() {} + +fn main() { + test_yes_object::(); + test_not_object::(); + //~^ ERROR the trait bound `dyn NotObject: NotObject` is not satisfied +} diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.rs b/tests/ui/traits/ice-with-dyn-pointee-errors.rs new file mode 100644 index 000000000..46cef2c8b --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee-errors.rs @@ -0,0 +1,15 @@ +#![feature(ptr_metadata)] +// Address issue #112737 -- ICE with dyn Pointee +extern crate core; +use core::ptr::Pointee; + +fn unknown_sized_object_ptr_in(_: &(impl Pointee + ?Sized)) {} + +fn raw_pointer_in(x: &dyn Pointee) { + unknown_sized_object_ptr_in(x) + //~^ ERROR type mismatch resolving ` as Pointee>::Metadata == ()` +} + +fn main() { + raw_pointer_in(&42) +} diff --git a/tests/ui/traits/ice-with-dyn-pointee-errors.stderr b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr new file mode 100644 index 000000000..8ad11c334 --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee-errors.stderr @@ -0,0 +1,19 @@ +error[E0271]: type mismatch resolving ` as Pointee>::Metadata == ()` + --> $DIR/ice-with-dyn-pointee-errors.rs:9:33 + | +LL | unknown_sized_object_ptr_in(x) + | --------------------------- ^ expected `()`, found `DynMetadata>` + | | + | required by a bound introduced by this call + | + = note: expected unit type `()` + found struct `DynMetadata>` +note: required by a bound in `unknown_sized_object_ptr_in` + --> $DIR/ice-with-dyn-pointee-errors.rs:6:50 + | +LL | fn unknown_sized_object_ptr_in(_: &(impl Pointee + ?Sized)) {} + | ^^^^^^^^^^^^^ required by this bound in `unknown_sized_object_ptr_in` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/ice-with-dyn-pointee.rs b/tests/ui/traits/ice-with-dyn-pointee.rs new file mode 100644 index 000000000..9b3b9c8cd --- /dev/null +++ b/tests/ui/traits/ice-with-dyn-pointee.rs @@ -0,0 +1,11 @@ +// run-pass +#![feature(ptr_metadata)] +// Address issue #112737 -- ICE with dyn Pointee +extern crate core; +use core::ptr::Pointee; + +fn raw_pointer_in(_: &dyn Pointee) {} + +fn main() { + raw_pointer_in(&42) +} diff --git a/tests/ui/traits/issue-105231.rs b/tests/ui/traits/issue-105231.rs new file mode 100644 index 000000000..74c7afd6b --- /dev/null +++ b/tests/ui/traits/issue-105231.rs @@ -0,0 +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 {} +impl Foo for B {} + +fn main() {} diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr new file mode 100644 index 000000000..fe20c47c5 --- /dev/null +++ b/tests/ui/traits/issue-105231.stderr @@ -0,0 +1,29 @@ +error[E0072]: recursive types `A` and `B` have infinite size + --> $DIR/issue-105231.rs:2:1 + | +LL | struct A(B); + | ^^^^^^^^^^^ ---- recursive without indirection +LL | +LL | struct B(A>); + | ^^^^^^^^^^^ ------- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL ~ struct A(Box>); +LL | +LL ~ struct B(Box>>); + | + +error[E0275]: overflow evaluating the requirement `A>>>>>>: 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 + | +LL | struct B(A>); + | ^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0072, E0275. +For more information about an error, try `rustc --explain E0072`. diff --git a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs index 3cd68ff6f..5136aef4f 100644 --- a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs +++ b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.rs @@ -57,10 +57,10 @@ fn main() { // Key is that Vec is "ok" and Third<'_, Ty> is "ok modulo regions": forward(); - //~^ ERROR evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk) - //~| ERROR evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) + //~^ ERROR evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) + //~| ERROR evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) reverse(); - //~^ ERROR evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk) - //~| ERROR evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) + //~^ ERROR evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) + //~| ERROR evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) } diff --git a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr index 7c4041144..96baec76a 100644 --- a/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr +++ b/tests/ui/traits/issue-83538-tainted-cache-after-cycle.stderr @@ -1,4 +1,4 @@ -error: evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk) +error: evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) --> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5 | LL | Vec: Unpin, @@ -7,7 +7,7 @@ LL | Vec: Unpin, LL | forward(); | ^^^^^^^ -error: evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) +error: evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) --> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5 | LL | Third<'a, Ty>: Unpin, @@ -16,7 +16,7 @@ LL | Third<'a, Ty>: Unpin, LL | forward(); | ^^^^^^^ -error: evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) +error: evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) --> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5 | LL | Third<'a, Ty>: Unpin, @@ -25,7 +25,7 @@ LL | Third<'a, Ty>: Unpin, LL | reverse(); | ^^^^^^^ -error: evaluate(Binder(TraitPredicate( as std::marker::Unpin>, polarity:Positive), [])) = Ok(EvaluatedToOk) +error: evaluate(Binder { value: TraitPredicate( as std::marker::Unpin>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) --> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5 | LL | Vec: Unpin, diff --git a/tests/ui/traits/issue-85360-eval-obligation-ice.rs b/tests/ui/traits/issue-85360-eval-obligation-ice.rs index 19131684a..ac8bda9c0 100644 --- a/tests/ui/traits/issue-85360-eval-obligation-ice.rs +++ b/tests/ui/traits/issue-85360-eval-obligation-ice.rs @@ -7,12 +7,12 @@ use core::marker::PhantomData; fn main() { test::>>(make()); - //~^ ERROR evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) - //~| ERROR evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) + //~^ ERROR evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) + //~| ERROR evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) test::>>(make()); - //~^ ERROR evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) - //~| ERROR evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) + //~^ ERROR evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) + //~| ERROR evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) } #[rustc_evaluate_where_clauses] diff --git a/tests/ui/traits/issue-85360-eval-obligation-ice.stderr b/tests/ui/traits/issue-85360-eval-obligation-ice.stderr index ebf977dd6..9590ea12c 100644 --- a/tests/ui/traits/issue-85360-eval-obligation-ice.stderr +++ b/tests/ui/traits/issue-85360-eval-obligation-ice.stderr @@ -1,4 +1,4 @@ -error: evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) +error: evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) --> $DIR/issue-85360-eval-obligation-ice.rs:9:5 | LL | test::>>(make()); @@ -7,7 +7,7 @@ LL | test::>>(make()); LL | fn test(_: T) {} | - predicate -error: evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOk) +error: evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) --> $DIR/issue-85360-eval-obligation-ice.rs:9:5 | LL | test::>>(make()); @@ -16,7 +16,7 @@ LL | test::>>(make()); LL | fn test(_: T) {} | ----- predicate -error: evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) +error: evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) --> $DIR/issue-85360-eval-obligation-ice.rs:13:5 | LL | test::>>(make()); @@ -25,7 +25,7 @@ LL | test::>>(make()); LL | fn test(_: T) {} | - predicate -error: evaluate(Binder(TraitPredicate(> as std::marker::Sized>, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) +error: evaluate(Binder { value: TraitPredicate(> as std::marker::Sized>, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) --> $DIR/issue-85360-eval-obligation-ice.rs:13:5 | LL | test::>>(make()); diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.rs b/tests/ui/traits/issue-91949-hangs-on-recursion.rs index 4eca643a9..312d5d08c 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.rs +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.rs @@ -3,6 +3,7 @@ // error-pattern: overflow evaluating the requirement ` as Iterator>::Item == ()` // error-pattern: function cannot return without recursing // normalize-stderr-test: "long-type-\d+" -> "long-type-hash" +// ignore-compare-mode-next-solver (hangs) // Regression test for #91949. // This hanged *forever* on 1.56, fixed by #90423. diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index 144990d50..c721dd41a 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -1,5 +1,5 @@ warning: function cannot return without recursing - --> $DIR/issue-91949-hangs-on-recursion.rs:23:1 + --> $DIR/issue-91949-hangs-on-recursion.rs:24:1 | LL | / fn recurse(elements: T) -> Vec LL | | where @@ -16,7 +16,7 @@ error[E0275]: overflow evaluating the requirement ` as Iter | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) note: required for `IteratorOfWrapped<(), std::iter::Empty<()>>` to implement `Iterator` - --> $DIR/issue-91949-hangs-on-recursion.rs:16:32 + --> $DIR/issue-91949-hangs-on-recursion.rs:17:32 | LL | impl> Iterator for IteratorOfWrapped { | -------- ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.rs b/tests/ui/traits/new-solver/alias-bound-unsound.rs index 00294c708..959f1afa0 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.rs +++ b/tests/ui/traits/new-solver/alias-bound-unsound.rs @@ -21,7 +21,7 @@ impl Foo for () { fn main() { let x = String::from("hello, world"); drop(<() as Foo>::copy_me(&x)); - //~^ ERROR `<() as Foo>::Item: Copy` is not satisfied + //~^ ERROR the type `&<() as Foo>::Item` is not well-formed //~| ERROR `<() as Foo>::Item` is not well-formed 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 9a43d2a66..5800e2c43 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/new-solver/alias-bound-unsound.stderr @@ -1,17 +1,8 @@ -error[E0277]: the trait bound `<() as Foo>::Item: Copy` is not satisfied - --> $DIR/alias-bound-unsound.rs:23:10 +error: the type `&<() as Foo>::Item` is not well-formed + --> $DIR/alias-bound-unsound.rs:23:31 | LL | drop(<() as Foo>::copy_me(&x)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `<() as Foo>::Item` - | -note: required by a bound in `Foo::Item` - --> $DIR/alias-bound-unsound.rs:10:30 - | -LL | type Item: Copy - | ---- required by a bound in this associated type -LL | where -LL | ::Item: Copy; - | ^^^^ required by this bound in `Foo::Item` + | ^^ error: the type `<() as Foo>::Item` is not well-formed --> $DIR/alias-bound-unsound.rs:23:10 @@ -21,4 +12,3 @@ LL | drop(<() as Foo>::copy_me(&x)); error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs index b036411be..204f6e8b0 100644 --- a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs +++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs @@ -1,22 +1,17 @@ // compile-flags: -Ztrait-solver=next -// check-pass -// (should not pass, should be turned into a coherence-only test) - -// check that a `alias-eq(::Assoc, ::Assoc)` goal fails. - -// FIXME(deferred_projection_equality): add a test that this is true during coherence +// check that a `alias-eq(::Assoc, ::Assoc)` goal fails +// during coherence. We must not incorrectly constrain `?a` and `?b` to be +// equal. trait TraitB { type Assoc; } -fn needs_a() -> T::Assoc { - unimplemented!() -} +trait Overlaps {} -fn bar() { - let _: <_ as TraitB>::Assoc = needs_a::(); -} +impl Overlaps> for ::Assoc {} +impl Overlaps for ::Assoc {} +//~^ ERROR conflicting implementations of trait fn main() {} diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr new file mode 100644 index 000000000..8eda64e44 --- /dev/null +++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `Overlaps>` for type `<_ as TraitB>::Assoc` + --> $DIR/alias_eq_substs_eq_not_intercrate.rs:14:1 + | +LL | impl Overlaps> for ::Assoc {} + | --------------------------------------------------------- first implementation here +LL | impl Overlaps for ::Assoc {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as TraitB>::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/array-default.rs b/tests/ui/traits/new-solver/array-default.rs new file mode 100644 index 000000000..5077137b0 --- /dev/null +++ b/tests/ui/traits/new-solver/array-default.rs @@ -0,0 +1,8 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn has_default() where [(); N]: Default {} + +fn main() { + has_default::<1>(); +} diff --git a/tests/ui/traits/new-solver/async.fail.stderr b/tests/ui/traits/new-solver/async.fail.stderr index b395c23ae..72fa2eb31 100644 --- a/tests/ui/traits/new-solver/async.fail.stderr +++ b/tests/ui/traits/new-solver/async.fail.stderr @@ -1,8 +1,8 @@ -error[E0271]: expected `[async block@$DIR/async.rs:12:17: 12:25]` to be a future that resolves to `i32`, but it resolves to `()` +error[E0271]: type mismatch resolving `<[async block@$DIR/async.rs:12:17: 12:25] as Future>::Output == i32` --> $DIR/async.rs:12:17 | LL | needs_async(async {}); - | ----------- ^^^^^^^^ expected `i32`, found `()` + | ----------- ^^^^^^^^ types differ | | | required by a bound introduced by this call | diff --git a/tests/ui/traits/new-solver/async.rs b/tests/ui/traits/new-solver/async.rs index 195cc35ca..155b71eb7 100644 --- a/tests/ui/traits/new-solver/async.rs +++ b/tests/ui/traits/new-solver/async.rs @@ -10,7 +10,7 @@ fn needs_async(_: impl Future) {} #[cfg(fail)] fn main() { needs_async(async {}); - //[fail]~^ ERROR to be a future that resolves to `i32`, but it resolves to `()` + //[fail]~^ ERROR type mismatch } #[cfg(pass)] diff --git a/tests/ui/traits/new-solver/closure-substs-ambiguity.rs b/tests/ui/traits/new-solver/closure-substs-ambiguity.rs new file mode 100644 index 000000000..48432f402 --- /dev/null +++ b/tests/ui/traits/new-solver/closure-substs-ambiguity.rs @@ -0,0 +1,7 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn main() { + let mut x: Vec<_> = vec![]; + x.extend(Some(1i32).into_iter().map(|x| x)); +} diff --git a/tests/ui/traits/new-solver/dedup-regions.rs b/tests/ui/traits/new-solver/dedup-regions.rs new file mode 100644 index 000000000..f376f39a5 --- /dev/null +++ b/tests/ui/traits/new-solver/dedup-regions.rs @@ -0,0 +1,31 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +struct A(*mut ()); + +unsafe impl Send for A where A: 'static {} + +macro_rules! mk { + ($name:ident $ty:ty) => { + struct $name($ty, $ty, $ty, $ty, $ty, $ty, $ty, $ty, $ty, $ty); + }; +} + +mk!(B A); +mk!(C B); +mk!(D C); +mk!(E D); +mk!(F E); +mk!(G F); +mk!(H G); +mk!(I H); +mk!(J I); +mk!(K J); +mk!(L K); +mk!(M L); + +fn needs_send() {} + +fn main() { + needs_send::(); +} diff --git a/tests/ui/traits/new-solver/dont-remap-tait-substs.rs b/tests/ui/traits/new-solver/dont-remap-tait-substs.rs new file mode 100644 index 000000000..309bee8aa --- /dev/null +++ b/tests/ui/traits/new-solver/dont-remap-tait-substs.rs @@ -0,0 +1,19 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// Makes sure we don't prepopulate the MIR typeck of `define` +// with `Foo = T`, but instead, `Foo = B`, so that +// the param-env predicates actually apply. + +#![feature(type_alias_impl_trait)] + +type Foo = impl NeedsSend; + +trait NeedsSend {} +impl NeedsSend for T {} + +fn define(a: A, b: B, _: Foo) { + let y: Option> = Some(b); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr new file mode 100644 index 000000000..ec1c3231a --- /dev/null +++ b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.not_send.stderr @@ -0,0 +1,16 @@ +error[E0283]: type annotations needed: cannot satisfy `Foo: Send` + --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:5 + | +LL | needs_send::(); + | ^^^^^^^^^^^^^^^^^ + | + = note: cannot satisfy `Foo: Send` +note: required by a bound in `needs_send` + --> $DIR/dont-type_of-tait-in-defining-scope.rs:13:18 + | +LL | fn needs_send() {} + | ^^^^ required by this bound in `needs_send` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs new file mode 100644 index 000000000..08f14d749 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-type_of-tait-in-defining-scope.rs @@ -0,0 +1,24 @@ +// revisions: is_send not_send +// compile-flags: -Ztrait-solver=next +//[is_send] check-pass + +#![feature(type_alias_impl_trait)] + +#[cfg(is_send)] +type Foo = impl Send; + +#[cfg(not_send)] +type Foo = impl Sized; + +fn needs_send() {} + +fn test(_: Foo) { + needs_send::(); + //[not_send]~^ ERROR type annotations needed: cannot satisfy `Foo: Send` +} + +fn defines(_: Foo) { + let _: Foo = (); +} + +fn main() {} 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 new file mode 100644 index 000000000..7d15b8c63 --- /dev/null +++ b/tests/ui/traits/new-solver/dyn-any-dont-prefer-impl.rs @@ -0,0 +1,13 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +use std::any::Any; + +fn needs_usize(_: &usize) {} + +fn main() { + let x: &dyn Any = &1usize; + if let Some(x) = x.downcast_ref::() { + needs_usize(x); + } +} diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.rs b/tests/ui/traits/new-solver/equating-projection-cyclically.rs index 019c6e81c..2668da1b7 100644 --- a/tests/ui/traits/new-solver/equating-projection-cyclically.rs +++ b/tests/ui/traits/new-solver/equating-projection-cyclically.rs @@ -1,11 +1,10 @@ // compile-flags: -Ztrait-solver=next -// known-bug: unknown trait Test { type Assoc; } -fn transform(x: T) -> T::Assoc { +fn transform(x: Inv) -> Inv { todo!() } @@ -17,8 +16,13 @@ impl Test for String { type Assoc = String; } +struct Inv(Option<*mut T>); + fn main() { - let mut x = Default::default(); + let mut x: Inv<_> = Inv(None); + // This ends up equating `Inv` with `Inv<::Assoc>` + // which fails the occurs check when generalizing `?x`. x = transform(x); - x = 1i32; + //~^ ERROR mismatched types + x = Inv::(None); } diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.stderr b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr index 57cbc65a1..6031d4f08 100644 --- a/tests/ui/traits/new-solver/equating-projection-cyclically.stderr +++ b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr @@ -1,13 +1,8 @@ error[E0308]: mismatched types - --> $DIR/equating-projection-cyclically.rs:22:19 + --> $DIR/equating-projection-cyclically.rs:25:9 | LL | x = transform(x); - | ^ expected inferred type, found associated type - | - = note: expected type `_` - found associated type `<_ as Test>::Assoc` - = help: consider constraining the associated type `<_ as Test>::Assoc` to `_` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + | ^^^^^^^^^^^^ cyclic type of infinite size error: aborting due to previous error diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs index 32addd829..fd91d81cd 100644 --- a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs @@ -1,6 +1,5 @@ -// check-pass // compile-flags: -Ztrait-solver=next -// Issue 95863 +// known-bug: #95863 pub trait With { type F; diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr new file mode 100644 index 000000000..d0a4cd661 --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/lazy-nested-obligations-2.rs:15:23 + | +LL | let _: V = V(f); + | - ^ types differ + | | + | arguments to this struct are incorrect + | + = note: expected associated type `::F` + found fn item `for<'a> fn(&'a str) {f}` + = help: consider constraining the associated type `::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `::F` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: tuple struct defined here + --> $DIR/lazy-nested-obligations-2.rs:16:16 + | +LL | pub struct V(::F); + | ^ + +error[E0308]: mismatched types + --> $DIR/lazy-nested-obligations-2.rs:21:30 + | +LL | let _: E3 = E3::Var(f); + | ------- ^ types differ + | | + | arguments to this enum variant are incorrect + | + = note: expected associated type `::F` + found fn item `for<'a> fn(&'a str) {f}` + = help: consider constraining the associated type `::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `::F` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: tuple variant defined here + --> $DIR/lazy-nested-obligations-2.rs:19:9 + | +LL | Var(::F), + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs b/tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs new file mode 100644 index 000000000..1f7d4a49c --- /dev/null +++ b/tests/ui/traits/new-solver/leak-check-coinductive-cycle.rs @@ -0,0 +1,33 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +#![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/member-constraints-in-root-universe.rs b/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs new file mode 100644 index 000000000..97c443058 --- /dev/null +++ b/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs @@ -0,0 +1,17 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Trait { + type Ty; +} + +impl Trait for for<'a> fn(&'a u8, &'a u8) { + type Ty = (); +} + +// argument is necessary to create universes before registering the hidden type. +fn test<'a>(_: ::Ty) -> impl Sized { + "hidden type is `&'?0 str` with '?0 member of ['static,]" +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalized-const-built-in-op.rs b/tests/ui/traits/new-solver/normalized-const-built-in-op.rs new file mode 100644 index 000000000..2443e5178 --- /dev/null +++ b/tests/ui/traits/new-solver/normalized-const-built-in-op.rs @@ -0,0 +1,11 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +const fn foo() { + let mut x = [1, 2, 3]; + // We need to fix up `<<[i32; 3] as Index>::Output as AddAssign>` + // to be treated like a built-in operation. + x[1] += 5; +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/object-unsafety.rs b/tests/ui/traits/new-solver/object-unsafety.rs index 7bdd863a7..da843c914 100644 --- a/tests/ui/traits/new-solver/object-unsafety.rs +++ b/tests/ui/traits/new-solver/object-unsafety.rs @@ -10,7 +10,15 @@ fn copy(from: &U::From) -> U::From { pub fn copy_any(t: &T) -> T { copy::>(t) - //~^ ERROR the trait bound `dyn Setup: Setup` is not satisfied + //~^ ERROR the type `& as Setup>::From` is not well-formed + //~| ERROR the trait bound `dyn Setup: Setup` is not satisfied + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR the type ` as Setup>::From` is not well-formed + //~| ERROR the size for values of type ` as Setup>::From` cannot be known at compilation time + + // FIXME(-Ztrait-solver=next): These error messages are horrible and some of them + // are even simple fallout from previous error. } fn main() { diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/new-solver/object-unsafety.stderr index 198ac623d..bb7c68b89 100644 --- a/tests/ui/traits/new-solver/object-unsafety.stderr +++ b/tests/ui/traits/new-solver/object-unsafety.stderr @@ -14,6 +14,65 @@ help: consider introducing a `where` clause, but there might be an alternative b LL | pub fn copy_any(t: &T) -> T where dyn Setup: Setup { | ++++++++++++++++++++++++++++++++ -error: aborting due to previous error +error: the type `& as Setup>::From` is not well-formed + --> $DIR/object-unsafety.rs:12:31 + | +LL | copy::>(t) + | ^ + +error[E0308]: mismatched types + --> $DIR/object-unsafety.rs:12:31 + | +LL | copy::>(t) + | ------------------------- ^ types differ + | | + | arguments to this function are incorrect + | + = note: expected reference `& as Setup>::From` + found reference `&T` +note: function defined here + --> $DIR/object-unsafety.rs:7:4 + | +LL | fn copy(from: &U::From) -> U::From { + | ^^^^ -------------- + +error[E0308]: mismatched types + --> $DIR/object-unsafety.rs:12:5 + | +LL | pub fn copy_any(t: &T) -> T { + | - - expected `T` because of return type + | | + | this type parameter +LL | copy::>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + | + = note: expected type parameter `T` + found associated type ` as Setup>::From` + = note: you might be missing a type parameter or trait bound + +error: the type ` as Setup>::From` is not well-formed + --> $DIR/object-unsafety.rs:12:5 + | +LL | copy::>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type ` as Setup>::From` cannot be known at compilation time + --> $DIR/object-unsafety.rs:12:5 + | +LL | copy::>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^--- + | | + | doesn't have a size known at compile-time + | this returned value is of type ` as Setup>::From` + | + = help: the trait `Sized` is not implemented for ` as Setup>::From` + = note: the return type of a function must have a statically known size +help: consider further restricting the associated type + | +LL | pub fn copy_any(t: &T) -> T where as Setup>::From: Sized { + | +++++++++++++++++++++++++++++++++++++++++++++++++ + +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/opportunistic-region-resolve.rs b/tests/ui/traits/new-solver/opportunistic-region-resolve.rs new file mode 100644 index 000000000..2610789cd --- /dev/null +++ b/tests/ui/traits/new-solver/opportunistic-region-resolve.rs @@ -0,0 +1,19 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(rustc_attrs)] + +#[rustc_coinductive] +trait Trait {} + +#[rustc_coinductive] +trait Indirect {} +impl Indirect for T {} + +impl<'a> Trait for &'a () where &'a (): Indirect {} + +fn impls_trait() {} + +fn main() { + impls_trait::<&'static ()>(); +} diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs index 8c029f517..d086db475 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs @@ -1,3 +1,4 @@ +//~ ERROR overflow // compile-flags: -Ztrait-solver=next trait Foo1 { diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr index 139b0a456..eebaf21d7 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr @@ -1,16 +1,20 @@ error[E0275]: overflow evaluating the requirement `::Assoc1: Bar` - --> $DIR/recursive-self-normalization-2.rs:15:5 + --> $DIR/recursive-self-normalization-2.rs:16:5 | LL | needs_bar::(); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) note: required by a bound in `needs_bar` - --> $DIR/recursive-self-normalization-2.rs:12:17 + --> $DIR/recursive-self-normalization-2.rs:13:17 | LL | fn needs_bar() {} | ^^^ required by this bound in `needs_bar` -error: aborting due to previous error +error[E0275]: overflow evaluating the requirement `::Assoc2` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) + +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/recursive-self-normalization.rs b/tests/ui/traits/new-solver/recursive-self-normalization.rs index 06d187b5f..d15df7dea 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization.rs +++ b/tests/ui/traits/new-solver/recursive-self-normalization.rs @@ -1,3 +1,4 @@ +//~ ERROR overflow evaluating the requirement `::Assoc` [E0275] // compile-flags: -Ztrait-solver=next trait Foo { diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/recursive-self-normalization.stderr index 8e9b9b4b4..6a87fe2f1 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization.stderr +++ b/tests/ui/traits/new-solver/recursive-self-normalization.stderr @@ -1,16 +1,20 @@ error[E0275]: overflow evaluating the requirement `::Assoc: Bar` - --> $DIR/recursive-self-normalization.rs:11:5 + --> $DIR/recursive-self-normalization.rs:12:5 | LL | needs_bar::(); | ^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) note: required by a bound in `needs_bar` - --> $DIR/recursive-self-normalization.rs:8:17 + --> $DIR/recursive-self-normalization.rs:9:17 | LL | fn needs_bar() {} | ^^^ required by this bound in `needs_bar` -error: aborting due to previous error +error[E0275]: overflow evaluating the requirement `::Assoc` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) + +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/slice-match-byte-lit.rs b/tests/ui/traits/new-solver/slice-match-byte-lit.rs new file mode 100644 index 000000000..4f8480625 --- /dev/null +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.rs @@ -0,0 +1,11 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn test(s: &[u8]) { + match &s[0..3] { + b"uwu" => {} + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/specialization-transmute.rs b/tests/ui/traits/new-solver/specialization-transmute.rs index a54701df4..f6b19e7ad 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.rs +++ b/tests/ui/traits/new-solver/specialization-transmute.rs @@ -10,12 +10,11 @@ trait Default { } impl Default for T { - default type Id = T; - - fn intu(&self) -> &Self::Id { + default type Id = T; + // This will be fixed by #111994 + fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed self - //~^ ERROR cannot satisfy `T <: ::Id` - } + } } fn transmute, U: Copy>(t: T) -> U { @@ -24,7 +23,6 @@ fn transmute, U: Copy>(t: T) -> U { use std::num::NonZeroU8; fn main() { - let s = transmute::>(0); - //~^ ERROR cannot satisfy `::Id == Option + let s = transmute::>(0); // this call should then error assert_eq!(s, None); } diff --git a/tests/ui/traits/new-solver/specialization-transmute.stderr b/tests/ui/traits/new-solver/specialization-transmute.stderr index e67c56afc..09b1405fe 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.stderr +++ b/tests/ui/traits/new-solver/specialization-transmute.stderr @@ -8,24 +8,14 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0284]: type annotations needed: cannot satisfy `T <: ::Id` - --> $DIR/specialization-transmute.rs:16:9 +error[E0284]: type annotations needed + --> $DIR/specialization-transmute.rs:15:23 | -LL | self - | ^^^^ cannot satisfy `T <: ::Id` - -error[E0284]: type annotations needed: cannot satisfy `::Id == Option` - --> $DIR/specialization-transmute.rs:27:13 - | -LL | let s = transmute::>(0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `::Id == Option` - | -note: required by a bound in `transmute` - --> $DIR/specialization-transmute.rs:21:25 +LL | fn intu(&self) -> &Self::Id { + | ^^^^^^^^^ cannot infer type | -LL | fn transmute, U: Copy>(t: T) -> U { - | ^^^^^^ required by this bound in `transmute` + = note: cannot satisfy `::Id == _` -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.rs b/tests/ui/traits/new-solver/specialization-unconstrained.rs index 02150689e..7fd753109 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.rs +++ b/tests/ui/traits/new-solver/specialization-unconstrained.rs @@ -11,7 +11,7 @@ trait Default { } impl Default for T { - default type Id = T; + default type Id = T; //~ ERROR type annotations needed } fn test, U>() {} diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/new-solver/specialization-unconstrained.stderr index 910925cba..9915da1a2 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.stderr +++ b/tests/ui/traits/new-solver/specialization-unconstrained.stderr @@ -8,6 +8,12 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default +error[E0282]: type annotations needed + --> $DIR/specialization-unconstrained.rs:14:22 + | +LL | default type Id = T; + | ^ cannot infer type for associated type `::Id` + error[E0284]: type annotations needed: cannot satisfy `::Id == ()` --> $DIR/specialization-unconstrained.rs:20:5 | @@ -20,6 +26,7 @@ note: required by a bound in `test` LL | fn test, U>() {} | ^^^^^^ required by this bound in `test` -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 E0284`. +Some errors have detailed explanations: E0282, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/tait-eq-proj-2.rs b/tests/ui/traits/new-solver/tait-eq-proj-2.rs new file mode 100644 index 000000000..77ea8bc24 --- /dev/null +++ b/tests/ui/traits/new-solver/tait-eq-proj-2.rs @@ -0,0 +1,23 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(type_alias_impl_trait)] + +// Similar to tests/ui/traits/new-solver/tait-eq-proj.rs +// but check the alias-sub relation in the other direction. + +type Tait = impl Iterator; + +fn mk() -> T { + todo!() +} + +fn a(_: Tait) { + let x: Tait = mk(); + let mut array = mk(); + let mut z = IntoIterator::into_iter(array); + z = x; + array = [0i32; 32]; +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/tait-eq-proj.rs b/tests/ui/traits/new-solver/tait-eq-proj.rs new file mode 100644 index 000000000..01ef2ec95 --- /dev/null +++ b/tests/ui/traits/new-solver/tait-eq-proj.rs @@ -0,0 +1,35 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(type_alias_impl_trait)] + +type Tait = impl Iterator; + +/* + +Consider the goal - AliasRelate(Tait, <[i32; 32] as IntoIterator>::IntoIter) +which is registered on the line above. + +A. SubstRelate - fails (of course). + +B. NormalizesToRhs - Tait normalizes-to <[i32; 32] as IntoIterator>::IntoIter + * infer definition - Tait := <[i32; 32] as IntoIterator>::IntoIter + +C. NormalizesToLhs - <[i32; 32] as IntoIterator>::IntoIter normalizes-to Tait + * Find impl candidate, after substitute - std::array::IntoIter + * Equate std::array::IntoIter and Tait + * infer definition - Tait := std::array::IntoIter + +B and C are not equal, but they are equivalent modulo normalization. + +We get around this by evaluating both the NormalizesToRhs and NormalizesToLhs +goals together. Essentially: + A alias-relate B if A normalizes-to B and B normalizes-to A. + +*/ + +fn a(_: Tait) { + let _: Tait = IntoIterator::into_iter([0i32; 32]); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/tait-eq-tait.rs b/tests/ui/traits/new-solver/tait-eq-tait.rs new file mode 100644 index 000000000..70d9dc0ea --- /dev/null +++ b/tests/ui/traits/new-solver/tait-eq-tait.rs @@ -0,0 +1,18 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +// Not exactly sure if this is the inference behavior we *want*, +// but it is a side-effect of the lazy normalization of TAITs. + +#![feature(type_alias_impl_trait)] + +fn mk() -> T { + todo!() +} + +fn main() { + type Tait = impl Sized; + type Tait2 = impl Sized; + let x: Tait = 1u32; + let y: Tait2 = x; +} diff --git a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr index fa5e780ee..83a0452b0 100644 --- a/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr +++ b/tests/ui/traits/new-solver/two-projection-param-candidates-are-ambiguous.stderr @@ -5,6 +5,7 @@ LL | needs_bar::(); | ^^^^^^^^^^^^^^ | = note: cannot satisfy `T: Bar` + = help: the trait `Bar` is implemented for `T` note: required by a bound in `needs_bar` --> $DIR/two-projection-param-candidates-are-ambiguous.rs:23:17 | diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr new file mode 100644 index 000000000..072ac32a5 --- /dev/null +++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `(): Trait<1>` is not satisfied + --> $DIR/unevaluated-const-impl-trait-ref.rs:20:13 + | +LL | needs::<1>(); + | ^ the trait `Trait<1>` is not implemented for `()` + | + = help: the following other types implement trait `Trait`: + <() as Trait<0>> + <() as Trait<2>> +note: required by a bound in `needs` + --> $DIR/unevaluated-const-impl-trait-ref.rs:10:38 + | +LL | fn needs() where (): Trait {} + | ^^^^^^^^ required by this bound in `needs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs new file mode 100644 index 000000000..26c595bc9 --- /dev/null +++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next +// revisions: works fails +//[works] check-pass + +trait Trait {} + +impl Trait<{ 1 - 1 }> for () {} +impl Trait<{ 1 + 1 }> for () {} + +fn needs() where (): Trait {} + +#[cfg(works)] +fn main() { + needs::<0>(); + needs::<2>(); +} + +#[cfg(fails)] +fn main() { + needs::<1>(); + //[fails]~^ ERROR the trait bound `(): Trait<1>` is not satisfied +} diff --git a/tests/ui/traits/new-solver/winnow-specializing-impls.rs b/tests/ui/traits/new-solver/winnow-specializing-impls.rs new file mode 100644 index 000000000..06f64de74 --- /dev/null +++ b/tests/ui/traits/new-solver/winnow-specializing-impls.rs @@ -0,0 +1,22 @@ +// build-pass +// compile-flags: -Ztrait-solver=next + +// Tests that the specializing impl `<() as Foo>` holds during codegen. + +#![feature(min_specialization)] + +trait Foo { + fn bar(); +} + +impl Foo for T { + default fn bar() {} +} + +impl Foo for () { + fn bar() {} +} + +fn main() { + <() as Foo>::bar(); +} diff --git a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs new file mode 100644 index 000000000..96a7424f0 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.rs @@ -0,0 +1,12 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +fn auto_trait() +where + for T: PartialEq + PartialOrd, +{} + +fn main() { + auto_trait(); + //~^ ERROR can't compare `T` with `T` +} diff --git a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr new file mode 100644 index 000000000..da09343fb --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr @@ -0,0 +1,28 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/foreach-partial-eq.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: can't compare `T` with `T` + --> $DIR/foreach-partial-eq.rs:10:5 + | +LL | auto_trait(); + | ^^^^^^^^^^ no implementation for `T < T` and `T > T` + | + = help: the trait `PartialOrd` is not implemented for `T` +note: required by a bound in `auto_trait` + --> $DIR/foreach-partial-eq.rs:6:27 + | +LL | fn auto_trait() + | ---------- required by a bound in this function +LL | where +LL | for T: PartialEq + PartialOrd, + | ^^^^^^^^^^ required by this bound in `auto_trait` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs new file mode 100644 index 000000000..e9ae00df7 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.rs @@ -0,0 +1,11 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +trait Trait { + type Assoc; +} + +fn uwu(_: impl for Trait<(), Assoc = impl Trait>) {} +//~^ ERROR `impl Trait` can only mention type parameters from an fn or impl + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr new file mode 100644 index 000000000..1124076c2 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/nested-apit-mentioning-outer-bound-var.stderr @@ -0,0 +1,17 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/nested-apit-mentioning-outer-bound-var.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: `impl Trait` can only mention type parameters from an fn or impl + --> $DIR/nested-apit-mentioning-outer-bound-var.rs:8:52 + | +LL | fn uwu(_: impl for Trait<(), Assoc = impl Trait>) {} + | - type parameter declared here ^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/traits/object/print_vtable_sizes.rs b/tests/ui/traits/object/print_vtable_sizes.rs new file mode 100644 index 000000000..565609499 --- /dev/null +++ b/tests/ui/traits/object/print_vtable_sizes.rs @@ -0,0 +1,61 @@ +// check-pass +// compile-flags: -Z print-vtable-sizes +#![crate_type = "lib"] + +trait A: AsRef<[T::V]> + AsMut<[T::V]> {} + +trait B: AsRef + AsRef + AsRef + AsRef {} + +trait C { + fn x() {} // not object safe, shouldn't be reported +} + +// This ideally should not have any upcasting cost, +// but currently does due to a bug +trait D: Send + Sync + help::MarkerWithSuper {} + +// This can't have no cost without reordering, +// because `Super::f`. +trait E: help::MarkerWithSuper + Send + Sync {} + +trait F { + fn a(&self); + fn b(&self); + fn c(&self); + + fn d() -> Self + where + Self: Sized; +} + +trait G: AsRef + AsRef + help::MarkerWithSuper { + fn a(&self); + fn b(&self); + fn c(&self); + fn d(&self); + fn e(&self); + + fn f() -> Self + where + Self: Sized; +} + +// Traits with the same name +const _: () = { + trait S {} +}; +const _: () = { + trait S {} +}; + +mod help { + pub trait V { + type V; + } + + pub trait MarkerWithSuper: Super {} + + pub trait Super { + fn f(&self); + } +} diff --git a/tests/ui/traits/object/print_vtable_sizes.stdout b/tests/ui/traits/object/print_vtable_sizes.stdout new file mode 100644 index 000000000..3ba650bc3 --- /dev/null +++ b/tests/ui/traits/object/print_vtable_sizes.stdout @@ -0,0 +1,11 @@ +print-vtable-sizes { "crate_name": "", "trait_name": "D", "entries": "7", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "3", "upcasting_cost_percent": "75" } +print-vtable-sizes { "crate_name": "", "trait_name": "E", "entries": "6", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "2", "upcasting_cost_percent": "50" } +print-vtable-sizes { "crate_name": "", "trait_name": "G", "entries": "14", "entries_ignoring_upcasting": "11", "entries_for_upcasting": "3", "upcasting_cost_percent": "27.27272727272727" } +print-vtable-sizes { "crate_name": "", "trait_name": "A", "entries": "6", "entries_ignoring_upcasting": "5", "entries_for_upcasting": "1", "upcasting_cost_percent": "20" } +print-vtable-sizes { "crate_name": "", "trait_name": "B", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "", "trait_name": "F", "entries": "6", "entries_ignoring_upcasting": "6", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "", "trait_name": "_::S", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "", "trait_name": "help::MarkerWithSuper", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "", "trait_name": "help::Super", "entries": "4", "entries_ignoring_upcasting": "4", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } +print-vtable-sizes { "crate_name": "", "trait_name": "help::V", "entries": "3", "entries_ignoring_upcasting": "3", "entries_for_upcasting": "0", "upcasting_cost_percent": "0" } diff --git a/tests/ui/traits/project-modulo-regions.rs b/tests/ui/traits/project-modulo-regions.rs index f0c0dd3ed..e88f21ecf 100644 --- a/tests/ui/traits/project-modulo-regions.rs +++ b/tests/ui/traits/project-modulo-regions.rs @@ -48,8 +48,8 @@ fn test(val: MyStruct) where Helper: HelperTrait { fn foo(val: MyStruct) { test(val); - //[with_clause]~^ ERROR evaluate(Binder(TraitPredicate(, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) - //[without_clause]~^^ ERROR evaluate(Binder(TraitPredicate(, polarity:Positive), [])) = Ok(EvaluatedToOk) + //[with_clause]~^ ERROR evaluate(Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) + //[without_clause]~^^ ERROR evaluate(Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) } fn main() {} diff --git a/tests/ui/traits/project-modulo-regions.with_clause.stderr b/tests/ui/traits/project-modulo-regions.with_clause.stderr index 2434c32c8..dcc98e855 100644 --- a/tests/ui/traits/project-modulo-regions.with_clause.stderr +++ b/tests/ui/traits/project-modulo-regions.with_clause.stderr @@ -1,4 +1,4 @@ -error: evaluate(Binder(TraitPredicate(, polarity:Positive), [])) = Ok(EvaluatedToOkModuloRegions) +error: evaluate(Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOkModuloRegions) --> $DIR/project-modulo-regions.rs:50:5 | LL | fn test(val: MyStruct) where Helper: HelperTrait { diff --git a/tests/ui/traits/project-modulo-regions.without_clause.stderr b/tests/ui/traits/project-modulo-regions.without_clause.stderr index 9d35690d5..e9959567e 100644 --- a/tests/ui/traits/project-modulo-regions.without_clause.stderr +++ b/tests/ui/traits/project-modulo-regions.without_clause.stderr @@ -1,4 +1,4 @@ -error: evaluate(Binder(TraitPredicate(, polarity:Positive), [])) = Ok(EvaluatedToOk) +error: evaluate(Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }) = Ok(EvaluatedToOk) --> $DIR/project-modulo-regions.rs:50:5 | LL | fn test(val: MyStruct) where Helper: HelperTrait { diff --git a/tests/ui/traits/suggest-where-clause.stderr b/tests/ui/traits/suggest-where-clause.stderr index 44e63b78c..f3a4c6890 100644 --- a/tests/ui/traits/suggest-where-clause.stderr +++ b/tests/ui/traits/suggest-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim --> $DIR/suggest-where-clause.rs:7:20 | LL | fn check() { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | // suggest a where-clause, if needed LL | mem::size_of::(); | ^ doesn't have a size known at compile-time @@ -19,7 +19,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim --> $DIR/suggest-where-clause.rs:10:20 | LL | fn check() { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | mem::size_of::>(); | ^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/traits/trivial_impl.rs b/tests/ui/traits/trivial_impl.rs new file mode 100644 index 000000000..6ac8c744b --- /dev/null +++ b/tests/ui/traits/trivial_impl.rs @@ -0,0 +1,18 @@ +//! This test checks that we do need to implement +//! all members, even if their where bounds only hold +//! due to other impls. + +trait Foo { + fn foo() + where + Self: Foo<()>; +} + +impl Foo<()> for () { + fn foo() {} +} + +impl Foo for () {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl.stderr b/tests/ui/traits/trivial_impl.stderr new file mode 100644 index 000000000..4b29b55be --- /dev/null +++ b/tests/ui/traits/trivial_impl.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl.rs:15:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Foo<()>; + | |______________________- `foo` from trait +... +LL | impl Foo for () {} + | ^^^^^^^^^^^^^^^^^^^^ 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/traits/trivial_impl2.rs b/tests/ui/traits/trivial_impl2.rs new file mode 100644 index 000000000..be5809600 --- /dev/null +++ b/tests/ui/traits/trivial_impl2.rs @@ -0,0 +1,13 @@ +//! This test checks that we currently need to implement +//! members, even if their where bounds don't hold for the impl type. + +trait Foo { + fn foo() + where + Self: Foo<()>; +} + +impl Foo for () {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl2.stderr b/tests/ui/traits/trivial_impl2.stderr new file mode 100644 index 000000000..04c05df06 --- /dev/null +++ b/tests/ui/traits/trivial_impl2.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl2.rs:10:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Foo<()>; + | |______________________- `foo` from trait +... +LL | impl Foo for () {} + | ^^^^^^^^^^^^^^^^^^^^ 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/traits/trivial_impl3.rs b/tests/ui/traits/trivial_impl3.rs new file mode 100644 index 000000000..714f643bc --- /dev/null +++ b/tests/ui/traits/trivial_impl3.rs @@ -0,0 +1,19 @@ +//! Check that we don't break orphan rules. +//! The dependency may add an impl for `u8` later, +//! which would break this crate. We want to avoid adding +//! more ways in which adding an impl can be a breaking change. + +// aux-build:trivial3.rs + +extern crate trivial3; + +pub trait Foo { + fn foo() + where + Self: trivial3::Trait; +} + +impl Foo for u8 {} +//~^ ERROR not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl3.stderr b/tests/ui/traits/trivial_impl3.stderr new file mode 100644 index 000000000..dfb39d6ce --- /dev/null +++ b/tests/ui/traits/trivial_impl3.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl3.rs:16:1 + | +LL | / fn foo() +LL | | where +LL | | Self: trivial3::Trait; + | |______________________________- `foo` from trait +... +LL | impl Foo for u8 {} + | ^^^^^^^^^^^^^^^ 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/traits/trivial_impl4.rs b/tests/ui/traits/trivial_impl4.rs new file mode 100644 index 000000000..518f159c1 --- /dev/null +++ b/tests/ui/traits/trivial_impl4.rs @@ -0,0 +1,21 @@ +//! Check that we don't break orphan rules. +//! The dependency may add an impl for `u8` later, +//! which would break this crate. We want to avoid adding +//! more ways in which adding an impl can be a breaking change. +//! This test differs from `trivial_impl3` because there actually +//! exists any impl for `Trait`, which has an effect on coherence. + +// aux-build:trivial4.rs + +extern crate trivial4; + +pub trait Foo { + fn foo() + where + Self: trivial4::Trait; +} + +impl Foo for u8 {} +//~^ ERROR not all trait items implemented, missing: `foo` + +fn main() {} diff --git a/tests/ui/traits/trivial_impl4.stderr b/tests/ui/traits/trivial_impl4.stderr new file mode 100644 index 000000000..04b29ed77 --- /dev/null +++ b/tests/ui/traits/trivial_impl4.stderr @@ -0,0 +1,14 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl4.rs:18:1 + | +LL | / fn foo() +LL | | where +LL | | Self: trivial4::Trait; + | |______________________________- `foo` from trait +... +LL | impl Foo for u8 {} + | ^^^^^^^^^^^^^^^ 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/traits/trivial_impl_sized.rs b/tests/ui/traits/trivial_impl_sized.rs new file mode 100644 index 000000000..501a34050 --- /dev/null +++ b/tests/ui/traits/trivial_impl_sized.rs @@ -0,0 +1,26 @@ +//! This test checks that we currently need to implement +//! members, even if their where bounds don't hold for the impl type. + +trait Foo { + fn foo() + where + Self: Sized; +} + +impl Foo for () { + fn foo() {} +} + +// Must not be allowed +impl Foo for i32 {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +// Should be allowed +impl Foo for dyn std::fmt::Debug {} +//~^ ERROR: not all trait items implemented, missing: `foo` + +impl Foo for dyn std::fmt::Display { + fn foo() {} +} + +fn main() {} diff --git a/tests/ui/traits/trivial_impl_sized.stderr b/tests/ui/traits/trivial_impl_sized.stderr new file mode 100644 index 000000000..ebf6dfc9d --- /dev/null +++ b/tests/ui/traits/trivial_impl_sized.stderr @@ -0,0 +1,25 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl_sized.rs:15:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Sized; + | |____________________- `foo` from trait +... +LL | impl Foo for i32 {} + | ^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/trivial_impl_sized.rs:19:1 + | +LL | / fn foo() +LL | | where +LL | | Self: Sized; + | |____________________- `foo` from trait +... +LL | impl Foo for dyn std::fmt::Debug {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/transmutability/alignment/align-fail.rs b/tests/ui/transmutability/alignment/align-fail.rs new file mode 100644 index 000000000..7f6090a6e --- /dev/null +++ b/tests/ui/transmutability/alignment/align-fail.rs @@ -0,0 +1,23 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + assert::is_maybe_transmutable::<&'static [u8; 0], &'static [u16; 0]>(); //~ ERROR `&[u8; 0]` cannot be safely transmuted into `&[u16; 0]` +} diff --git a/tests/ui/transmutability/alignment/align-fail.stderr b/tests/ui/transmutability/alignment/align-fail.stderr new file mode 100644 index 000000000..59246fb1b --- /dev/null +++ b/tests/ui/transmutability/alignment/align-fail.stderr @@ -0,0 +1,30 @@ +error[E0277]: `&[u8; 0]` cannot be safely transmuted into `&[u16; 0]` in the defining scope of `assert::Context` + --> $DIR/align-fail.rs:22:55 + | +LL | ...tatic [u8; 0], &'static [u16; 0]>(); + | ^^^^^^^^^^^^^^^^^ The minimum alignment of `&[u8; 0]` (1) should be greater than that of `&[u16; 0]` (2) + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/align-fail.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` +help: consider removing the leading `&`-reference + | +LL - assert::is_maybe_transmutable::<&'static [u8; 0], &'static [u16; 0]>(); +LL + assert::is_maybe_transmutable::<&'static [u8; 0], [u16; 0]>(); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/alignment/align-pass.rs b/tests/ui/transmutability/alignment/align-pass.rs new file mode 100644 index 000000000..62dc672ea --- /dev/null +++ b/tests/ui/transmutability/alignment/align-pass.rs @@ -0,0 +1,23 @@ +// check-pass +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + assert::is_maybe_transmutable::<&'static [u16; 0], &'static [u8; 0]>(); +} diff --git a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr index 9877a6606..46cdaa925 100644 --- a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr +++ b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr @@ -90,7 +90,7 @@ error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scop --> $DIR/primitive_reprs_should_have_correct_length.rs:72:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0i16` + | ^^^^^^^ The size of `u8` is smaller than the size of `V0i16` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -134,7 +134,7 @@ error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scop --> $DIR/primitive_reprs_should_have_correct_length.rs:80:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0u16` + | ^^^^^^^ The size of `u8` is smaller than the size of `V0u16` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -178,7 +178,7 @@ error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining sco --> $DIR/primitive_reprs_should_have_correct_length.rs:96:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u16` isn't a bit-valid value of `V0i32` + | ^^^^^^^ The size of `u16` is smaller than the size of `V0i32` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -222,7 +222,7 @@ error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining sco --> $DIR/primitive_reprs_should_have_correct_length.rs:104:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u16` isn't a bit-valid value of `V0u32` + | ^^^^^^^ The size of `u16` is smaller than the size of `V0u32` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -266,7 +266,7 @@ error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining sco --> $DIR/primitive_reprs_should_have_correct_length.rs:120:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u32` isn't a bit-valid value of `V0i64` + | ^^^^^^^ The size of `u32` is smaller than the size of `V0i64` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -310,7 +310,7 @@ error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining sco --> $DIR/primitive_reprs_should_have_correct_length.rs:128:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u32` isn't a bit-valid value of `V0u64` + | ^^^^^^^ The size of `u32` is smaller than the size of `V0u64` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -354,7 +354,7 @@ error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining sc --> $DIR/primitive_reprs_should_have_correct_length.rs:144:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0isize` + | ^^^^^^^ The size of `u8` is smaller than the size of `V0isize` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 @@ -398,7 +398,7 @@ error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining sc --> $DIR/primitive_reprs_should_have_correct_length.rs:152:44 | LL | assert::is_transmutable::(); - | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0usize` + | ^^^^^^^ The size of `u8` is smaller than the size of `V0usize` | note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs index ebe34e134..8d19cabc0 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs @@ -18,5 +18,5 @@ fn should_gracefully_handle_unknown_dst_field() { struct Context; #[repr(C)] struct Src; #[repr(C)] struct Dst(Missing); //~ cannot find type - assert::is_transmutable::(); + assert::is_transmutable::(); //~ ERROR cannot be safely transmuted } diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr index 475e6f429..c2df398b8 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr @@ -4,6 +4,22 @@ error[E0412]: cannot find type `Missing` in this scope LL | #[repr(C)] struct Dst(Missing); | ^^^^^^^ not found in this scope -error: aborting due to previous error +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_gracefully_handle_unknown_dst_field::Context` + --> $DIR/unknown_src_field.rs:21:36 + | +LL | assert::is_transmutable::(); + | ^^^ `Dst` has an unknown layout + | +note: required by a bound in `is_transmutable` + --> $DIR/unknown_src_field.rs:13:14 + | +LL | pub fn is_transmutable() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0277, E0412. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/primitives/bool-mut.rs b/tests/ui/transmutability/primitives/bool-mut.rs new file mode 100644 index 000000000..49dbe90e4 --- /dev/null +++ b/tests/ui/transmutability/primitives/bool-mut.rs @@ -0,0 +1,17 @@ +// check-fail +//[next] compile-flags: -Ztrait-solver=next + +#![feature(transmutability)] +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + assert::is_transmutable::<&'static mut bool, &'static mut u8>() //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/primitives/bool-mut.stderr b/tests/ui/transmutability/primitives/bool-mut.stderr new file mode 100644 index 000000000..b36991e1c --- /dev/null +++ b/tests/ui/transmutability/primitives/bool-mut.stderr @@ -0,0 +1,18 @@ +error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context` + --> $DIR/bool-mut.rs:16:50 + | +LL | assert::is_transmutable::<&'static mut bool, &'static mut u8>() + | ^^^^^^^^^^^^^^^ At least one value of `u8` isn't a bit-valid value of `bool` + | +note: required by a bound in `is_transmutable` + --> $DIR/bool-mut.rs:11:14 + | +LL | pub fn is_transmutable() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/primitives/bool.current.stderr b/tests/ui/transmutability/primitives/bool.current.stderr index 47c8438a2..4b3eb6c51 100644 --- a/tests/ui/transmutability/primitives/bool.current.stderr +++ b/tests/ui/transmutability/primitives/bool.current.stderr @@ -1,11 +1,11 @@ error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context` - --> $DIR/bool.rs:24:35 + --> $DIR/bool.rs:21:35 | LL | assert::is_transmutable::(); | ^^^^ At least one value of `u8` isn't a bit-valid value of `bool` | note: required by a bound in `is_transmutable` - --> $DIR/bool.rs:14:14 + --> $DIR/bool.rs:11:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/bool.next.stderr b/tests/ui/transmutability/primitives/bool.next.stderr index 47c8438a2..4b3eb6c51 100644 --- a/tests/ui/transmutability/primitives/bool.next.stderr +++ b/tests/ui/transmutability/primitives/bool.next.stderr @@ -1,11 +1,11 @@ error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context` - --> $DIR/bool.rs:24:35 + --> $DIR/bool.rs:21:35 | LL | assert::is_transmutable::(); | ^^^^ At least one value of `u8` isn't a bit-valid value of `bool` | note: required by a bound in `is_transmutable` - --> $DIR/bool.rs:14:14 + --> $DIR/bool.rs:11:14 | LL | pub fn is_transmutable() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs index de77cfc78..654e7b47e 100644 --- a/tests/ui/transmutability/primitives/bool.rs +++ b/tests/ui/transmutability/primitives/bool.rs @@ -1,10 +1,7 @@ // revisions: current next //[next] compile-flags: -Ztrait-solver=next -#![crate_type = "lib"] #![feature(transmutability)] -#![allow(dead_code)] -#![allow(incomplete_features)] mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; @@ -20,7 +17,7 @@ mod assert { {} } -fn contrast_with_u8() { +fn main() { assert::is_transmutable::(); //~ ERROR cannot be safely transmuted assert::is_maybe_transmutable::(); assert::is_transmutable::(); diff --git a/tests/ui/transmutability/references.current.stderr b/tests/ui/transmutability/references.current.stderr deleted file mode 100644 index 819c9b92b..000000000 --- a/tests/ui/transmutability/references.current.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` in the defining scope of `assert::Context` - --> $DIR/references.rs:29:52 - | -LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); - | ^^^^^^^^^^^^^ `&Unit` does not have a well-specified layout - | -note: required by a bound in `is_maybe_transmutable` - --> $DIR/references.rs:16:14 - | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references.next.stderr b/tests/ui/transmutability/references.next.stderr deleted file mode 100644 index 819c9b92b..000000000 --- a/tests/ui/transmutability/references.next.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: `&Unit` cannot be safely transmuted into `&Unit` in the defining scope of `assert::Context` - --> $DIR/references.rs:29:52 - | -LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); - | ^^^^^^^^^^^^^ `&Unit` does not have a well-specified layout - | -note: required by a bound in `is_maybe_transmutable` - --> $DIR/references.rs:16:14 - | -LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function -LL | where -LL | Dst: BikeshedIntrinsicFrom - | |__________^ required by this bound in `is_maybe_transmutable` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references.rs b/tests/ui/transmutability/references.rs deleted file mode 100644 index 8c2b25ebb..000000000 --- a/tests/ui/transmutability/references.rs +++ /dev/null @@ -1,30 +0,0 @@ -// revisions: current next -//[next] compile-flags: -Ztrait-solver=next - -//! Transmutations involving references are not yet supported. - -#![crate_type = "lib"] -#![feature(transmutability)] -#![allow(dead_code, incomplete_features, non_camel_case_types)] - -mod assert { - use std::mem::{Assume, BikeshedIntrinsicFrom}; - pub struct Context; - - pub fn is_maybe_transmutable() - where - Dst: BikeshedIntrinsicFrom - {} -} - -fn not_yet_implemented() { - #[repr(C)] struct Unit; - assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); //~ ERROR cannot be safely transmuted -} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs new file mode 100644 index 000000000..a6e2889d3 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.rs @@ -0,0 +1,25 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(bool, &'static A); + #[repr(C)] struct B(u8, &'static B); + assert::is_maybe_transmutable::<&'static A, &'static mut B>(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr new file mode 100644 index 000000000..4b4d6ad02 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible-mut.stderr @@ -0,0 +1,25 @@ +error[E0277]: `&A` cannot be safely transmuted into `&mut B` in the defining scope of `assert::Context` + --> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:24:49 + | +LL | assert::is_maybe_transmutable::<&'static A, &'static mut B>(); + | ^^^^^^^^^^^^^^ `&A` is a shared reference, but `&mut B` is a unique reference + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types-bit-compatible-mut.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs new file mode 100644 index 000000000..3ea80173a --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.rs @@ -0,0 +1,26 @@ +// check-fail +// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(bool, &'static A); + #[repr(C)] struct B(u8, &'static B); + assert::is_maybe_transmutable::<&'static A, &'static B>(); //~ ERROR overflow evaluating the requirement +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr new file mode 100644 index 000000000..fae332e6a --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-compatible.stderr @@ -0,0 +1,25 @@ +error[E0275]: overflow evaluating the requirement `B: BikeshedIntrinsicFrom` + --> $DIR/recursive-wrapper-types-bit-compatible.rs:25:5 + | +LL | assert::is_maybe_transmutable::<&'static A, &'static B>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types-bit-compatible.rs:11:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs new file mode 100644 index 000000000..e8582d2fd --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.rs @@ -0,0 +1,25 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(bool, &'static A); + #[repr(C)] struct B(u8, &'static B); + assert::is_maybe_transmutable::<&'static B, &'static A>(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr new file mode 100644 index 000000000..ecfe48659 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types-bit-incompatible.stderr @@ -0,0 +1,25 @@ +error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` + --> $DIR/recursive-wrapper-types-bit-incompatible.rs:24:49 + | +LL | assert::is_maybe_transmutable::<&'static B, &'static A>(); + | ^^^^^^^^^^ At least one value of `B` isn't a bit-valid value of `A` + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types-bit-incompatible.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references/recursive-wrapper-types.rs b/tests/ui/transmutability/references/recursive-wrapper-types.rs new file mode 100644 index 000000000..59d1ad84a --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types.rs @@ -0,0 +1,27 @@ +// check-fail +// FIXME(bryangarza): Change to check-pass when coinduction is supported for BikeshedIntrinsicFrom +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct A(&'static B); + #[repr(C)] struct B(&'static A); + assert::is_maybe_transmutable::<&'static A, &'static B>(); //~ overflow evaluating the requirement + assert::is_maybe_transmutable::<&'static B, &'static A>(); +} diff --git a/tests/ui/transmutability/references/recursive-wrapper-types.stderr b/tests/ui/transmutability/references/recursive-wrapper-types.stderr new file mode 100644 index 000000000..35a60c226 --- /dev/null +++ b/tests/ui/transmutability/references/recursive-wrapper-types.stderr @@ -0,0 +1,25 @@ +error[E0275]: overflow evaluating the requirement `A: BikeshedIntrinsicFrom` + --> $DIR/recursive-wrapper-types.rs:25:5 + | +LL | assert::is_maybe_transmutable::<&'static A, &'static B>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/recursive-wrapper-types.rs:11:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/transmutability/references/u8-to-unit.rs b/tests/ui/transmutability/references/u8-to-unit.rs new file mode 100644 index 000000000..8b37492bd --- /dev/null +++ b/tests/ui/transmutability/references/u8-to-unit.rs @@ -0,0 +1,24 @@ +// check-pass +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct Unit; + assert::is_maybe_transmutable::<&'static u8, &'static Unit>(); +} diff --git a/tests/ui/transmutability/references/unit-to-itself.rs b/tests/ui/transmutability/references/unit-to-itself.rs new file mode 100644 index 000000000..04a7e16d7 --- /dev/null +++ b/tests/ui/transmutability/references/unit-to-itself.rs @@ -0,0 +1,24 @@ +// check-pass +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct Unit; + assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); +} diff --git a/tests/ui/transmutability/references/unit-to-u8.rs b/tests/ui/transmutability/references/unit-to-u8.rs new file mode 100644 index 000000000..eff516e9a --- /dev/null +++ b/tests/ui/transmutability/references/unit-to-u8.rs @@ -0,0 +1,24 @@ +// check-fail +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable() + where + Dst: BikeshedIntrinsicFrom + {} +} + +fn main() { + #[repr(C)] struct Unit; + assert::is_maybe_transmutable::<&'static Unit, &'static u8>(); //~ ERROR cannot be safely transmuted +} diff --git a/tests/ui/transmutability/references/unit-to-u8.stderr b/tests/ui/transmutability/references/unit-to-u8.stderr new file mode 100644 index 000000000..f2b72357f --- /dev/null +++ b/tests/ui/transmutability/references/unit-to-u8.stderr @@ -0,0 +1,25 @@ +error[E0277]: `Unit` cannot be safely transmuted into `u8` in the defining scope of `assert::Context` + --> $DIR/unit-to-u8.rs:23:52 + | +LL | assert::is_maybe_transmutable::<&'static Unit, &'static u8>(); + | ^^^^^^^^^^^ The size of `Unit` is smaller than the size of `u8` + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/unit-to-u8.rs:10:14 + | +LL | pub fn is_maybe_transmutable() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/region-infer.stderr b/tests/ui/transmutability/region-infer.stderr index d6b65e9e4..307d0dfe5 100644 --- a/tests/ui/transmutability/region-infer.stderr +++ b/tests/ui/transmutability/region-infer.stderr @@ -2,7 +2,7 @@ error[E0277]: `()` cannot be safely transmuted into `W<'_>` in the defining scop --> $DIR/region-infer.rs:20:5 | LL | test(); - | ^^^^ `W<'_>` does not have a well-specified layout + | ^^^^ The size of `()` is smaller than the size of `W<'_>` | note: required by a bound in `test` --> $DIR/region-infer.rs:11:12 diff --git a/tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs b/tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs new file mode 100644 index 000000000..c7d480a77 --- /dev/null +++ b/tests/ui/treat-err-as-bug/panic-causes-oom-112708.rs @@ -0,0 +1,10 @@ +// compile-flags: -Ztreat-err-as-bug +// dont-check-failure-status +// error-pattern: aborting due to `-Z treat-err-as-bug=1` +// dont-check-compiler-stderr +// rustc-env:RUST_BACKTRACE=0 + +fn main() { + #[deny(while_true)] + while true {} +} diff --git a/tests/ui/treat-err-as-bug/panic-causes-oom-112708.stderr b/tests/ui/treat-err-as-bug/panic-causes-oom-112708.stderr new file mode 100644 index 000000000..2d49071ac --- /dev/null +++ b/tests/ui/treat-err-as-bug/panic-causes-oom-112708.stderr @@ -0,0 +1,32 @@ +error: denote infinite loops with `loop { ... }` + --> $DIR/panic-causes-oom-112708.rs:13:5 + | +LL | while true {} + | ^^^^^^^^^^ help: use `loop` + | +note: the lint level is defined here + --> $DIR/panic-causes-oom-112708.rs:12:12 + | +LL | #[deny(while_true)] + | ^^^^^^^^^^ + + +query stack during panic: +#0 [early_lint_checks] perform lints prior to macro expansion +#1 [hir_crate] getting the crate HIR +end of query stack + +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [early_lint_checks] perform lints prior to macro expansion +#1 [hir_crate] getting the crate HIR +end of query stack + +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [early_lint_checks] perform lints prior to macro expansion +#1 [hir_crate] getting the crate HIR +end of query stack +thread caused non-unwinding panic. aborting. diff --git a/tests/ui/try-block/issue-45124.rs b/tests/ui/try-block/issue-45124.rs index 942014c91..2cf2ade65 100644 --- a/tests/ui/try-block/issue-45124.rs +++ b/tests/ui/try-block/issue-45124.rs @@ -8,7 +8,7 @@ fn main() { let mut a = 0; let () = { let _: Result<(), ()> = try { - let _ = Err(())?; + let () = Err(())?; return }; a += 1; diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index a49630adb..7eb392faa 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -8,8 +8,8 @@ LL | Ok(Err(123_i32)?) | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From`: - > > + > = note: required for `Result` to implement `FromResidual>` error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` @@ -22,8 +22,8 @@ LL | Some(3)?; | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` --> $DIR/bad-interconversion.rs:17:31 @@ -35,8 +35,8 @@ LL | Ok(ControlFlow::Break(123)?) | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/bad-interconversion.rs:22:22 diff --git a/tests/ui/try-trait/option-to-result.stderr b/tests/ui/try-trait/option-to-result.stderr index fabc1ff2c..1c4d718f1 100644 --- a/tests/ui/try-trait/option-to-result.stderr +++ b/tests/ui/try-trait/option-to-result.stderr @@ -9,8 +9,8 @@ LL | a?; | = help: the trait `FromResidual>` is not implemented for `Result<(), ()>` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/option-to-result.rs:11:6 diff --git a/tests/ui/try-trait/try-on-option.stderr b/tests/ui/try-trait/try-on-option.stderr index fad6a1fe8..eeb0439df 100644 --- a/tests/ui/try-trait/try-on-option.stderr +++ b/tests/ui/try-trait/try-on-option.stderr @@ -9,8 +9,8 @@ LL | x?; | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: - as FromResidual>> as FromResidual>> + as FromResidual>> error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option.rs:11:6 diff --git a/tests/ui/tuple/index-float.rs b/tests/ui/tuple/index-float.rs index eda2bf485..53b025c91 100644 --- a/tests/ui/tuple/index-float.rs +++ b/tests/ui/tuple/index-float.rs @@ -3,8 +3,8 @@ fn main() { let tuple = (((),),); - let _ = tuple. 0.0; // OK, whitespace - let _ = tuple.0. 0; // OK, whitespace + let () = tuple. 0.0; // OK, whitespace + let () = tuple.0. 0; // OK, whitespace - let _ = tuple./*special cases*/0.0; // OK, comment + let () = tuple./*special cases*/0.0; // OK, comment } diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs b/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs index a1584581e..d9f7c7809 100644 --- a/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs +++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs @@ -4,9 +4,9 @@ #![allow(dead_code)] mod m { - type Foo = impl std::fmt::Debug; + pub(crate) type Foo = impl std::fmt::Debug; - pub fn foo() -> Foo { + pub(crate) fn foo() -> Foo { 22_u32 } } diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs index 5fb7a9473..fd3f9c614 100644 --- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs +++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs @@ -4,8 +4,9 @@ // FIXME This should compile, but it currently doesn't mod m { - type Foo = impl std::fmt::Debug; + pub type Foo = impl std::fmt::Debug; //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391] + //~| ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391] pub fn foo() -> Foo { 22_u32 @@ -13,6 +14,7 @@ mod m { pub fn bar() { is_send(foo()); + //~^ ERROR: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0} } fn is_send(_: T) {} diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr index 1e9a45aac..dd56c59bf 100644 --- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr +++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr @@ -1,11 +1,11 @@ error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` - --> $DIR/auto-trait-leakage3.rs:7:16 + --> $DIR/auto-trait-leakage3.rs:7:20 | -LL | type Foo = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ +LL | pub type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ | note: ...which requires type-checking `m::bar`... - --> $DIR/auto-trait-leakage3.rs:15:9 + --> $DIR/auto-trait-leakage3.rs:16:9 | LL | is_send(foo()); | ^^^^^^^ @@ -17,6 +17,48 @@ note: cycle used when checking item types in module `m` LL | mod m { | ^^^^^ -error: aborting due to previous error +error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` + --> $DIR/auto-trait-leakage3.rs:7:20 + | +LL | pub type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires type-checking `m::bar`... + --> $DIR/auto-trait-leakage3.rs:15:5 + | +LL | pub fn bar() { + | ^^^^^^^^^^^^ + = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in module `m` + --> $DIR/auto-trait-leakage3.rs:6:1 + | +LL | mod m { + | ^^^^^ + +error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits + --> $DIR/auto-trait-leakage3.rs:16:17 + | +LL | is_send(foo()); + | ------- ^^^^^ + | | + | required by a bound introduced by this call + | +note: opaque type is declared here + --> $DIR/auto-trait-leakage3.rs:7:20 + | +LL | pub type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/auto-trait-leakage3.rs:15:12 + | +LL | pub fn bar() { + | ^^^ +note: required by a bound in `is_send` + --> $DIR/auto-trait-leakage3.rs:20:19 + | +LL | fn is_send(_: T) {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/bound_reduction2.rs b/tests/ui/type-alias-impl-trait/bound_reduction2.rs index 0bcc9e002..4e9f65d88 100644 --- a/tests/ui/type-alias-impl-trait/bound_reduction2.rs +++ b/tests/ui/type-alias-impl-trait/bound_reduction2.rs @@ -13,6 +13,7 @@ trait Trait {} impl Trait for () {} fn foo_desugared(_: T) -> Foo { + //~^ ERROR non-defining opaque type use () //~^ ERROR expected generic type parameter, found `::Assoc` } diff --git a/tests/ui/type-alias-impl-trait/bound_reduction2.stderr b/tests/ui/type-alias-impl-trait/bound_reduction2.stderr index 3c259bd9e..14f9dbbdb 100644 --- a/tests/ui/type-alias-impl-trait/bound_reduction2.stderr +++ b/tests/ui/type-alias-impl-trait/bound_reduction2.stderr @@ -1,5 +1,17 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/bound_reduction2.rs:15:46 + | +LL | fn foo_desugared(_: T) -> Foo { + | ^^^^^^^^^^^^^ argument `::Assoc` is not a generic parameter + | +note: for this opaque type + --> $DIR/bound_reduction2.rs:9:15 + | +LL | type Foo = impl Trait; + | ^^^^^^^^^^^^^ + error[E0792]: expected generic type parameter, found `::Assoc` - --> $DIR/bound_reduction2.rs:16:5 + --> $DIR/bound_reduction2.rs:17:5 | LL | type Foo = impl Trait; | - this generic parameter must be used with a generic type parameter @@ -7,6 +19,6 @@ LL | type Foo = impl Trait; LL | () | ^^ -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/type-alias-impl-trait/bounds-are-checked3.rs b/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs new file mode 100644 index 000000000..5a9e87c09 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs @@ -0,0 +1,16 @@ +#![feature(type_alias_impl_trait)] + +use std::fmt::{Debug, Display}; + +struct Struct(Option); + +// Make sure that, in contrast to type aliases without opaque types, +// we actually do a wf check for the aliased type. +type Foo = (impl Debug, Struct); +//~^ ERROR: `T` doesn't implement `std::fmt::Display` + +fn foo() -> Foo { + (Vec::::new(), Struct(None)) +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr new file mode 100644 index 000000000..a845cba77 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr @@ -0,0 +1,20 @@ +error[E0277]: `T` doesn't implement `std::fmt::Display` + --> $DIR/bounds-are-checked3.rs:9:35 + | +LL | type Foo = (impl Debug, Struct); + | ^^^^^^^^^ `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 `Struct` + --> $DIR/bounds-are-checked3.rs:5:18 + | +LL | struct Struct(Option); + | ^^^^^^^ required by this bound in `Struct` +help: consider further restricting this bound + | +LL | type Foo = (impl Debug, Struct); + | +++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/bounds.rs b/tests/ui/type-alias-impl-trait/bounds.rs new file mode 100644 index 000000000..dc05b70c5 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bounds.rs @@ -0,0 +1,16 @@ +#![feature(type_alias_impl_trait)] + +// check-pass + +use std::fmt::Debug; + +// No need to report the `type_alias_bounds` lint, as +// the moment an opaque type is mentioned, we actually do check +// type alias bounds. +type Foo = (impl Debug, usize); + +fn foo() -> Foo { + (Vec::::new(), 1234) +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/closure_args.rs b/tests/ui/type-alias-impl-trait/closure_args.rs index c5e7af81d..243f9cd6d 100644 --- a/tests/ui/type-alias-impl-trait/closure_args.rs +++ b/tests/ui/type-alias-impl-trait/closure_args.rs @@ -11,6 +11,13 @@ fn run ()>(f: F, i: Input) { f(i); } -fn main() { - run(|x: u32| {println!("{x}");}, 0); +fn bop(_: Input) { + run( + |x: u32| { + println!("{x}"); + }, + 0, + ); } + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/closure_args2.rs b/tests/ui/type-alias-impl-trait/closure_args2.rs index 82386c280..1dd5c3e40 100644 --- a/tests/ui/type-alias-impl-trait/closure_args2.rs +++ b/tests/ui/type-alias-impl-trait/closure_args2.rs @@ -1,10 +1,12 @@ -// run-pass +// check-pass #![feature(type_alias_impl_trait)] trait Foo { // This was reachable in https://github.com/rust-lang/rust/issues/100800 - fn foo(&self) { unreachable!() } + fn foo(&self) { + unreachable!() + } } impl Foo for T {} @@ -14,10 +16,17 @@ impl B { } type Input = impl Foo; -fn run1(f: F, i: Input) {f(i)} -fn run2(f: F, i: B) {f(i)} +fn run1(f: F, i: Input) { + f(i) +} +fn run2(f: F, i: B) { + f(i) +} -fn main() { - run1(|x: B| {x.foo()}, B); - run2(|x: B| {x.foo()}, B); +fn bop() -> Input { + run1(|x: B| x.foo(), B); + run2(|x: B| x.foo(), B); + panic!() } + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence.stderr b/tests/ui/type-alias-impl-trait/coherence.stderr index 00b0dbbb5..c923eb08a 100644 --- a/tests/ui/type-alias-impl-trait/coherence.stderr +++ b/tests/ui/type-alias-impl-trait/coherence.stderr @@ -4,7 +4,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar LL | impl foreign_crate::ForeignTrait for AliasOfForeignType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------- | | | - | | type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate + | | `AliasOfForeignType` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs new file mode 100644 index 000000000..39b3d535a --- /dev/null +++ b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs @@ -0,0 +1,25 @@ +// When checking whether these two impls overlap, we could detect that we +// would require the hidden type of `TAIT` to be equal to both `u32` and `i32` +// and therefore accept them as disjoint. That is annoying to implement with +// the current system because we would have to add the following to each +// returning branch in coherence. +// +// let _ = infcx.take_opaque_types(); +// +// @lcnr: Because of this I decided to not bother and cause this to fail instead. +// In the future we can definitely modify the compiler to accept this +// again. +#![feature(type_alias_impl_trait)] + +trait Trait {} + +type TAIT = impl Sized; + +impl Trait for (TAIT, TAIT) {} + +impl Trait for (u32, i32) {} +//~^ ERROR conflicting implementations of trait `Trait` for type `(TAIT, TAIT)` + +fn define() -> TAIT {} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr new file mode 100644 index 000000000..f2aee7986 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Trait` for type `(TAIT, TAIT)` + --> $DIR/coherence_different_hidden_ty.rs:20:1 + | +LL | impl Trait for (TAIT, TAIT) {} + | --------------------------- first implementation here +LL | +LL | impl Trait for (u32, i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(TAIT, TAIT)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/type-alias-impl-trait/coherence_generalization.rs b/tests/ui/type-alias-impl-trait/coherence_generalization.rs index 5c9ad9498..679b2b0f1 100644 --- a/tests/ui/type-alias-impl-trait/coherence_generalization.rs +++ b/tests/ui/type-alias-impl-trait/coherence_generalization.rs @@ -1,5 +1,7 @@ // check-pass +// FIXME(type_alias_impl_trait): What does this test? This needs a comment +// explaining what we're worried about here. #![feature(type_alias_impl_trait)] trait Trait {} type Opaque = impl Sized; diff --git a/tests/ui/type-alias-impl-trait/cross_inference.rs b/tests/ui/type-alias-impl-trait/cross_inference.rs index dafaf40a6..5eaf0ddda 100644 --- a/tests/ui/type-alias-impl-trait/cross_inference.rs +++ b/tests/ui/type-alias-impl-trait/cross_inference.rs @@ -1,10 +1,12 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next // check-pass #![feature(type_alias_impl_trait)] fn main() { - type T = impl Copy; - let foo: T = (1u32, 2u32); + type Tait = impl Copy; + let foo: Tait = (1u32, 2u32); let x: (_, _) = foo; println!("{:?}", x); } diff --git a/tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs b/tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs new file mode 100644 index 000000000..44158349f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs @@ -0,0 +1,12 @@ +// compile-flags: --crate-type=lib -Cdebuginfo=2 +// build-pass + +#![feature(type_alias_impl_trait)] + +type Debuggable = impl core::fmt::Debug; + +static mut TEST: Option = None; + +fn foo() -> Debuggable { + 0u32 +} diff --git a/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr b/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr index fbfa0ccf1..d60f1ffbc 100644 --- a/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr +++ b/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr @@ -19,6 +19,11 @@ LL | "" | = note: expected opaque type `Boo` found reference `&'static str` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/declared_but_not_defined_in_scope.rs:10:4 + | +LL | fn bomp() -> boo::Boo { + | ^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs b/tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs new file mode 100644 index 000000000..5a421ea1d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs @@ -0,0 +1,19 @@ +// User type annotation in fn bodies is a a valid defining site for opaque types. +// check-pass +#![feature(type_alias_impl_trait)] + +trait Equate { type Proj; } +impl Equate for T { type Proj = T; } + +trait Indirect { type Ty; } +impl> Indirect for (A, B) { type Ty = (); } + +type Opq = impl Sized; +fn define_1(_: Opq) { + let _ = None::<<(Opq, u8) as Indirect>::Ty>; +} +fn define_2() -> Opq { + 0u8 +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/defining-use-submodule.rs b/tests/ui/type-alias-impl-trait/defining-use-submodule.rs index 8b51f5571..4d84b2cbb 100644 --- a/tests/ui/type-alias-impl-trait/defining-use-submodule.rs +++ b/tests/ui/type-alias-impl-trait/defining-use-submodule.rs @@ -11,12 +11,12 @@ type Foo = impl std::fmt::Display; type Bar = impl std::fmt::Display; mod foo { - pub fn foo() -> super::Foo { + pub(crate) fn foo() -> super::Foo { "foo" } - pub mod bar { - pub fn bar() -> crate::Bar { + pub(crate) mod bar { + pub(crate) fn bar() -> crate::Bar { 1 } } diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs index e5bfbfdae..b2842df15 100644 --- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs @@ -2,7 +2,7 @@ type Tait<'a> = impl Sized + 'a; -fn foo<'a, 'b>() { +fn foo<'a, 'b>() -> Tait<'a> { if false { if { return } { let y: Tait<'b> = 1i32; @@ -10,6 +10,7 @@ fn foo<'a, 'b>() { } } let x: Tait<'a> = (); + x } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr index f2eb7bc4d..b138f9d5c 100644 --- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr @@ -5,10 +5,10 @@ LL | let y: Tait<'b> = 1i32; | ^^^^ expected `()`, got `i32` | note: previous use here - --> $DIR/different_defining_uses_never_type-2.rs:12:23 + --> $DIR/different_defining_uses_never_type-2.rs:7:14 | -LL | let x: Tait<'a> = (); - | ^^ +LL | if { return } { + | ^^^^^^ error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs index 2b30a9cd5..a4ac27378 100644 --- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs +++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs @@ -2,7 +2,7 @@ type Tait = impl Sized; -fn foo() { +fn foo() -> Tait { if false { if { return } { let y: Tait = 1i32; @@ -10,6 +10,7 @@ fn foo() { } } let x: Tait = (); + x } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs index 9d938a616..14ced3418 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs @@ -9,6 +9,7 @@ impl<'a, T: ?Sized> Captures<'a> for T {} type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; fn one<'a>(t: &'a ()) -> Two<'a, 'a> { + //~^ ERROR non-defining opaque type use t //~^ ERROR non-defining opaque type use } diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr index 72e1ef4b4..4da69a705 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr @@ -1,5 +1,17 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_lifetime_param.rs:12:5 + --> $DIR/generic_duplicate_lifetime_param.rs:11:26 + | +LL | fn one<'a>(t: &'a ()) -> Two<'a, 'a> { + | ^^^^^^^^^^^ generic argument `'a` used twice + | +note: for this opaque type + --> $DIR/generic_duplicate_lifetime_param.rs:9:20 + | +LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_lifetime_param.rs:13:5 | LL | t | ^ @@ -10,5 +22,5 @@ note: lifetime used multiple times LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>; | ^^ ^^ -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs index 80462f8ac..1e391b55a 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs @@ -1,5 +1,12 @@ #![feature(type_alias_impl_trait)] +//! This test checks various cases where we are using the same +//! generic parameter twice in the parameter list of a TAIT. +//! Within defining scopes that is not legal, because the hidden type +//! is not fully defined then. This could cause us to have a TAIT +//! that doesn't have a hidden type for all possible combinations of generic +//! parameters passed to it. + use std::fmt::Debug; fn main() {} @@ -7,7 +14,6 @@ fn main() {} // test that unused generic parameters are ok type TwoTys = impl Debug; - pub trait Captures<'a> {} impl<'a, T: ?Sized> Captures<'a> for T {} @@ -16,18 +22,20 @@ type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; type TwoConsts = impl Debug; - fn one_ty(t: T) -> TwoTys { + //~^ ERROR non-defining opaque type use in defining scope t //~^ ERROR non-defining opaque type use in defining scope } fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> { + //~^ ERROR non-defining opaque type use in defining scope t //~^ ERROR non-defining opaque type use in defining scope } fn one_const(t: *mut [u8; N]) -> TwoConsts { + //~^ ERROR non-defining opaque type use in defining scope t //~^ ERROR non-defining opaque type use in defining scope } diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index 98e4bfea1..d8330771d 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -1,38 +1,74 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:21:5 + --> $DIR/generic_duplicate_param_use.rs:25:30 + | +LL | fn one_ty(t: T) -> TwoTys { + | ^^^^^^^^^^^^ generic argument `T` used twice + | +note: for this opaque type + --> $DIR/generic_duplicate_param_use.rs:15:21 + | +LL | type TwoTys = impl Debug; + | ^^^^^^^^^^ + +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use.rs:27:5 | LL | t | ^ | note: type used multiple times - --> $DIR/generic_duplicate_param_use.rs:8:13 + --> $DIR/generic_duplicate_param_use.rs:15:13 | LL | type TwoTys = impl Debug; | ^ ^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:26:5 + --> $DIR/generic_duplicate_param_use.rs:31:36 + | +LL | fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> { + | ^^^^^^^^^^^^^^^^^^^^ generic argument `'a` used twice + | +note: for this opaque type + --> $DIR/generic_duplicate_param_use.rs:21:29 + | +LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use.rs:33:5 | LL | t | ^ | note: lifetime used multiple times - --> $DIR/generic_duplicate_param_use.rs:15:19 + --> $DIR/generic_duplicate_param_use.rs:21:19 | LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>; | ^^ ^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:31:5 + --> $DIR/generic_duplicate_param_use.rs:37:50 + | +LL | fn one_const(t: *mut [u8; N]) -> TwoConsts { + | ^^^^^^^^^^^^^^^ generic argument `N` used twice + | +note: for this opaque type + --> $DIR/generic_duplicate_param_use.rs:23:50 + | +LL | type TwoConsts = impl Debug; + | ^^^^^^^^^^ + +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use.rs:39:5 | LL | t | ^ | note: constant used multiple times - --> $DIR/generic_duplicate_param_use.rs:17:16 + --> $DIR/generic_duplicate_param_use.rs:23:16 | LL | type TwoConsts = impl Debug; | ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs b/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs index e7b8567b9..68f4c6923 100644 --- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs @@ -13,16 +13,19 @@ type OneConst = impl Debug; // Not defining uses, because they doesn't define *all* possible generics. fn concrete_ty() -> OneTy { + //~^ ERROR: non-defining opaque type use in defining scope 5u32 - //~^ ERROR expected generic type parameter, found `u32` + //~^ ERROR: expected generic type parameter, found `u32` } fn concrete_lifetime() -> OneLifetime<'static> { + //~^ ERROR: non-defining opaque type use in defining scope 6u32 - //~^ ERROR expected generic lifetime parameter, found `'static` + //~^ ERROR: expected generic lifetime parameter, found `'static` } fn concrete_const() -> OneConst<{ 123 }> { + //~^ ERROR: non-defining opaque type use in defining scope 7u32 - //~^ ERROR expected generic constant parameter, found `123` + //~^ ERROR: expected generic constant parameter, found `123` } diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr index 966fe823f..e3b7b1a76 100644 --- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr @@ -1,5 +1,17 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/generic_nondefining_use.rs:15:21 + | +LL | fn concrete_ty() -> OneTy { + | ^^^^^^^^^^ argument `u32` is not a generic parameter + | +note: for this opaque type + --> $DIR/generic_nondefining_use.rs:7:17 + | +LL | type OneTy = impl Debug; + | ^^^^^^^^^^ + error[E0792]: expected generic type parameter, found `u32` - --> $DIR/generic_nondefining_use.rs:16:5 + --> $DIR/generic_nondefining_use.rs:17:5 | LL | type OneTy = impl Debug; | - this generic parameter must be used with a generic type parameter @@ -7,8 +19,20 @@ LL | type OneTy = impl Debug; LL | 5u32 | ^^^^ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/generic_nondefining_use.rs:21:27 + | +LL | fn concrete_lifetime() -> OneLifetime<'static> { + | ^^^^^^^^^^^^^^^^^^^^ argument `'static` is not a generic parameter + | +note: for this opaque type + --> $DIR/generic_nondefining_use.rs:9:24 + | +LL | type OneLifetime<'a> = impl Debug; + | ^^^^^^^^^^ + error[E0792]: expected generic lifetime parameter, found `'static` - --> $DIR/generic_nondefining_use.rs:21:5 + --> $DIR/generic_nondefining_use.rs:23:5 | LL | type OneLifetime<'a> = impl Debug; | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type @@ -16,8 +40,20 @@ LL | type OneLifetime<'a> = impl Debug; LL | 6u32 | ^^^^ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/generic_nondefining_use.rs:27:24 + | +LL | fn concrete_const() -> OneConst<{ 123 }> { + | ^^^^^^^^^^^^^^^^^ argument `123` is not a generic parameter + | +note: for this opaque type + --> $DIR/generic_nondefining_use.rs:11:33 + | +LL | type OneConst = impl Debug; + | ^^^^^^^^^^ + error[E0792]: expected generic constant parameter, found `123` - --> $DIR/generic_nondefining_use.rs:26:5 + --> $DIR/generic_nondefining_use.rs:29:5 | LL | type OneConst = impl Debug; | -------------- this generic parameter must be used with a generic constant parameter @@ -25,6 +61,6 @@ LL | type OneConst = impl Debug; LL | 7u32 | ^^^^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs index cdd8f6f19..c60f5c11c 100644 --- a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs +++ b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs @@ -5,12 +5,12 @@ fn main() { let x = wrong_generic(&y); let z: i32 = x; //~^ ERROR expected generic type parameter, found `&i32` -} -type WrongGeneric = impl 'static; -//~^ ERROR: at least one trait must be specified + type WrongGeneric = impl 'static; + //~^ ERROR: at least one trait must be specified -fn wrong_generic(t: T) -> WrongGeneric { - t - //~^ ERROR the parameter type `T` may not live long enough + fn wrong_generic(t: T) -> WrongGeneric { + t + //~^ ERROR the parameter type `T` may not live long enough + } } diff --git a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr index fa79e51e9..8c3a25dbf 100644 --- a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr +++ b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr @@ -1,8 +1,8 @@ error: at least one trait must be specified - --> $DIR/generic_type_does_not_live_long_enough.rs:10:24 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:28 | -LL | type WrongGeneric = impl 'static; - | ^^^^^^^^^^^^ +LL | type WrongGeneric = impl 'static; + | ^^^^^^^^^^^^ error[E0792]: expected generic type parameter, found `&i32` --> $DIR/generic_type_does_not_live_long_enough.rs:6:18 @@ -10,19 +10,19 @@ error[E0792]: expected generic type parameter, found `&i32` LL | let z: i32 = x; | ^ ... -LL | type WrongGeneric = impl 'static; - | - this generic parameter must be used with a generic type parameter +LL | type WrongGeneric = impl 'static; + | - this generic parameter must be used with a generic type parameter error[E0310]: the parameter type `T` may not live long enough - --> $DIR/generic_type_does_not_live_long_enough.rs:14:5 + --> $DIR/generic_type_does_not_live_long_enough.rs:13:9 | -LL | t - | ^ ...so that the type `T` will meet its required lifetime bounds +LL | t + | ^ ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound... | -LL | fn wrong_generic(t: T) -> WrongGeneric { - | +++++++++ +LL | fn wrong_generic(t: T) -> WrongGeneric { + | +++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr index c73288329..bc9280127 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr @@ -4,11 +4,11 @@ error[E0277]: the trait bound `T: Trait` is not satisfied LL | fn underconstrain(_: T) -> Underconstrained { | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T` | -note: required by a bound in `Underconstrained` +note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained.rs:6:26 | LL | type Underconstrained = impl Send; - | ^^^^^ required by this bound in `Underconstrained` + | ^^^^^ required by this bound help: consider restricting type parameter `T` | LL | fn underconstrain(_: T) -> Underconstrained { diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr index d77d978aa..fdc9ec090 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -4,11 +4,11 @@ error[E0277]: `U` doesn't implement `Debug` LL | fn underconstrained(_: U) -> Underconstrained { | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` | -note: required by a bound in `Underconstrained` +note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained2.rs:5:26 | LL | type Underconstrained = impl Send; - | ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained` + | ^^^^^^^^^^^^^^^ required by this bound help: consider restricting type parameter `U` | LL | fn underconstrained(_: U) -> Underconstrained { @@ -20,11 +20,11 @@ error[E0277]: `V` doesn't implement `Debug` LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` | -note: required by a bound in `Underconstrained2` +note: required by a bound on the type alias `Underconstrained2` --> $DIR/generic_underconstrained2.rs:13:27 | LL | type Underconstrained2 = impl Send; - | ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained2` + | ^^^^^^^^^^^^^^^ required by this bound help: consider restricting type parameter `V` | LL | fn underconstrained2(_: U, _: V) -> Underconstrained2 { diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs new file mode 100644 index 000000000..eb19b49c7 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs @@ -0,0 +1,28 @@ +//! This test shows that a field type that is a projection that resolves to an opaque, +//! is not a defining use. While we could substitute the struct generics, that would +//! mean we would have to walk all substitutions of an `Foo`, which can quickly +//! degenerate into looking at an exponential number of types depending on the complexity +//! of a program. + +#![feature(impl_trait_in_assoc_type)] + +struct Bar; + +trait Trait: Sized { + type Assoc; + fn foo() -> Foo; +} + +impl Trait for Bar { + type Assoc = impl std::fmt::Debug; + fn foo() -> Foo { + Foo { field: () } + //~^ ERROR: mismatched types + } +} + +struct Foo { + field: ::Assoc, +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr new file mode 100644 index 000000000..648efd1cb --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr @@ -0,0 +1,20 @@ +error[E0308]: mismatched types + --> $DIR/hidden_behind_projection_behind_struct_field.rs:19:22 + | +LL | type Assoc = impl std::fmt::Debug; + | -------------------- the expected opaque type +LL | fn foo() -> Foo { +LL | Foo { field: () } + | ^^ expected opaque type, found `()` + | + = note: expected opaque type `::Assoc` + found unit type `()` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/hidden_behind_projection_behind_struct_field.rs:18:8 + | +LL | fn foo() -> Foo { + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs new file mode 100644 index 000000000..58778702d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs @@ -0,0 +1,30 @@ +//! This test shows that the appearance of an opaque type +//! in the substs of a struct are enough to make it count +//! for making the function a defining use. It doesn't matter +//! if the opaque type is actually used in the field. + +#![feature(impl_trait_in_assoc_type)] +// check-pass + +use std::marker::PhantomData; + +struct Bar; + +trait Trait: Sized { + type Assoc; + fn foo() -> Foo; +} + +impl Trait for Bar { + type Assoc = impl std::fmt::Debug; + fn foo() -> Foo { + let foo: Foo<()> = Foo { field: PhantomData }; + foo + } +} + +struct Foo { + field: PhantomData, +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs new file mode 100644 index 000000000..e440dce5e --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs @@ -0,0 +1,26 @@ +//! This test shows that we can even follow projections +//! into associated types of the same impl if they are +//! indirectly mentioned in a struct field. + +#![feature(impl_trait_in_assoc_type)] +// check-pass + +struct Bar; + +trait Trait: Sized { + type Assoc; + fn foo() -> Foo; +} + +impl Trait for Bar { + type Assoc = impl std::fmt::Debug; + fn foo() -> Foo { + Foo { field: () } + } +} + +struct Foo { + field: ::Assoc, +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params.rs new file mode 100644 index 000000000..db1a3a1c7 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params.rs @@ -0,0 +1,28 @@ +//! This test checks that walking into binders +//! during opaque type collection does not ICE or raise errors. + +// edition: 2021 + +// check-pass + +#![feature(type_alias_impl_trait)] + +trait B { + type C; +} + +struct A; + +impl<'a> B for &'a A { + type C = (); +} + +struct Terminator; + +type Successors<'a> = impl std::fmt::Debug + 'a; + +impl Terminator { + fn successors(&self, _: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {} +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs new file mode 100644 index 000000000..f011e5b21 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs @@ -0,0 +1,35 @@ +//! This test checks the behaviour of walking into binders +//! and normalizing something behind them actually works. + +// edition: 2021 + +#![feature(type_alias_impl_trait)] + +trait B { + type C; +} + +struct A; + +impl<'a> B for &'a A { + type C = Tait; +} + +type Tait = impl std::fmt::Debug; + +struct Terminator; + +type Successors<'a> = impl std::fmt::Debug + 'a; + +impl Terminator { + fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> { + f = g; + //~^ ERROR item constrains opaque type that is not in its signature + } +} + +fn g(_: &()) -> String { + String::new() +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr new file mode 100644 index 000000000..39f584dd4 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr @@ -0,0 +1,15 @@ +error: item constrains opaque type that is not in its signature + --> $DIR/higher_kinded_params2.rs:26:13 + | +LL | f = g; + | ^ + | + = note: this item must mention the opaque type in its signature in order to be able to register hidden types +note: this item must mention the opaque type in its signature in order to be able to register hidden types + --> $DIR/higher_kinded_params2.rs:25:8 + | +LL | fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> { + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs new file mode 100644 index 000000000..6edfccaf7 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs @@ -0,0 +1,36 @@ +//! This test checks that we can't actually have an opaque type behind +//! a binder that references variables from that binder. + +// edition: 2021 + +#![feature(type_alias_impl_trait)] + +trait B { + type C; +} + +struct A; + +impl<'a> B for &'a A { + type C = Tait<'a>; +} + +type Tait<'a> = impl std::fmt::Debug + 'a; + +struct Terminator; + +type Successors<'a> = impl std::fmt::Debug + 'a; + +impl Terminator { + fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> { + f = g; + //~^ ERROR mismatched types + //~| ERROR item constrains opaque type that is not in its signature + } +} + +fn g(x: &()) -> &() { + x +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr new file mode 100644 index 000000000..14372d8f3 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr @@ -0,0 +1,28 @@ +error: item constrains opaque type that is not in its signature + --> $DIR/higher_kinded_params3.rs:26:13 + | +LL | f = g; + | ^ + | + = note: this item must mention the opaque type in its signature in order to be able to register hidden types +note: this item must mention the opaque type in its signature in order to be able to register hidden types + --> $DIR/higher_kinded_params3.rs:25:8 + | +LL | fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> { + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/higher_kinded_params3.rs:26:9 + | +LL | type Tait<'a> = impl std::fmt::Debug + 'a; + | ------------------------- the expected opaque type +... +LL | f = g; + | ^^^^^ one type is more general than the other + | + = note: expected fn pointer `for<'x> fn(&'x ()) -> Tait<'x>` + found fn pointer `for<'a> fn(&'a ()) -> &'a ()` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs new file mode 100644 index 000000000..a3f65146f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs @@ -0,0 +1,28 @@ +#![feature(impl_trait_in_assoc_type)] + +// We weren't checking that the trait and impl generics line up in the +// normalization-shortcut code in `OpaqueTypeCollector`. + +use std::ops::Deref; + +trait Foo { + type Bar<'a>; + + type Baz<'a>; + + fn test<'a>() -> Self::Bar<'a>; +} + +impl Foo for () { + type Bar<'a> = impl Deref>; + + type Baz = impl Sized; + //~^ ERROR type `Baz` has 1 type parameter but its trait declaration has 0 type parameters + //~| ERROR unconstrained opaque type + + fn test<'a>() -> Self::Bar<'a> { + &() + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr new file mode 100644 index 000000000..13f5d8b8e --- /dev/null +++ b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr @@ -0,0 +1,20 @@ +error[E0049]: type `Baz` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/impl-trait-in-type-alias-with-bad-substs.rs:19:14 + | +LL | type Baz<'a>; + | -- expected 0 type parameters +... +LL | type Baz = impl Sized; + | ^ found 1 type parameter + +error: unconstrained opaque type + --> $DIR/impl-trait-in-type-alias-with-bad-substs.rs:19:19 + | +LL | type Baz = impl Sized; + | ^^^^^^^^^^ + | + = note: `Baz` must be used in combination with a concrete type within the same impl + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs new file mode 100644 index 000000000..00d1a1a22 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs @@ -0,0 +1,14 @@ +#![feature(type_alias_impl_trait)] +#![feature(auto_traits)] + +type Alias = (impl Sized, u8); + +auto trait Trait {} +impl Trait for Alias {} +//~^ ERROR traits with a default impl, like `Trait`, cannot be implemented for type alias `Alias` + +fn _def() -> Alias { + (42, 42) +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr new file mode 100644 index 000000000..c312ee7de --- /dev/null +++ b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr @@ -0,0 +1,11 @@ +error[E0321]: traits with a default impl, like `Trait`, cannot be implemented for type alias `Alias` + --> $DIR/impl_for_weak_alias.rs:7:1 + | +LL | impl Trait for Alias {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: a trait object implements `Trait` if and only if `Trait` is one of the trait object's trait bounds + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0321`. diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.rs b/tests/ui/type-alias-impl-trait/inference-cycle.rs index 79caddf79..20175a4fe 100644 --- a/tests/ui/type-alias-impl-trait/inference-cycle.rs +++ b/tests/ui/type-alias-impl-trait/inference-cycle.rs @@ -2,8 +2,9 @@ #![allow(dead_code)] mod m { - type Foo = impl std::fmt::Debug; + pub type Foo = impl std::fmt::Debug; //~^ ERROR cycle detected + //~| ERROR cycle detected // Cycle: error today, but it'd be nice if it eventually worked @@ -13,10 +14,11 @@ mod m { pub fn bar() { is_send(foo()); // Today: error + //~^ ERROR: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits } - fn baz() { - let f: Foo = 22_u32; + fn baz() -> Foo { + () } fn is_send(_: T) {} diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr index b9d646b92..4d5f36747 100644 --- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr +++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr @@ -1,11 +1,11 @@ error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` - --> $DIR/inference-cycle.rs:5:16 + --> $DIR/inference-cycle.rs:5:20 | -LL | type Foo = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ +LL | pub type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ | note: ...which requires type-checking `m::bar`... - --> $DIR/inference-cycle.rs:15:9 + --> $DIR/inference-cycle.rs:16:9 | LL | is_send(foo()); // Today: error | ^^^^^^^ @@ -17,6 +17,48 @@ note: cycle used when checking item types in module `m` LL | mod m { | ^^^^^ -error: aborting due to previous error +error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` + --> $DIR/inference-cycle.rs:5:20 + | +LL | pub type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires type-checking `m::bar`... + --> $DIR/inference-cycle.rs:15:5 + | +LL | pub fn bar() { + | ^^^^^^^^^^^^ + = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in module `m` + --> $DIR/inference-cycle.rs:4:1 + | +LL | mod m { + | ^^^^^ + +error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits + --> $DIR/inference-cycle.rs:16:17 + | +LL | is_send(foo()); // Today: error + | ------- ^^^^^ + | | + | required by a bound introduced by this call + | +note: opaque type is declared here + --> $DIR/inference-cycle.rs:5:20 + | +LL | pub type Foo = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/inference-cycle.rs:15:12 + | +LL | pub fn bar() { + | ^^^ +note: required by a bound in `is_send` + --> $DIR/inference-cycle.rs:24:19 + | +LL | fn is_send(_: T) {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr index 2beed73cb..6ec5d13f8 100644 --- a/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr +++ b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr @@ -12,10 +12,10 @@ LL | let x: Self::Foo = (); = note: expected opaque type `<() as Foo>::Foo` found unit type `()` note: this item must have the opaque type in its signature in order to be able to register hidden types - --> $DIR/invalid_impl_trait_in_assoc_ty.rs:10:5 + --> $DIR/invalid_impl_trait_in_assoc_ty.rs:10:8 | LL | fn bar() { - | ^^^^^^^^ + | ^^^ error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/issue-109054.rs b/tests/ui/type-alias-impl-trait/issue-109054.rs new file mode 100644 index 000000000..1fbec47b1 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-109054.rs @@ -0,0 +1,22 @@ +// edition:2021 + +#![feature(type_alias_impl_trait)] + +struct CallMe; + +type ReturnType<'a> = impl std::future::Future + 'a; +type FnType = impl Fn(&u32) -> ReturnType; + +impl std::ops::Deref for CallMe { + type Target = FnType; + + fn deref(&self) -> &Self::Target { + fn inner(val: &u32) -> ReturnType { + async move { *val * 2 } + } + + &inner //~ ERROR: expected generic lifetime parameter, found `'_` + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-109054.stderr b/tests/ui/type-alias-impl-trait/issue-109054.stderr new file mode 100644 index 000000000..a611b9fe4 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-109054.stderr @@ -0,0 +1,12 @@ +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/issue-109054.rs:18:9 + | +LL | type ReturnType<'a> = impl std::future::Future + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | &inner + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs index 4a11bb502..b89c3e459 100644 --- a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs +++ b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs @@ -1,9 +1,10 @@ #![feature(type_alias_impl_trait)] +// check-pass + type Foo = impl Fn() -> Foo; fn foo() -> Foo { -//~^ ERROR: overflow evaluating the requirement foo } diff --git a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr deleted file mode 100644 index 0a34e8486..000000000 --- a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0275]: overflow evaluating the requirement `Foo: Sized` - --> $DIR/issue-53398-cyclic-types.rs:5:13 - | -LL | fn foo() -> Foo { - | ^^^ - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`) - = note: required because it appears within the type `fn() -> Foo {foo}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs index a3f126d56..a213dbba4 100644 --- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs +++ b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs @@ -1,19 +1,22 @@ #![feature(generators, generator_trait, rustc_attrs)] #![feature(type_alias_impl_trait)] -use std::ops::Generator; +// check-pass -type GenOnce = impl Generator; +mod gen { + use std::ops::Generator; -const fn const_generator(yielding: Y, returning: R) -> GenOnce { - move || { - yield yielding; + pub type GenOnce = impl Generator; - return returning; + pub const fn const_generator(yielding: Y, returning: R) -> GenOnce { + move || { + yield yielding; + + return returning; + } } } -const FOO: GenOnce = const_generator(10, 100); +const FOO: gen::GenOnce = gen::const_generator(10, 100); -#[rustc_error] -fn main() {} //~ ERROR +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr deleted file mode 100644 index eb1c9603a..000000000 --- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/issue-53678-generator-and-const-fn.rs:19:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/type-alias-impl-trait/issue-57961.rs b/tests/ui/type-alias-impl-trait/issue-57961.rs index 4aa5966ff..61af7a0f6 100644 --- a/tests/ui/type-alias-impl-trait/issue-57961.rs +++ b/tests/ui/type-alias-impl-trait/issue-57961.rs @@ -11,8 +11,8 @@ impl Foo for () { //~^ ERROR expected `IntoIter` to be an iterator that yields `X`, but it yields `u32` } -fn incoherent() { - let f: X = 22_i32; +fn incoherent() -> X { + 22_i32 } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-60564.rs b/tests/ui/type-alias-impl-trait/issue-60564.rs index c2f4c3708..48bd70bcc 100644 --- a/tests/ui/type-alias-impl-trait/issue-60564.rs +++ b/tests/ui/type-alias-impl-trait/issue-60564.rs @@ -17,6 +17,7 @@ where { type BitsIter = IterBitsIter; fn iter_bits(self, n: u8) -> Self::BitsIter { + //~^ ERROR non-defining opaque type use (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) //~^ ERROR expected generic type parameter, found `u8` } diff --git a/tests/ui/type-alias-impl-trait/issue-60564.stderr b/tests/ui/type-alias-impl-trait/issue-60564.stderr index f8fdb004d..d42495e93 100644 --- a/tests/ui/type-alias-impl-trait/issue-60564.stderr +++ b/tests/ui/type-alias-impl-trait/issue-60564.stderr @@ -1,5 +1,17 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/issue-60564.rs:19:34 + | +LL | fn iter_bits(self, n: u8) -> Self::BitsIter { + | ^^^^^^^^^^^^^^ argument `u8` is not a generic parameter + | +note: for this opaque type + --> $DIR/issue-60564.rs:8:30 + | +LL | type IterBitsIter = impl std::iter::Iterator; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0792]: expected generic type parameter, found `u8` - --> $DIR/issue-60564.rs:20:9 + --> $DIR/issue-60564.rs:21:9 | LL | type IterBitsIter = impl std::iter::Iterator; | - this generic parameter must be used with a generic type parameter @@ -7,6 +19,6 @@ LL | type IterBitsIter = impl std::iter::Iterator; LL | (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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/type-alias-impl-trait/issue-63263-closure-return.rs b/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs index 7414611a7..ddea7aeb6 100644 --- a/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs +++ b/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs @@ -8,6 +8,9 @@ pub type Closure = impl FnOnce(); -fn main() { +fn bop() -> Closure { || -> Closure { || () }; + panic!() } + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs b/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs index b91cbce37..7b3e9e124 100644 --- a/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs +++ b/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs @@ -11,7 +11,9 @@ type T = impl Sized; fn take(_: fn() -> T) {} -fn main() { +fn bop(_: T) { take(|| {}); take(|| {}); } + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs index 5e0a82a72..9dcdb5785 100644 --- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs +++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs @@ -7,7 +7,8 @@ trait Trait {} type Alias<'a, U> = impl Trait; fn f<'a>() -> Alias<'a, ()> {} -//~^ ERROR expected generic type parameter, found `()` +//~^ ERROR non-defining opaque type use +//~| ERROR expected generic type parameter, found `()` fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr index 271743a40..085bffe90 100644 --- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr +++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr @@ -1,3 +1,15 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/issue-68368-non-defining-use-2.rs:9:15 + | +LL | fn f<'a>() -> Alias<'a, ()> {} + | ^^^^^^^^^^^^^ argument `()` is not a generic parameter + | +note: for this opaque type + --> $DIR/issue-68368-non-defining-use-2.rs:7:21 + | +LL | type Alias<'a, U> = impl Trait; + | ^^^^^^^^^^^^^ + error[E0792]: expected generic type parameter, found `()` --> $DIR/issue-68368-non-defining-use-2.rs:9:29 | @@ -7,6 +19,6 @@ LL | LL | fn f<'a>() -> Alias<'a, ()> {} | ^^ -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/type-alias-impl-trait/issue-68368-non-defining-use.rs b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs index 3b32260c9..dfe2ee820 100644 --- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs +++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs @@ -8,6 +8,7 @@ type Alias<'a, U> = impl Trait; fn f<'a>() -> Alias<'a, ()> {} //~^ ERROR expected generic type parameter, found `()` +//~| ERROR non-defining opaque type use fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr index 4d9a8d6ee..ea704ffff 100644 --- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr +++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr @@ -1,3 +1,15 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/issue-68368-non-defining-use.rs:9:15 + | +LL | fn f<'a>() -> Alias<'a, ()> {} + | ^^^^^^^^^^^^^ argument `()` is not a generic parameter + | +note: for this opaque type + --> $DIR/issue-68368-non-defining-use.rs:7:21 + | +LL | type Alias<'a, U> = impl Trait; + | ^^^^^^^^^^^^^ + error[E0792]: expected generic type parameter, found `()` --> $DIR/issue-68368-non-defining-use.rs:9:29 | @@ -7,6 +19,6 @@ LL | LL | fn f<'a>() -> Alias<'a, ()> {} | ^^ -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/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs index 7657fe2fb..a0f8e48e2 100644 --- a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs +++ b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs @@ -1,4 +1,6 @@ -// Regression test for #69136 +//! Regression test for #69136 +//! This test checks that the unknown lifetime `'a` doesn't cause +//! ICEs after emitting the error. #![feature(type_alias_impl_trait)] @@ -17,7 +19,6 @@ impl WithAssoc for () { type Return = impl WithAssoc; //~^ ERROR use of undeclared lifetime name `'a` -fn my_fun() -> Return<()> {} -//~^ ERROR expected generic type parameter, found `()` +fn my_fun() -> Return {} fn main() {} diff --git a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr index d1250786d..b7af3f06d 100644 --- a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr +++ b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr @@ -1,5 +1,5 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:17:65 + --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:19:65 | LL | type Return = impl WithAssoc; | ^^ undeclared lifetime @@ -14,16 +14,6 @@ help: consider introducing lifetime `'a` here LL | type Return<'a, A> = impl WithAssoc; | +++ -error[E0792]: expected generic type parameter, found `()` - --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:20:27 - | -LL | type Return = impl WithAssoc; - | - this generic parameter must be used with a generic type parameter -... -LL | fn my_fun() -> Return<()> {} - | ^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0261, E0792. -For more information about an error, try `rustc --explain E0261`. +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/type-alias-impl-trait/issue-70121.rs b/tests/ui/type-alias-impl-trait/issue-70121.rs index dff0d89d4..bfd8d8872 100644 --- a/tests/ui/type-alias-impl-trait/issue-70121.rs +++ b/tests/ui/type-alias-impl-trait/issue-70121.rs @@ -1,5 +1,3 @@ -// check-pass - #![feature(type_alias_impl_trait)] pub type Successors<'a> = impl Iterator; @@ -17,6 +15,7 @@ impl<'a> Tr for &'a () { } pub fn kazusa<'a>() -> <&'a () as Tr>::Item { + //~^ ERROR item constrains opaque type that is not in its signature None.into_iter() } diff --git a/tests/ui/type-alias-impl-trait/issue-70121.stderr b/tests/ui/type-alias-impl-trait/issue-70121.stderr new file mode 100644 index 000000000..30c3ddd86 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/issue-70121.stderr @@ -0,0 +1,15 @@ +error: item constrains opaque type that is not in its signature + --> $DIR/issue-70121.rs:17:24 + | +LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item { + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this item must mention the opaque type in its signature in order to be able to register hidden types +note: this item must mention the opaque type in its signature in order to be able to register hidden types + --> $DIR/issue-70121.rs:17:8 + | +LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item { + | ^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs index b97e444c6..386b77d4d 100644 --- a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs +++ b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs @@ -1,6 +1,8 @@ // Regression test for issue #76202 // Tests that we don't ICE when we have a trait impl on a TAIT. +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next // check-pass #![feature(type_alias_impl_trait)] diff --git a/tests/ui/type-alias-impl-trait/issue-77179.rs b/tests/ui/type-alias-impl-trait/issue-77179.rs index 8d818d4a3..e7b04a489 100644 --- a/tests/ui/type-alias-impl-trait/issue-77179.rs +++ b/tests/ui/type-alias-impl-trait/issue-77179.rs @@ -2,7 +2,7 @@ #![feature(type_alias_impl_trait)] -type Pointer = impl std::ops::Deref; +type Pointer = impl std::ops::Deref; fn test() -> Pointer<_> { //~^ ERROR: the placeholder `_` is not allowed within types diff --git a/tests/ui/type-alias-impl-trait/multi-error.rs b/tests/ui/type-alias-impl-trait/multi-error.rs new file mode 100644 index 000000000..b5ff06572 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/multi-error.rs @@ -0,0 +1,23 @@ +//! This test checks that we don't follow up +//! with type mismatch errors of opaque types +//! with their hidden types if we failed the +//! defining scope check at the signature level. + +#![feature(impl_trait_in_assoc_type)] + +trait Foo { + type Bar; + type Baz; + fn foo() -> (Self::Bar, Self::Baz); +} + +impl Foo for () { + type Bar = impl Sized; + type Baz = impl Sized; + fn foo() -> (Self::Bar, Self::Baz) { + //~^ ERROR non-defining opaque type use + ((), ()) + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/multi-error.stderr b/tests/ui/type-alias-impl-trait/multi-error.stderr new file mode 100644 index 000000000..b2de2effe --- /dev/null +++ b/tests/ui/type-alias-impl-trait/multi-error.stderr @@ -0,0 +1,15 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/multi-error.rs:17:17 + | +LL | fn foo() -> (Self::Bar, Self::Baz) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument `u32` is not a generic parameter + | +note: for this opaque type + --> $DIR/multi-error.rs:15:19 + | +LL | type Bar = impl Sized; + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs index 9ae2c34b9..da845e861 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs @@ -8,7 +8,6 @@ type X = impl Into<&'static A>; fn f(a: &'static A, b: B) -> (X, X) { //~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied - //~| ERROR concrete type differs from previous defining opaque type use (a, a) } diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr index 0d24d42ba..66a6b0bbf 100644 --- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr +++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr @@ -10,15 +10,6 @@ help: consider introducing a `where` clause, but there might be an alternative b LL | fn f(a: &'static A, b: B) -> (X, X) where &'static B: From<&A> { | ++++++++++++++++++++++++++ -error: concrete type differs from previous defining opaque type use - --> $DIR/multiple-def-uses-in-one-fn.rs:9:45 - | -LL | fn f(a: &'static A, b: B) -> (X, X) { - | ^^^^^^^^^^^^^^^^^^ - | | - | expected `&B`, got `&A` - | this expression supplies two conflicting concrete types for the same opaque type - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr index f4d96038d..dccf84362 100644 --- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -8,8 +8,8 @@ LL | () | -- return type was inferred to be `()` here | = help: the following other types implement trait `Foo`: - <() as Foo<()>> <() as Foo> + <() as Foo<()>> error: aborting due to previous error diff --git a/tests/ui/type-alias-impl-trait/nested_in_closure.rs b/tests/ui/type-alias-impl-trait/nested_in_closure.rs new file mode 100644 index 000000000..362f3d53e --- /dev/null +++ b/tests/ui/type-alias-impl-trait/nested_in_closure.rs @@ -0,0 +1,17 @@ +#![feature(type_alias_impl_trait)] +// check-pass + +fn main() { + let x = || { + type Tait = impl Sized; + let y: Tait = (); + }; + + let y = || { + type Tait = impl std::fmt::Debug; + let y: Tait = (); + y + }; + let mut z = y(); + z = (); +} diff --git a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs index 60b6e1aac..07607516c 100644 --- a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs +++ b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs @@ -10,11 +10,11 @@ mod my_mod { 5i32 } - pub fn get_foot() -> Foot { + pub fn get_foot(_: Foo) -> Foot { get_foo() //~ ERROR opaque type's hidden type cannot be another opaque type } } fn main() { - let _: my_mod::Foot = my_mod::get_foot(); + let _: my_mod::Foot = my_mod::get_foot(my_mod::get_foo()); } diff --git a/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr b/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr index ae03a5b3e..863282a0f 100644 --- a/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr +++ b/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr @@ -11,6 +11,11 @@ LL | let _: &str = bomp(); | = note: expected reference `&str` found opaque type `Boo` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/no_revealing_outside_defining_module.rs:14:4 + | +LL | fn bomp2() { + | ^^^^^ error[E0308]: mismatched types --> $DIR/no_revealing_outside_defining_module.rs:19:5 @@ -25,6 +30,11 @@ LL | "" | = note: expected opaque type `Boo` found reference `&'static str` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/no_revealing_outside_defining_module.rs:18:4 + | +LL | fn bomp() -> boo::Boo { + | ^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/type-alias-impl-trait/non-defining-method.rs b/tests/ui/type-alias-impl-trait/non-defining-method.rs new file mode 100644 index 000000000..2f4a7052f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/non-defining-method.rs @@ -0,0 +1,21 @@ +//! This test checks that we don't follow up +//! with type mismatch errors of opaque types +//! with their hidden types if we failed the +//! defining scope check at the signature level. + +#![feature(impl_trait_in_assoc_type)] + +trait Foo { + type Bar; + fn foo() -> Self::Bar; + fn bar() -> Self::Bar; +} + +impl Foo for () { + type Bar = impl Sized; + fn foo() -> Self::Bar {} + //~^ ERROR non-defining opaque type use + fn bar() -> Self::Bar {} +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/non-defining-method.stderr b/tests/ui/type-alias-impl-trait/non-defining-method.stderr new file mode 100644 index 000000000..ed5590f9d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/non-defining-method.stderr @@ -0,0 +1,15 @@ +error[E0792]: non-defining opaque type use in defining scope + --> $DIR/non-defining-method.rs:16:17 + | +LL | fn foo() -> Self::Bar {} + | ^^^^^^^^^^^^^^ argument `u32` is not a generic parameter + | +note: for this opaque type + --> $DIR/non-defining-method.rs:15:19 + | +LL | type Bar = impl Sized; + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr new file mode 100644 index 000000000..dd2737c70 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr @@ -0,0 +1,55 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/normalize-hidden-types.rs:25:20 + | +LL | fn define() -> Opaque { + | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` + | +note: previous use here + --> $DIR/normalize-hidden-types.rs:27:9 + | +LL | dyn_hoops::<_>(0) + | ^^^^^^^^^^^^^^^^^ + +error: concrete type differs from previous defining opaque type use + --> $DIR/normalize-hidden-types.rs:34:22 + | +LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } + | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` + | +note: previous use here + --> $DIR/normalize-hidden-types.rs:34:31 + | +LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } + | ^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/normalize-hidden-types.rs:44:25 + | +LL | type Opaque = impl Sized; + | ---------- the expected opaque type +... +LL | let _: Opaque = dyn_hoops::(0); + | ------ ^^^^^^^^^^^^^^^^^^ expected opaque type, found `*const dyn FnOnce(())` + | | + | expected due to this + | + = note: expected opaque type `typeck::Opaque` + found raw pointer `*const (dyn FnOnce(()) + 'static)` + = help: consider constraining the associated type `::Gat<'_>` to `()` or calling a method that returns `::Gat<'_>` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error: concrete type differs from previous defining opaque type use + --> $DIR/normalize-hidden-types.rs:54:25 + | +LL | let _: Opaque = dyn_hoops::<_>(0); + | ^^^^^^^^^^^^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` + | +note: previous use here + --> $DIR/normalize-hidden-types.rs:56:9 + | +LL | None + | ^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs new file mode 100644 index 000000000..8d8054644 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs @@ -0,0 +1,60 @@ +// Regression test for #112691 +// +// revisions: current next +// [next] compile-flags: -Ztrait-solver=next +// [next] check-pass +// [current]: known-bug: #112691 + +#![feature(type_alias_impl_trait)] + +trait Trait { + type Gat<'lt>; +} + +impl Trait for u8 { + type Gat<'lt> = (); +} + +fn dyn_hoops(_: T) -> *const dyn FnOnce(T::Gat<'_>) { + loop {} +} + +mod typeof_1 { + use super::*; + type Opaque = impl Sized; + fn define() -> Opaque { + //[current]~^ ERROR concrete type differs + dyn_hoops::<_>(0) + } +} + +mod typeof_2 { + use super::*; + type Opaque = impl Sized; + fn define_1() -> Opaque { dyn_hoops::<_>(0) } + //[current]~^ ERROR concrete type differs + fn define_2() -> Opaque { dyn_hoops::(0) } +} + +mod typeck { + use super::*; + type Opaque = impl Sized; + fn define() -> Option { + let _: Opaque = dyn_hoops::<_>(0); + let _: Opaque = dyn_hoops::(0); + //[current]~^ ERROR mismatched types + None + } +} + +mod borrowck { + use super::*; + type Opaque = impl Sized; + fn define() -> Option { + let _: Opaque = dyn_hoops::<_>(0); + //[current]~^ ERROR concrete type differs + None + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs new file mode 100644 index 000000000..131f8d999 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs @@ -0,0 +1,33 @@ +#![feature(impl_trait_in_assoc_type)] + +trait Foo { + type Assoc; + + fn test() -> u32; +} + +struct DefinesOpaque; +impl Foo for () { + type Assoc = impl Sized; + + // This test's return type is `u32`, *not* the opaque that is defined above. + // Previously we were only checking that the self type of the assoc matched, + // but this doesn't account for other impls with different trait substs. + fn test() -> <() as Foo>::Assoc { + let _: >::Assoc = ""; + //~^ ERROR mismatched types + + 1 + } +} + +struct NoOpaques; +impl Foo for () { + type Assoc = u32; + + fn test() -> u32 { + 1 + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr new file mode 100644 index 000000000..a621bb519 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/not-matching-trait-refs-isnt-defining.rs:17:54 + | +LL | type Assoc = impl Sized; + | ---------- the expected opaque type +... +LL | let _: >::Assoc = ""; + | ----------------------------------- ^^ expected opaque type, found `&str` + | | + | expected due to this + | + = note: expected opaque type `<() as Foo>::Assoc` + found reference `&'static str` +note: this item must have the opaque type in its signature in order to be able to register hidden types + --> $DIR/not-matching-trait-refs-isnt-defining.rs:16:8 + | +LL | fn test() -> <() as Foo>::Assoc { + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/obligation_ice.rs b/tests/ui/type-alias-impl-trait/obligation_ice.rs new file mode 100644 index 000000000..5aef04ff1 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/obligation_ice.rs @@ -0,0 +1,17 @@ +#![feature(type_alias_impl_trait)] +// check-pass + +use std::iter::{once, Chain}; + +trait Trait<'a, 'b: 'a> {} + +impl<'a, 'b: 'a, T> Trait<'a, 'b> for std::iter::Cloned {} + +type I<'a, 'b: 'a, A: Trait<'a, 'b>> = Chain>; +fn test2<'a, 'b, A: Trait<'a, 'b> + Iterator>(x: A) -> I<'a, 'b, A> { + x.chain(once("5")) +} + +fn main() { + assert_eq!(vec!["1", "3", "5"], test2(["1", "3"].iter().cloned()).collect::>()); +} diff --git a/tests/ui/type-alias-impl-trait/privacy.rs b/tests/ui/type-alias-impl-trait/privacy.rs new file mode 100644 index 000000000..aa092f6f8 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/privacy.rs @@ -0,0 +1,8 @@ +#![feature(type_alias_impl_trait)] + +type Foo = (impl Sized, u8); +pub fn foo() -> Foo { + //~^ ERROR private type alias `Foo` in public interface + (42, 42) +} +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/privacy.stderr b/tests/ui/type-alias-impl-trait/privacy.stderr new file mode 100644 index 000000000..e8c6039cd --- /dev/null +++ b/tests/ui/type-alias-impl-trait/privacy.stderr @@ -0,0 +1,11 @@ +error[E0446]: private type alias `Foo` in public interface + --> $DIR/privacy.rs:4:1 + | +LL | type Foo = (impl Sized, u8); + | -------- `Foo` declared as private +LL | pub fn foo() -> Foo { + | ^^^^^^^^^^^^^^^^^^^ can't leak private type alias + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0446`. diff --git a/tests/ui/type-alias-impl-trait/reveal_local.rs b/tests/ui/type-alias-impl-trait/reveal_local.rs index 7ecb55353..7943bb240 100644 --- a/tests/ui/type-alias-impl-trait/reveal_local.rs +++ b/tests/ui/type-alias-impl-trait/reveal_local.rs @@ -4,22 +4,28 @@ use std::fmt::Debug; type Foo = impl Debug; //~^ ERROR cycle detected +//~| ERROR cycle detected +//~| ERROR cycle detected -fn is_send() { } +fn is_send() {} fn not_good() { // Error: this function does not constrain `Foo` to any particular // hidden type, so it cannot rely on `Send` being true. is_send::(); + //~^ ERROR: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits } -fn not_gooder() { +fn not_gooder() -> Foo { // Constrain `Foo = u32` let x: Foo = 22_u32; // while we could know this from the hidden type, it would // need extra roundabout logic to support it. is_send::(); + //~^ ERROR: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits + + x } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr index 27fded333..0c5ef4a6f 100644 --- a/tests/ui/type-alias-impl-trait/reveal_local.stderr +++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr @@ -5,7 +5,7 @@ LL | type Foo = impl Debug; | ^^^^^^^^^^ | note: ...which requires type-checking `not_good`... - --> $DIR/reveal_local.rs:13:5 + --> $DIR/reveal_local.rs:15:5 | LL | is_send::(); | ^^^^^^^^^^^^^^ @@ -23,6 +23,98 @@ LL | | LL | | fn main() {} | |____________^ -error: aborting due to previous error +error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` + --> $DIR/reveal_local.rs:5:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `not_good`... + --> $DIR/reveal_local.rs:12:1 + | +LL | fn not_good() { + | ^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/reveal_local.rs:1:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | use std::fmt::Debug; +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits + --> $DIR/reveal_local.rs:15:15 + | +LL | is_send::(); + | ^^^ + | +note: opaque type is declared here + --> $DIR/reveal_local.rs:5:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/reveal_local.rs:12:4 + | +LL | fn not_good() { + | ^^^^^^^^ +note: required by a bound in `is_send` + --> $DIR/reveal_local.rs:10:15 + | +LL | fn is_send() {} + | ^^^^ required by this bound in `is_send` + +error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` + --> $DIR/reveal_local.rs:5:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + | +note: ...which requires type-checking `not_gooder`... + --> $DIR/reveal_local.rs:19:1 + | +LL | fn not_gooder() -> Foo { + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/reveal_local.rs:1:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | use std::fmt::Debug; +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits + --> $DIR/reveal_local.rs:25:15 + | +LL | is_send::(); + | ^^^ + | +note: opaque type is declared here + --> $DIR/reveal_local.rs:5:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ +note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule + --> $DIR/reveal_local.rs:19:4 + | +LL | fn not_gooder() -> Foo { + | ^^^^^^^^^^ +note: required by a bound in `is_send` + --> $DIR/reveal_local.rs:10:15 + | +LL | fn is_send() {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.rs b/tests/ui/type-alias-impl-trait/self-referential-3.rs index d40715717..18f09b548 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-3.rs +++ b/tests/ui/type-alias-impl-trait/self-referential-3.rs @@ -1,9 +1,9 @@ -// run-pass #![feature(type_alias_impl_trait)] type Bar<'a, 'b> = impl PartialEq> + std::fmt::Debug; fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + //~^ ERROR can't compare `&i32` with `Bar<'a, 'b>` i } diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.stderr b/tests/ui/type-alias-impl-trait/self-referential-3.stderr new file mode 100644 index 000000000..4155a114b --- /dev/null +++ b/tests/ui/type-alias-impl-trait/self-referential-3.stderr @@ -0,0 +1,15 @@ +error[E0277]: can't compare `&i32` with `Bar<'a, 'b>` + --> $DIR/self-referential-3.rs:5:31 + | +LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'a, 'b>` +LL | +LL | i + | - return type was inferred to be `&i32` here + | + = help: the trait `PartialEq>` is not implemented for `&i32` + = help: the trait `PartialEq` is implemented for `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/type-alias-impl-trait/self-referential.rs b/tests/ui/type-alias-impl-trait/self-referential.rs index 3ff5406a3..34b7c24df 100644 --- a/tests/ui/type-alias-impl-trait/self-referential.rs +++ b/tests/ui/type-alias-impl-trait/self-referential.rs @@ -10,7 +10,7 @@ fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { type Foo<'a, 'b> = (i32, impl PartialEq> + std::fmt::Debug); fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - //~^ ERROR can't compare `&i32` with `(i32, &i32)` + //~^ ERROR can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})` (42, i) } diff --git a/tests/ui/type-alias-impl-trait/self-referential.stderr b/tests/ui/type-alias-impl-trait/self-referential.stderr index aff489d70..9a17d495b 100644 --- a/tests/ui/type-alias-impl-trait/self-referential.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential.stderr @@ -10,16 +10,16 @@ LL | i = help: the trait `PartialEq>` is not implemented for `&i32` = help: the trait `PartialEq` is implemented for `i32` -error[E0277]: can't compare `&i32` with `(i32, &i32)` +error[E0277]: can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})` --> $DIR/self-referential.rs:12:31 | LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - | ^^^^^^^^^^^ no implementation for `&i32 == (i32, &i32)` + | ^^^^^^^^^^^ no implementation for `&i32 == (i32, Foo<'a, 'b>::{opaque#0})` LL | LL | (42, i) | ------- return type was inferred to be `(i32, &i32)` here | - = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` + = help: the trait `PartialEq<(i32, Foo<'a, 'b>::{opaque#0})>` is not implemented for `&i32` = help: the trait `PartialEq` is implemented for `i32` error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs index 07c891f06..4e7388517 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs @@ -4,20 +4,20 @@ // Regression test for issue #61863 -pub trait MyTrait {} +trait MyTrait {} #[derive(Debug)] -pub struct MyStruct { +struct MyStruct { v: u64, } impl MyTrait for MyStruct {} -pub fn bla() -> TE { +fn bla() -> TE { return MyStruct { v: 1 }; } -pub fn bla2() -> TE { +fn bla2() -> TE { bla() } diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.rs b/tests/ui/type-alias-impl-trait/type_of_a_let.rs index 4e9d1788b..361611715 100644 --- a/tests/ui/type-alias-impl-trait/type_of_a_let.rs +++ b/tests/ui/type-alias-impl-trait/type_of_a_let.rs @@ -5,16 +5,16 @@ use std::fmt::Debug; type Foo = impl Debug; -fn foo1() -> u32 { +fn foo1() -> (u32, Foo) { let x: Foo = 22_u32; - x + (x, todo!()) } -fn foo2() -> u32 { +fn foo2() -> (u32, Foo) { let x: Foo = 22_u32; let y: Foo = x; same_type((x, y)); //~ ERROR use of moved value - y //~ ERROR use of moved value + (y, todo!()) //~ ERROR use of moved value } fn same_type(x: (T, T)) {} diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.stderr b/tests/ui/type-alias-impl-trait/type_of_a_let.stderr index 1dabe4586..7d7cad874 100644 --- a/tests/ui/type-alias-impl-trait/type_of_a_let.stderr +++ b/tests/ui/type-alias-impl-trait/type_of_a_let.stderr @@ -9,14 +9,14 @@ LL | same_type((x, y)); | ^ value used here after move error[E0382]: use of moved value: `y` - --> $DIR/type_of_a_let.rs:17:5 + --> $DIR/type_of_a_let.rs:17:6 | LL | let y: Foo = x; | - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait LL | same_type((x, y)); | - value moved here -LL | y - | ^ value used here after move +LL | (y, todo!()) + | ^ value used here after move error: aborting due to 2 previous errors diff --git a/tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs b/tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs new file mode 100644 index 000000000..5d0e456d9 --- /dev/null +++ b/tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs @@ -0,0 +1,18 @@ +// run-pass +// Verify that PartialEq implementations do not break type inference when +// accepting types with different allocators + +use std::rc::Rc; +use std::sync::Arc; + + +fn main() { + let boxed: Vec> = vec![]; + assert_eq!(boxed, vec![]); + + let rc: Vec> = vec![]; + assert_eq!(rc, vec![]); + + let arc: Vec> = vec![]; + assert_eq!(arc, vec![]); +} diff --git a/tests/ui/type/type-check-defaults.stderr b/tests/ui/type/type-check-defaults.stderr index 9ba63ffe9..10d600cbf 100644 --- a/tests/ui/type/type-check-defaults.stderr +++ b/tests/ui/type/type-check-defaults.stderr @@ -66,10 +66,10 @@ LL | trait ProjectionPred> where T::Item : Add {} | = help: the trait `Add` is not implemented for `i32` = help: the following other types implement trait `Add`: + + > <&'a i32 as Add> <&i32 as Add<&i32>> - > - error: aborting due to 7 previous errors diff --git a/tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.rs b/tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.rs new file mode 100644 index 000000000..0c2d71707 --- /dev/null +++ b/tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.rs @@ -0,0 +1,29 @@ +pub trait NSWindow: Sized { + fn frame(self) -> () { + unimplemented!() + } + fn setFrame_display_(self, display: ()) {} +} +impl NSWindow for () {} + +pub struct NSRect {} + +use std::ops::Deref; +struct MainThreadSafe(T); +impl Deref for MainThreadSafe { + type Target = T; + + fn deref(&self) -> &T { + unimplemented!() + } +} + +fn main() { + || { + let ns_window = MainThreadSafe(()); + // Don't record adjustments twice for `*ns_window` + (*ns_window).frame(); + ns_window.setFrame_display_(0); + //~^ ERROR mismatched types + }; +} diff --git a/tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.stderr b/tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.stderr new file mode 100644 index 000000000..02e87d701 --- /dev/null +++ b/tests/ui/typeck/dont-record-adjustments-when-pointing-at-arg.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/dont-record-adjustments-when-pointing-at-arg.rs:26:37 + | +LL | ns_window.setFrame_display_(0); + | ----------------- ^ expected `()`, found integer + | | + | arguments to this method are incorrect + | +note: method defined here + --> $DIR/dont-record-adjustments-when-pointing-at-arg.rs:5:8 + | +LL | fn setFrame_display_(self, display: ()) {} + | ^^^^^^^^^^^^^^^^^ ----------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-106929.rs b/tests/ui/typeck/issue-106929.rs new file mode 100644 index 000000000..91342229a --- /dev/null +++ b/tests/ui/typeck/issue-106929.rs @@ -0,0 +1,13 @@ +struct Client; + +impl Client { + fn post(&self, _: T, _: T) {} +} + +fn f() { + let c = Client; + post(c, ()); + //~^ ERROR cannot find function `post` in this scope +} + +fn main() {} diff --git a/tests/ui/typeck/issue-106929.stderr b/tests/ui/typeck/issue-106929.stderr new file mode 100644 index 000000000..f744e5a41 --- /dev/null +++ b/tests/ui/typeck/issue-106929.stderr @@ -0,0 +1,15 @@ +error[E0425]: cannot find function `post` in this scope + --> $DIR/issue-106929.rs:9:5 + | +LL | post(c, ()); + | ^^^^ not found in this scope + | +help: use the `.` operator to call the method `post` on `&Client` + | +LL - post(c, ()); +LL + c.post(()); + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/typeck/issue-112252-ptr-arithmetics-help.fixed b/tests/ui/typeck/issue-112252-ptr-arithmetics-help.fixed new file mode 100644 index 000000000..bdb884f54 --- /dev/null +++ b/tests/ui/typeck/issue-112252-ptr-arithmetics-help.fixed @@ -0,0 +1,10 @@ +// run-rustfix + +fn main() { + let _ptr1: *const u32 = std::ptr::null(); + let _ptr2: *const u32 = std::ptr::null(); + let _a = _ptr1.wrapping_add(5); //~ ERROR cannot add + let _b = _ptr1.wrapping_sub(5); //~ ERROR cannot subtract + let _c = unsafe { _ptr2.offset_from(_ptr1) }; //~ ERROR cannot subtract + let _d = _ptr1.wrapping_add(5); //~ ERROR cannot index +} diff --git a/tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs b/tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs new file mode 100644 index 000000000..cf68850cc --- /dev/null +++ b/tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs @@ -0,0 +1,10 @@ +// run-rustfix + +fn main() { + let _ptr1: *const u32 = std::ptr::null(); + let _ptr2: *const u32 = std::ptr::null(); + let _a = _ptr1 + 5; //~ ERROR cannot add + let _b = _ptr1 - 5; //~ ERROR cannot subtract + let _c = _ptr2 - _ptr1; //~ ERROR cannot subtract + let _d = _ptr1[5]; //~ ERROR cannot index +} diff --git a/tests/ui/typeck/issue-112252-ptr-arithmetics-help.stderr b/tests/ui/typeck/issue-112252-ptr-arithmetics-help.stderr new file mode 100644 index 000000000..c55930da2 --- /dev/null +++ b/tests/ui/typeck/issue-112252-ptr-arithmetics-help.stderr @@ -0,0 +1,54 @@ +error[E0369]: cannot add `{integer}` to `*const u32` + --> $DIR/issue-112252-ptr-arithmetics-help.rs:6:20 + | +LL | let _a = _ptr1 + 5; + | ----- ^ - {integer} + | | + | *const u32 + | +help: consider using `wrapping_add` or `add` for pointer + {integer} + | +LL | let _a = _ptr1.wrapping_add(5); + | ~~~~~~~~~~~~~~ + + +error[E0369]: cannot subtract `{integer}` from `*const u32` + --> $DIR/issue-112252-ptr-arithmetics-help.rs:7:20 + | +LL | let _b = _ptr1 - 5; + | ----- ^ - {integer} + | | + | *const u32 + | +help: consider using `wrapping_sub` or `sub` for pointer - {integer} + | +LL | let _b = _ptr1.wrapping_sub(5); + | ~~~~~~~~~~~~~~ + + +error[E0369]: cannot subtract `*const u32` from `*const u32` + --> $DIR/issue-112252-ptr-arithmetics-help.rs:8:20 + | +LL | let _c = _ptr2 - _ptr1; + | ----- ^ ----- *const u32 + | | + | *const u32 + | +help: consider using `offset_from` for pointer - pointer if the pointers point to the same allocation + | +LL | let _c = unsafe { _ptr2.offset_from(_ptr1) }; + | ++++++++ ~~~~~~~~~~~~~ +++ + +error[E0608]: cannot index into a value of type `*const u32` + --> $DIR/issue-112252-ptr-arithmetics-help.rs:9:14 + | +LL | let _d = _ptr1[5]; + | ^^^^^^^^ + | +help: consider using `wrapping_add` or `add` for indexing into raw pointer + | +LL | let _d = _ptr1.wrapping_add(5); + | ~~~~~~~~~~~~~~ ~ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0369, E0608. +For more information about an error, try `rustc --explain E0369`. diff --git a/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs new file mode 100644 index 000000000..3cb011dc0 --- /dev/null +++ b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.rs @@ -0,0 +1,9 @@ +// Previously, the while loop with an assignment statement (mistakenly) as the condition +// which has a place expr as the LHS would trigger an ICE in typeck. +// Reduced from https://github.com/rust-lang/rust/issues/112385. + +fn main() { + let foo = Some(()); + while Some(foo) = None {} + //~^ ERROR mismatched types +} diff --git a/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr new file mode 100644 index 000000000..cf2648d08 --- /dev/null +++ b/tests/ui/typeck/issue-112385-while-assign-lhs-place-expr-ice.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-112385-while-assign-lhs-place-expr-ice.rs:7:11 + | +LL | while Some(foo) = None {} + | ^^^^^^^^^^^^^^^^ expected `bool`, found `()` + | +help: consider adding `let` + | +LL | while let Some(foo) = None {} + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-1871.rs b/tests/ui/typeck/issue-1871.rs new file mode 100644 index 000000000..f7a2bdd56 --- /dev/null +++ b/tests/ui/typeck/issue-1871.rs @@ -0,0 +1,12 @@ +// Tests that we don't generate a spurious error about f.honk's type +// being undeterminable +fn main() { + let f = 42; + + let _g = if f < 5 { + f.honk() //~ ERROR no method named `honk` found + } + else { + () + }; +} diff --git a/tests/ui/typeck/issue-1871.stderr b/tests/ui/typeck/issue-1871.stderr new file mode 100644 index 000000000..b774ca22d --- /dev/null +++ b/tests/ui/typeck/issue-1871.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `honk` found for type `{integer}` in the current scope + --> $DIR/issue-1871.rs:7:9 + | +LL | f.honk() + | ^^^^ method not found in `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/typeck/issue-2063-resource.rs b/tests/ui/typeck/issue-2063-resource.rs new file mode 100644 index 000000000..1d0527447 --- /dev/null +++ b/tests/ui/typeck/issue-2063-resource.rs @@ -0,0 +1,14 @@ +// check-pass +#![allow(dead_code)] +// test that autoderef of a type like this does not +// cause compiler to loop. Note that no instances +// of such a type could ever be constructed. + +struct S { + x: X, + to_str: (), +} + +struct X(Box); + +fn main() {} diff --git a/tests/ui/typeck/issue-2063.rs b/tests/ui/typeck/issue-2063.rs new file mode 100644 index 000000000..f08f9d4cf --- /dev/null +++ b/tests/ui/typeck/issue-2063.rs @@ -0,0 +1,22 @@ +// run-pass +// test that autoderef of a type like this does not +// cause compiler to loop. Note that no instances +// of such a type could ever be constructed. + +struct T(#[allow(unused_tuple_struct_fields)] Box); + +trait ToStr2 { + fn my_to_string(&self) -> String; +} + +impl ToStr2 for T { + fn my_to_string(&self) -> String { "t".to_string() } +} + +#[allow(dead_code)] +fn new_t(x: T) { + x.my_to_string(); +} + +fn main() { +} diff --git a/tests/ui/typeck/issue-81293.stderr b/tests/ui/typeck/issue-81293.stderr index 6976be711..292c63070 100644 --- a/tests/ui/typeck/issue-81293.stderr +++ b/tests/ui/typeck/issue-81293.stderr @@ -21,10 +21,10 @@ LL | a = c + b * 5; | = help: the trait `Add` is not implemented for `usize` = help: the following other types implement trait `Add`: + + > <&'a usize as Add> <&usize as Add<&usize>> - > - error: aborting due to 3 previous errors diff --git a/tests/ui/typeck/issue-86721-return-expr-ice.rs b/tests/ui/typeck/issue-86721-return-expr-ice.rs index cd7135f18..4f882f7a3 100644 --- a/tests/ui/typeck/issue-86721-return-expr-ice.rs +++ b/tests/ui/typeck/issue-86721-return-expr-ice.rs @@ -2,7 +2,7 @@ // revisions: rev1 rev2 #![cfg_attr(any(), rev1, rev2)] -#![crate_type="lib"] +#![crate_type = "lib"] #[cfg(any(rev1))] trait T { diff --git a/tests/ui/typeck/issue-89856.stderr b/tests/ui/typeck/issue-89856.stderr index bd76f1724..0db3e67ed 100644 --- a/tests/ui/typeck/issue-89856.stderr +++ b/tests/ui/typeck/issue-89856.stderr @@ -13,7 +13,7 @@ note: function defined here | LL | fn take_str_maybe(_: Option<&str>) { } | ^^^^^^^^^^^^^^ --------------- -help: try converting the passed type into a `&str` +help: try using `.as_deref()` to convert `Option` to `Option<&str>` | LL | take_str_maybe(option.as_deref()); | +++++++++++ diff --git a/tests/ui/typeck/issue-90101.stderr b/tests/ui/typeck/issue-90101.stderr index d2729d853..484089f9e 100644 --- a/tests/ui/typeck/issue-90101.stderr +++ b/tests/ui/typeck/issue-90101.stderr @@ -7,11 +7,11 @@ LL | func(Path::new("hello").to_path_buf().to_string_lossy(), "world") | required by a bound introduced by this call | = help: the following other types implement trait `From`: - > >> >> > > + > = note: required for `Cow<'_, str>` to implement `Into` note: required by a bound in `func` --> $DIR/issue-90101.rs:3:20 diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.fixed b/tests/ui/typeck/ptr-null-mutability-suggestions.fixed new file mode 100644 index 000000000..d00536b29 --- /dev/null +++ b/tests/ui/typeck/ptr-null-mutability-suggestions.fixed @@ -0,0 +1,11 @@ +// run-rustfix + +#[allow(unused_imports)] +use std::ptr; + +fn expecting_null_mut(_: *mut u8) {} + +fn main() { + expecting_null_mut(core::ptr::null_mut()); + //~^ ERROR mismatched types +} diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.rs b/tests/ui/typeck/ptr-null-mutability-suggestions.rs new file mode 100644 index 000000000..ea3066d22 --- /dev/null +++ b/tests/ui/typeck/ptr-null-mutability-suggestions.rs @@ -0,0 +1,11 @@ +// run-rustfix + +#[allow(unused_imports)] +use std::ptr; + +fn expecting_null_mut(_: *mut u8) {} + +fn main() { + expecting_null_mut(ptr::null()); + //~^ ERROR mismatched types +} diff --git a/tests/ui/typeck/ptr-null-mutability-suggestions.stderr b/tests/ui/typeck/ptr-null-mutability-suggestions.stderr new file mode 100644 index 000000000..705b029bd --- /dev/null +++ b/tests/ui/typeck/ptr-null-mutability-suggestions.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/ptr-null-mutability-suggestions.rs:9:24 + | +LL | expecting_null_mut(ptr::null()); + | ------------------ ^^^^^^^^^^^ + | | | + | | types differ in mutability + | | help: consider using `core::ptr::null_mut` instead: `core::ptr::null_mut()` + | arguments to this function are incorrect + | + = note: expected raw pointer `*mut u8` + found raw pointer `*const _` +note: function defined here + --> $DIR/ptr-null-mutability-suggestions.rs:6:4 + | +LL | fn expecting_null_mut(_: *mut u8) {} + | ^^^^^^^^^^^^^^^^^^ ---------- + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/return-dyn-type-mismatch-2.rs b/tests/ui/typeck/return-dyn-type-mismatch-2.rs new file mode 100644 index 000000000..328f154dc --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch-2.rs @@ -0,0 +1,11 @@ +trait Trait {} + +fn foo() -> dyn Trait +where + dyn Trait: Sized, // pesky sized predicate +{ + 42 + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/typeck/return-dyn-type-mismatch-2.stderr b/tests/ui/typeck/return-dyn-type-mismatch-2.stderr new file mode 100644 index 000000000..9c368e838 --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch-2.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/return-dyn-type-mismatch-2.rs:7:5 + | +LL | fn foo() -> dyn Trait + | ------------ expected `(dyn Trait + 'static)` because of return type +... +LL | 42 + | ^^ expected `dyn Trait`, found integer + | + = note: expected trait object `(dyn Trait + 'static)` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/return-dyn-type-mismatch.rs b/tests/ui/typeck/return-dyn-type-mismatch.rs new file mode 100644 index 000000000..93718f70f --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch.rs @@ -0,0 +1,21 @@ +pub trait TestTrait { + type MyType; + + fn func() -> Option + where + Self: Sized; +} + +impl dyn TestTrait +where + Self: Sized, // pesky sized predicate +{ + fn other_func() -> dyn TestTrait { + match Self::func() { + None => None, + //~^ ERROR mismatched types + } + } +} + +fn main() {} diff --git a/tests/ui/typeck/return-dyn-type-mismatch.stderr b/tests/ui/typeck/return-dyn-type-mismatch.stderr new file mode 100644 index 000000000..9d0a609d8 --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/return-dyn-type-mismatch.rs:15:21 + | +LL | fn other_func() -> dyn TestTrait { + | ------------------------- expected `(dyn TestTrait + 'static)` because of return type +LL | match Self::func() { +LL | None => None, + | ^^^^ expected `dyn TestTrait`, found `Option<_>` + | + = note: expected trait object `(dyn TestTrait + 'static)` + found enum `Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/type-placeholder-fn-in-const.rs b/tests/ui/typeck/type-placeholder-fn-in-const.rs index ab2e2d8c5..bbb95a579 100644 --- a/tests/ui/typeck/type-placeholder-fn-in-const.rs +++ b/tests/ui/typeck/type-placeholder-fn-in-const.rs @@ -3,12 +3,13 @@ struct MyStruct; trait Test { const TEST: fn() -> _; //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121] - //~| ERROR: the placeholder `_` is not allowed within types on item signatures for constants [E0121] + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121] } impl Test for MyStruct { const TEST: fn() -> _ = 42; //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121] + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121] } fn main() {} diff --git a/tests/ui/typeck/type-placeholder-fn-in-const.stderr b/tests/ui/typeck/type-placeholder-fn-in-const.stderr index e7b2e554a..302359d25 100644 --- a/tests/ui/typeck/type-placeholder-fn-in-const.stderr +++ b/tests/ui/typeck/type-placeholder-fn-in-const.stderr @@ -4,7 +4,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | const TEST: fn() -> _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/type-placeholder-fn-in-const.rs:4:25 | LL | const TEST: fn() -> _; @@ -16,6 +16,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | const TEST: fn() -> _ = 42; | ^ not allowed in type signatures -error: aborting due to 3 previous errors +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants + --> $DIR/type-placeholder-fn-in-const.rs:10:25 + | +LL | const TEST: fn() -> _ = 42; + | ^ not allowed in type signatures + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index 46aed0f60..4eba14f5a 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -190,9 +190,9 @@ trait Qux { type B = _; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types const C: _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants const D: _ = 42; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants // type E: _; // FIXME: make the parser propagate the existence of `B` type F: std::ops::Fn(_); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types @@ -203,10 +203,10 @@ impl Qux for Struct { type B = _; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types const C: _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants //~| ERROR associated constant in `impl` without body const D: _ = 42; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } fn map(_: fn() -> Option<&'static T>) -> Option { diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index bc02547c6..0c5e7e3ce 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -525,13 +525,13 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | type B = _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item.rs:192:14 | LL | const C: _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item.rs:194:14 | LL | const D: _ = 42; @@ -642,13 +642,13 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | type B = _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item.rs:205:14 | LL | const C: _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item.rs:208:14 | LL | const D: _ = 42; diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.rs b/tests/ui/typeck/typeck_type_placeholder_item_help.rs index c459d8c3c..914f8a2b2 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.rs @@ -16,14 +16,14 @@ const TEST4: fn() -> _ = 42; trait Test5 { const TEST5: _ = 42; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } struct Test6; impl Test6 { const TEST6: _ = 13; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } pub fn main() { diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr index 07a5dbd93..ed6f40880 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr @@ -37,7 +37,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | const TEST4: fn() -> _ = 42; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item_help.rs:18:18 | LL | const TEST5: _ = 42; @@ -46,7 +46,7 @@ LL | const TEST5: _ = 42; | not allowed in type signatures | help: replace with the correct type: `i32` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item_help.rs:25:18 | LL | const TEST6: _ = 13; diff --git a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr index 96ac43216..85adf7751 100644 --- a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -8,10 +8,10 @@ LL | >::add(1, 2); | = help: the trait `Add` is not implemented for `i32` = help: the following other types implement trait `Add`: + + > <&'a i32 as Add> <&i32 as Add<&i32>> - > - error[E0308]: mismatched types --> $DIR/ufcs-qpath-self-mismatch.rs:7:28 @@ -65,10 +65,10 @@ LL | >::add(1, 2); | = help: the trait `Add` is not implemented for `i32` = help: the following other types implement trait `Add`: + + > <&'a i32 as Add> <&i32 as Add<&i32>> - > - error: aborting due to 4 previous errors diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed new file mode 100644 index 000000000..5be6ff8e7 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.fixed @@ -0,0 +1,17 @@ +// run-rustfix + +trait WithType {} +trait WithRegion<'a> { } + +#[allow(dead_code)] +struct Foo { + t: T +} + +impl Foo +where + T: for<'a> WithType<&'a u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs new file mode 100644 index 000000000..d7072aa11 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.rs @@ -0,0 +1,17 @@ +// run-rustfix + +trait WithType {} +trait WithRegion<'a> { } + +#[allow(dead_code)] +struct Foo { + t: T +} + +impl Foo +where + T: WithType<&u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr new file mode 100644 index 000000000..3e197dc9a --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2015.stderr @@ -0,0 +1,14 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-inherent-impl-ampersand-rust2015.rs:13:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here + | +LL | T: for<'a> WithType<&'a u32> + | +++++++ ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed new file mode 100644 index 000000000..0f1be5865 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.fixed @@ -0,0 +1,18 @@ +// edition:2018 +// run-rustfix + +trait WithType {} +trait WithRegion<'a> { } + +#[allow(dead_code)] +struct Foo { + t: T +} + +impl Foo +where + T: for<'a> WithType<&'a u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs new file mode 100644 index 000000000..59f7e472e --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.rs @@ -0,0 +1,18 @@ +// edition:2018 +// run-rustfix + +trait WithType {} +trait WithRegion<'a> { } + +#[allow(dead_code)] +struct Foo { + t: T +} + +impl Foo +where + T: WithType<&u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr new file mode 100644 index 000000000..08b4268e5 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand-rust2018.stderr @@ -0,0 +1,14 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-inherent-impl-ampersand-rust2018.rs:14:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here + | +LL | T: for<'a> WithType<&'a u32> + | +++++++ ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs deleted file mode 100644 index 43de30944..000000000 --- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs +++ /dev/null @@ -1,18 +0,0 @@ -// revisions: rust2015 rust2018 -//[rust2018] edition:2018 - -trait WithType {} -trait WithRegion<'a> { } - -struct Foo { - t: T -} - -impl Foo -where - T: WithType<&u32> -//[rust2015]~^ ERROR `&` without an explicit lifetime name cannot be used here -//[rust2018]~^^ ERROR `&` without an explicit lifetime name cannot be used here -{ } - -fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr deleted file mode 100644 index f4d14b5f8..000000000 --- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/where-clause-inherent-impl-ampersand.rs:13:17 - | -LL | T: WithType<&u32> - | ^ explicit lifetime name needed here - | -help: consider introducing a higher-ranked lifetime here with `for<'a>` - --> $DIR/where-clause-inherent-impl-ampersand.rs:13:8 - | -LL | T: WithType<&u32> - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr b/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr deleted file mode 100644 index f4d14b5f8..000000000 --- a/tests/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/where-clause-inherent-impl-ampersand.rs:13:17 - | -LL | T: WithType<&u32> - | ^ explicit lifetime name needed here - | -help: consider introducing a higher-ranked lifetime here with `for<'a>` - --> $DIR/where-clause-inherent-impl-ampersand.rs:13:8 - | -LL | T: WithType<&u32> - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed new file mode 100644 index 000000000..55c747096 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +trait WithType {} +trait WithRegion<'a> { } + +trait Foo { } + +impl Foo for Vec +where + T: for<'a> WithType<&'a u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs new file mode 100644 index 000000000..42a35b021 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.rs @@ -0,0 +1,14 @@ +// run-rustfix + +trait WithType {} +trait WithRegion<'a> { } + +trait Foo { } + +impl Foo for Vec +where + T: WithType<&u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr new file mode 100644 index 000000000..8c5bbb631 --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2015.stderr @@ -0,0 +1,14 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-trait-impl-region-2015.rs:10:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here + | +LL | T: for<'a> WithType<&'a u32> + | +++++++ ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed new file mode 100644 index 000000000..09b96fe5e --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.fixed @@ -0,0 +1,15 @@ +// run-rustfix +// edition:2018 + +trait WithType {} +trait WithRegion<'a> { } + +trait Foo { } + +impl Foo for Vec +where + T: for<'a> WithType<&'a u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs new file mode 100644 index 000000000..445f38cbe --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.rs @@ -0,0 +1,15 @@ +// run-rustfix +// edition:2018 + +trait WithType {} +trait WithRegion<'a> { } + +trait Foo { } + +impl Foo for Vec +where + T: WithType<&u32> +//~^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr new file mode 100644 index 000000000..0268c59fa --- /dev/null +++ b/tests/ui/underscore-lifetime/where-clause-trait-impl-region-2018.stderr @@ -0,0 +1,14 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-trait-impl-region-2018.rs:11:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + | +help: consider introducing a higher-ranked lifetime here + | +LL | T: for<'a> WithType<&'a u32> + | +++++++ ++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rs b/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rs deleted file mode 100644 index 09e5bbd84..000000000 --- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rs +++ /dev/null @@ -1,15 +0,0 @@ -// revisions: rust2015 rust2018 -//[rust2018] edition:2018 - -trait WithType {} -trait WithRegion<'a> { } - -trait Foo { } - -impl Foo for Vec -where - T: WithType<&u32> -//[rust2015,rust2018]~^ ERROR `&` without an explicit lifetime name cannot be used here -{ } - -fn main() {} diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr b/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr deleted file mode 100644 index 63fc1a19b..000000000 --- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/where-clause-trait-impl-region.rs:11:17 - | -LL | T: WithType<&u32> - | ^ explicit lifetime name needed here - | -help: consider introducing a higher-ranked lifetime here with `for<'a>` - --> $DIR/where-clause-trait-impl-region.rs:11:8 - | -LL | T: WithType<&u32> - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr b/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr deleted file mode 100644 index 63fc1a19b..000000000 --- a/tests/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0637]: `&` without an explicit lifetime name cannot be used here - --> $DIR/where-clause-trait-impl-region.rs:11:17 - | -LL | T: WithType<&u32> - | ^ explicit lifetime name needed here - | -help: consider introducing a higher-ranked lifetime here with `for<'a>` - --> $DIR/where-clause-trait-impl-region.rs:11:8 - | -LL | T: WithType<&u32> - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0637`. diff --git a/tests/ui/uninhabited/projection.rs b/tests/ui/uninhabited/projection.rs new file mode 100644 index 000000000..be0d3ff7d --- /dev/null +++ b/tests/ui/uninhabited/projection.rs @@ -0,0 +1,32 @@ +// check-pass + +#![feature(never_type, exhaustive_patterns)] + +trait Tag { + type TagType; +} + +enum Keep {} +enum Erase {} + +impl Tag for Keep { + type TagType = (); +} + +impl Tag for Erase { + type TagType = !; +} + +enum TagInt { + Untagged(i32), + Tagged(T::TagType, i32) +} + +fn test(keep: TagInt, erase: TagInt) { + match erase { + TagInt::Untagged(_) => (), + TagInt::Tagged(_, _) => () + }; +} + +fn main() {} diff --git a/tests/ui/union/union-fields-2.mirunsafeck.stderr b/tests/ui/union/union-fields-2.mirunsafeck.stderr index 90ad16402..1157f0c2a 100644 --- a/tests/ui/union/union-fields-2.mirunsafeck.stderr +++ b/tests/ui/union/union-fields-2.mirunsafeck.stderr @@ -16,7 +16,7 @@ error[E0560]: union `U` has no field named `c` LL | let u = U { a: 0, b: 1, c: 2 }; | ^ `U` does not have this field | - = note: available fields are: `a`, `b` + = note: all struct fields are already assigned error[E0784]: union expressions should have exactly one field --> $DIR/union-fields-2.rs:13:13 diff --git a/tests/ui/union/union-fields-2.thirunsafeck.stderr b/tests/ui/union/union-fields-2.thirunsafeck.stderr index 90ad16402..1157f0c2a 100644 --- a/tests/ui/union/union-fields-2.thirunsafeck.stderr +++ b/tests/ui/union/union-fields-2.thirunsafeck.stderr @@ -16,7 +16,7 @@ error[E0560]: union `U` has no field named `c` LL | let u = U { a: 0, b: 1, c: 2 }; | ^ `U` does not have this field | - = note: available fields are: `a`, `b` + = note: all struct fields are already assigned error[E0784]: union expressions should have exactly one field --> $DIR/union-fields-2.rs:13:13 diff --git a/tests/ui/union/union-sized-field.stderr b/tests/ui/union/union-sized-field.stderr index bf1ff9c8b..0a79f8bba 100644 --- a/tests/ui/union/union-sized-field.stderr +++ b/tests/ui/union/union-sized-field.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/union-sized-field.rs:4:12 | LL | union Foo { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | value: ManuallyDrop, | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | @@ -28,7 +28,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/union-sized-field.rs:9:12 | LL | struct Foo2 { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | value: ManuallyDrop, | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | @@ -54,7 +54,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/union-sized-field.rs:15:11 | LL | enum Foo3 { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | Value(ManuallyDrop), | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | diff --git a/tests/ui/unsafe/auxiliary/external_unsafe_macro.rs b/tests/ui/unsafe/auxiliary/external_unsafe_macro.rs new file mode 100644 index 000000000..b3837338b --- /dev/null +++ b/tests/ui/unsafe/auxiliary/external_unsafe_macro.rs @@ -0,0 +1,4 @@ +pub unsafe fn unsf() {} + +#[macro_export] +macro_rules! unsafe_macro { () => ($crate::unsf()) } diff --git a/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr b/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr index 6f005fe89..0c0826c1c 100644 --- a/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr +++ b/tests/ui/unsafe/rfc-2585-unsafe_op_in_unsafe_fn.mir.stderr @@ -5,6 +5,11 @@ LL | unsf(); | ^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior +note: an unsafe function restricts its caller, but its body is safe by default + --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:11:1 + | +LL | unsafe fn deny_level() { + | ^^^^^^^^^^^^^^^^^^^^^^ note: the lint level is defined here --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:4:9 | @@ -46,6 +51,11 @@ LL | unsf(); | ^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior +note: an unsafe function restricts its caller, but its body is safe by default + --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:27:1 + | +LL | unsafe fn warning_level() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: the lint level is defined here --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:26:8 | diff --git a/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed b/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed new file mode 100644 index 000000000..db1c10221 --- /dev/null +++ b/tests/ui/unsafe/wrapping-unsafe-block-sugg.fixed @@ -0,0 +1,66 @@ +// run-rustfix +// aux-build:external_unsafe_macro.rs + +#![deny(unsafe_op_in_unsafe_fn)] //~ NOTE + +extern crate external_unsafe_macro; + +unsafe fn unsf() {} + +pub unsafe fn foo() { unsafe { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + unsf(); //~ ERROR call to unsafe function is unsafe + //~^ NOTE + //~| NOTE + unsf(); //~ ERROR call to unsafe function is unsafe + //~^ NOTE + //~| NOTE +}} + +pub unsafe fn bar(x: *const i32) -> i32 { unsafe { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + let y = *x; //~ ERROR dereference of raw pointer is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE + y + *x //~ ERROR dereference of raw pointer is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE +}} + +static mut BAZ: i32 = 0; +pub unsafe fn baz() -> i32 { unsafe { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + let y = BAZ; //~ ERROR use of mutable static is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE + y + BAZ //~ ERROR use of mutable static is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE +}} + +macro_rules! unsafe_macro { () => (unsf()) } +//~^ ERROR call to unsafe function is unsafe +//~| NOTE +//~| NOTE +//~| ERROR call to unsafe function is unsafe +//~| NOTE +//~| NOTE + +pub unsafe fn unsafe_in_macro() { unsafe { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + unsafe_macro!(); + //~^ NOTE + //~| NOTE + unsafe_macro!(); + //~^ NOTE + //~| NOTE +}} + +pub unsafe fn unsafe_in_external_macro() { + // FIXME: https://github.com/rust-lang/rust/issues/112504 + // FIXME: ~^ NOTE an unsafe function restricts its caller, but its body is safe by default + external_unsafe_macro::unsafe_macro!(); + external_unsafe_macro::unsafe_macro!(); +} + +fn main() {} diff --git a/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs b/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs new file mode 100644 index 000000000..9c6be4589 --- /dev/null +++ b/tests/ui/unsafe/wrapping-unsafe-block-sugg.rs @@ -0,0 +1,66 @@ +// run-rustfix +// aux-build:external_unsafe_macro.rs + +#![deny(unsafe_op_in_unsafe_fn)] //~ NOTE + +extern crate external_unsafe_macro; + +unsafe fn unsf() {} + +pub unsafe fn foo() { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + unsf(); //~ ERROR call to unsafe function is unsafe + //~^ NOTE + //~| NOTE + unsf(); //~ ERROR call to unsafe function is unsafe + //~^ NOTE + //~| NOTE +} + +pub unsafe fn bar(x: *const i32) -> i32 { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + let y = *x; //~ ERROR dereference of raw pointer is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE + y + *x //~ ERROR dereference of raw pointer is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE +} + +static mut BAZ: i32 = 0; +pub unsafe fn baz() -> i32 { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + let y = BAZ; //~ ERROR use of mutable static is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE + y + BAZ //~ ERROR use of mutable static is unsafe and requires unsafe block + //~^ NOTE + //~| NOTE +} + +macro_rules! unsafe_macro { () => (unsf()) } +//~^ ERROR call to unsafe function is unsafe +//~| NOTE +//~| NOTE +//~| ERROR call to unsafe function is unsafe +//~| NOTE +//~| NOTE + +pub unsafe fn unsafe_in_macro() { + //~^ NOTE an unsafe function restricts its caller, but its body is safe by default + unsafe_macro!(); + //~^ NOTE + //~| NOTE + unsafe_macro!(); + //~^ NOTE + //~| NOTE +} + +pub unsafe fn unsafe_in_external_macro() { + // FIXME: https://github.com/rust-lang/rust/issues/112504 + // FIXME: ~^ NOTE an unsafe function restricts its caller, but its body is safe by default + external_unsafe_macro::unsafe_macro!(); + external_unsafe_macro::unsafe_macro!(); +} + +fn main() {} diff --git a/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr b/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr new file mode 100644 index 000000000..43f619c27 --- /dev/null +++ b/tests/ui/unsafe/wrapping-unsafe-block-sugg.stderr @@ -0,0 +1,99 @@ +error: call to unsafe function is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:12:5 + | +LL | unsf(); + | ^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior +note: an unsafe function restricts its caller, but its body is safe by default + --> $DIR/wrapping-unsafe-block-sugg.rs:10:1 + | +LL | pub unsafe fn foo() { + | ^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/wrapping-unsafe-block-sugg.rs:4:9 + | +LL | #![deny(unsafe_op_in_unsafe_fn)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: call to unsafe function is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:15:5 + | +LL | unsf(); + | ^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: dereference of raw pointer is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:22:13 + | +LL | let y = *x; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior +note: an unsafe function restricts its caller, but its body is safe by default + --> $DIR/wrapping-unsafe-block-sugg.rs:20:1 + | +LL | pub unsafe fn bar(x: *const i32) -> i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: dereference of raw pointer is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:25:9 + | +LL | y + *x + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error: use of mutable static is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:33:13 + | +LL | let y = BAZ; + | ^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior +note: an unsafe function restricts its caller, but its body is safe by default + --> $DIR/wrapping-unsafe-block-sugg.rs:31:1 + | +LL | pub unsafe fn baz() -> i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of mutable static is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:36:9 + | +LL | y + BAZ + | ^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: call to unsafe function is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:41:36 + | +LL | macro_rules! unsafe_macro { () => (unsf()) } + | ^^^^^^ call to unsafe function +... +LL | unsafe_macro!(); + | --------------- in this macro invocation + | + = note: consult the function's documentation for information on how to avoid undefined behavior +note: an unsafe function restricts its caller, but its body is safe by default + --> $DIR/wrapping-unsafe-block-sugg.rs:49:1 + | +LL | pub unsafe fn unsafe_in_macro() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: call to unsafe function is unsafe and requires unsafe block (error E0133) + --> $DIR/wrapping-unsafe-block-sugg.rs:41:36 + | +LL | macro_rules! unsafe_macro { () => (unsf()) } + | ^^^^^^ call to unsafe function +... +LL | unsafe_macro!(); + | --------------- in this macro invocation + | + = note: consult the function's documentation for information on how to avoid undefined behavior + = note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 8 previous errors + diff --git a/tests/ui/unsized-locals/issue-67981.stderr b/tests/ui/unsized-locals/issue-67981.stderr index a4b179ae2..13fdc037a 100644 --- a/tests/ui/unsized-locals/issue-67981.stderr +++ b/tests/ui/unsized-locals/issue-67981.stderr @@ -5,10 +5,7 @@ LL | let f: fn([u8]) = |_| {}; | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` -help: function arguments must have a statically known size, borrowed types always have a known size - | -LL | let f: fn([u8]) = |&_| {}; - | + + = note: all function arguments must have a statically known size error: aborting due to previous error diff --git a/tests/ui/unsized-locals/rust-call.rs b/tests/ui/unsized-locals/rust-call.rs new file mode 100644 index 000000000..ff4075aa4 --- /dev/null +++ b/tests/ui/unsized-locals/rust-call.rs @@ -0,0 +1,12 @@ +#![feature(unsized_tuple_coercion)] +#![feature(unboxed_closures)] +#![feature(unsized_fn_params)] + +fn bad() -> extern "rust-call" fn(([u8],)) { todo!() } + +fn main() { + let f = bad(); + let slice: Box<([u8],)> = Box::new(([1; 8],)); + f(*slice); + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time +} diff --git a/tests/ui/unsized-locals/rust-call.stderr b/tests/ui/unsized-locals/rust-call.stderr new file mode 100644 index 000000000..fff7ef75b --- /dev/null +++ b/tests/ui/unsized-locals/rust-call.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/rust-call.rs:10:7 + | +LL | f(*slice); + | ^^^^^^ doesn't have a size known at compile-time + | + = help: within `([u8],)`, the trait `Sized` is not implemented for `[u8]` + = note: required because it appears within the type `([u8],)` + = note: argument required to be sized due to `extern "rust-call"` ABI + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-71659.current.stderr b/tests/ui/unsized/issue-71659.current.stderr new file mode 100644 index 000000000..6b982a739 --- /dev/null +++ b/tests/ui/unsized/issue-71659.current.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied + --> $DIR/issue-71659.rs:33:15 + | +LL | let x = x.cast::<[i32]>(); + | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` + | +note: required by a bound in `Cast::cast` + --> $DIR/issue-71659.rs:22:15 + | +LL | fn cast(&self) -> &T + | ---- required by a bound in this associated function +LL | where +LL | Self: CastTo, + | ^^^^^^^^^ required by this bound in `Cast::cast` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-71659.next.stderr b/tests/ui/unsized/issue-71659.next.stderr new file mode 100644 index 000000000..6b982a739 --- /dev/null +++ b/tests/ui/unsized/issue-71659.next.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied + --> $DIR/issue-71659.rs:33:15 + | +LL | let x = x.cast::<[i32]>(); + | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` + | +note: required by a bound in `Cast::cast` + --> $DIR/issue-71659.rs:22:15 + | +LL | fn cast(&self) -> &T + | ---- required by a bound in this associated function +LL | where +LL | Self: CastTo, + | ^^^^^^^^^ required by this bound in `Cast::cast` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-71659.rs b/tests/ui/unsized/issue-71659.rs index 3524ca02b..db5c2e205 100644 --- a/tests/ui/unsized/issue-71659.rs +++ b/tests/ui/unsized/issue-71659.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![feature(unsize)] use std::marker::Unsize; diff --git a/tests/ui/unsized/issue-71659.stderr b/tests/ui/unsized/issue-71659.stderr deleted file mode 100644 index b57b3015e..000000000 --- a/tests/ui/unsized/issue-71659.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: the trait bound `dyn Foo: CastTo<[i32]>` is not satisfied - --> $DIR/issue-71659.rs:30:15 - | -LL | let x = x.cast::<[i32]>(); - | ^^^^ the trait `CastTo<[i32]>` is not implemented for `dyn Foo` - | -note: required by a bound in `Cast::cast` - --> $DIR/issue-71659.rs:19:15 - | -LL | fn cast(&self) -> &T - | ---- required by a bound in this associated function -LL | where -LL | Self: CastTo, - | ^^^^^^^^^ required by this bound in `Cast::cast` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/unsized-bare-typaram.stderr b/tests/ui/unsized/unsized-bare-typaram.stderr index 1eff14be8..daef98440 100644 --- a/tests/ui/unsized/unsized-bare-typaram.stderr +++ b/tests/ui/unsized/unsized-bare-typaram.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn foo() { bar::() } | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `bar` --> $DIR/unsized-bare-typaram.rs:1:8 diff --git a/tests/ui/unsized/unsized-enum.stderr b/tests/ui/unsized/unsized-enum.stderr index 5f2e22430..9e6408e81 100644 --- a/tests/ui/unsized/unsized-enum.stderr +++ b/tests/ui/unsized/unsized-enum.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn foo2() { not_sized::>() } | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Foo` --> $DIR/unsized-enum.rs:4:10 diff --git a/tests/ui/unsized/unsized-enum2.stderr b/tests/ui/unsized/unsized-enum2.stderr index 00b80327c..71cf78212 100644 --- a/tests/ui/unsized/unsized-enum2.stderr +++ b/tests/ui/unsized/unsized-enum2.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `W` cannot be known at compilation tim --> $DIR/unsized-enum2.rs:23:8 | LL | enum E { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | // parameter LL | VA(W), | ^ doesn't have a size known at compile-time @@ -27,7 +27,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized-enum2.rs:25:11 | LL | enum E { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | VB{x: X}, | ^ doesn't have a size known at compile-time @@ -52,7 +52,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim --> $DIR/unsized-enum2.rs:27:15 | LL | enum E { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | VC(isize, Y), | ^ doesn't have a size known at compile-time @@ -77,7 +77,7 @@ error[E0277]: the size for values of type `Z` cannot be known at compilation tim --> $DIR/unsized-enum2.rs:29:21 | LL | enum E { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | VD{u: isize, x: Z}, | ^ doesn't have a size known at compile-time diff --git a/tests/ui/unsized/unsized-fn-arg.stderr b/tests/ui/unsized/unsized-fn-arg.stderr index 404fa5291..0f6fadde1 100644 --- a/tests/ui/unsized/unsized-fn-arg.stderr +++ b/tests/ui/unsized/unsized-fn-arg.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn f(t: T) {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = help: unsized fn params are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/unsized/unsized-inherent-impl-self-type.stderr b/tests/ui/unsized/unsized-inherent-impl-self-type.stderr index a952aa063..9e5ad92eb 100644 --- a/tests/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/tests/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | impl S5 { | - ^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `S5` --> $DIR/unsized-inherent-impl-self-type.rs:5:11 diff --git a/tests/ui/unsized/unsized-struct.stderr b/tests/ui/unsized/unsized-struct.stderr index dff1b0a51..4e7cb09f0 100644 --- a/tests/ui/unsized/unsized-struct.stderr +++ b/tests/ui/unsized/unsized-struct.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn foo2() { not_sized::>() } | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `Foo` --> $DIR/unsized-struct.rs:4:12 @@ -30,7 +30,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim LL | fn bar2() { is_sized::>() } | - ^^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required because it appears within the type `Bar` --> $DIR/unsized-struct.rs:11:8 diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.stderr b/tests/ui/unsized/unsized-trait-impl-self-type.stderr index f6ba9a80c..4955d463f 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/tests/ui/unsized/unsized-trait-impl-self-type.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | impl T3 for S5 { | - ^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `S5` --> $DIR/unsized-trait-impl-self-type.rs:8:11 diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr index f81487d52..8761c293a 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | impl T2 for S4 { | - ^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `T2` --> $DIR/unsized-trait-impl-trait-arg.rs:4:10 diff --git a/tests/ui/unsized/unsized3.stderr b/tests/ui/unsized/unsized3.stderr index 9ad1ac6b4..3ef9a8753 100644 --- a/tests/ui/unsized/unsized3.stderr +++ b/tests/ui/unsized/unsized3.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:7:13 | LL | fn f1(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f2::(x); | ------- ^ doesn't have a size known at compile-time | | @@ -27,7 +27,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:18:13 | LL | fn f3(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f4::(x); | ------- ^ doesn't have a size known at compile-time | | @@ -52,7 +52,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:33:8 | LL | fn f8(x1: &S, x2: &S) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f5(x1); | -- ^^ doesn't have a size known at compile-time | | @@ -82,7 +82,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:40:5 | LL | fn f9(x1: Box>) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f5(&(*x1, 34)); | ^^ doesn't have a size known at compile-time | @@ -102,7 +102,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:45:9 | LL | fn f10(x1: Box>) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f5(&(32, *x1)); | ^^^^^^^^^ doesn't have a size known at compile-time | @@ -123,7 +123,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:45:8 | LL | fn f10(x1: Box>) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f5(&(32, *x1)); | -- ^^^^^^^^^^ doesn't have a size known at compile-time | | diff --git a/tests/ui/unsized/unsized5.stderr b/tests/ui/unsized/unsized5.stderr index 03ed0c457..53e7fc17e 100644 --- a/tests/ui/unsized/unsized5.stderr +++ b/tests/ui/unsized/unsized5.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized5.rs:4:9 | LL | struct S1 { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f1: X, | ^ doesn't have a size known at compile-time | @@ -26,7 +26,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized5.rs:10:8 | LL | struct S2 { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | f: isize, LL | g: X, | ^ doesn't have a size known at compile-time @@ -87,7 +87,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized5.rs:25:8 | LL | enum E { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | V1(X, isize), | ^ doesn't have a size known at compile-time | @@ -111,7 +111,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized5.rs:29:12 | LL | enum F { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | V2{f1: X, f: isize}, | ^ doesn't have a size known at compile-time | diff --git a/tests/ui/unsized/unsized6.stderr b/tests/ui/unsized/unsized6.stderr index 18ac1ea18..56e7f60f9 100644 --- a/tests/ui/unsized/unsized6.stderr +++ b/tests/ui/unsized/unsized6.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim --> $DIR/unsized6.rs:9:9 | LL | fn f1(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let y: Y; | ^ doesn't have a size known at compile-time @@ -23,7 +23,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:7:12 | LL | fn f1(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | let _: W; // <-- this is OK, no bindings created, no initializer. LL | let _: (isize, (X, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -39,7 +39,7 @@ error[E0277]: the size for values of type `Z` cannot be known at compilation tim --> $DIR/unsized6.rs:11:12 | LL | fn f1(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let y: (isize, (Z, usize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -55,7 +55,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:15:9 | LL | fn f2(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | let y: X; | ^ doesn't have a size known at compile-time | @@ -75,7 +75,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim --> $DIR/unsized6.rs:17:12 | LL | fn f2(x: &X) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let y: (isize, (Y, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -91,7 +91,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:22:9 | LL | fn f3(x1: Box, x2: Box, x3: Box) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | @@ -111,7 +111,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:24:9 | LL | fn f3(x1: Box, x2: Box, x3: Box) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let y = *x2; | ^ doesn't have a size known at compile-time @@ -128,7 +128,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:26:10 | LL | fn f3(x1: Box, x2: Box, x3: Box) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time @@ -145,7 +145,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:30:9 | LL | fn f4(x1: Box, x2: Box, x3: Box) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | @@ -165,7 +165,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:32:9 | LL | fn f4(x1: Box, x2: Box, x3: Box) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let y = *x2; | ^ doesn't have a size known at compile-time @@ -182,7 +182,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized6.rs:34:10 | LL | fn f4(x1: Box, x2: Box, x3: Box) { - | - this type parameter needs to be `std::marker::Sized` + | - this type parameter needs to be `Sized` ... LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time @@ -201,7 +201,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | fn g1(x: X) {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = help: unsized fn params are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` @@ -220,7 +220,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | fn g2(x: X) {} | - ^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | = help: unsized fn params are gated as an unstable feature help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/unsized/unsized7.stderr b/tests/ui/unsized/unsized7.stderr index 1555b9df4..c313a2724 100644 --- a/tests/ui/unsized/unsized7.stderr +++ b/tests/ui/unsized/unsized7.stderr @@ -4,7 +4,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim LL | impl T1 for S3 { | - ^^^^^ doesn't have a size known at compile-time | | - | this type parameter needs to be `std::marker::Sized` + | this type parameter needs to be `Sized` | note: required by a bound in `T1` --> $DIR/unsized7.rs:7:10 diff --git a/tests/ui/use/use-keyword.rs b/tests/ui/use/use-keyword.rs index c30c2e06c..840cddcb9 100644 --- a/tests/ui/use/use-keyword.rs +++ b/tests/ui/use/use-keyword.rs @@ -1,4 +1,4 @@ -// Check that imports with nakes super and self don't fail during parsing +// Check that imports with naked super and self don't fail during parsing // FIXME: this shouldn't fail during name resolution either mod a { diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs index c4fa850a4..892b28135 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/weird-exprs.rs @@ -1,7 +1,6 @@ // run-pass #![feature(generators)] -#![feature(unboxed_closures, fn_traits)] #![allow(non_camel_case_types)] #![allow(dead_code)] @@ -17,6 +16,7 @@ extern crate core; use std::cell::Cell; use std::mem::swap; +use std::ops::Deref; // Just a grab bag of stuff that you wouldn't want to actually write. @@ -81,7 +81,7 @@ fn angrydome() { break; } } -fn evil_lincoln() { let _evil = println!("lincoln"); } +fn evil_lincoln() { let _evil: () = println!("lincoln"); } fn dots() { assert_eq!(String::from(".................................................."), @@ -137,7 +137,7 @@ fn punch_card() -> impl std::fmt::Debug { } fn r#match() { - let val = match match match match match () { + let val: () = match match match match match () { () => () } { () => () @@ -166,7 +166,7 @@ fn match_nested_if() { } fn monkey_barrel() { - let val = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=(); + let val: () = ()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=()=(); assert_eq!(val, ()); } @@ -183,10 +183,10 @@ fn 𝚌𝚘𝚗𝚝𝚒𝚗𝚞𝚎() { fn function() { struct foo; - impl FnOnce<()> for foo { - type Output = foo; - extern "rust-call" fn call_once(self, _args: ()) -> Self::Output { - foo + impl Deref for foo { + type Target = fn() -> Self; + fn deref(&self) -> &Self::Target { + &((|| foo) as _) } } let foo = foo () ()() ()()() ()()()() ()()()()(); diff --git a/tests/ui/where-clauses/issue-50825-1.rs b/tests/ui/where-clauses/issue-50825-1.rs new file mode 100644 index 000000000..ee4316029 --- /dev/null +++ b/tests/ui/where-clauses/issue-50825-1.rs @@ -0,0 +1,22 @@ +// run-pass +// regression test for issue #50825 +// Make sure that the `impl` bound (): X is preferred over +// the (): X bound in the where clause. + +trait X { + type T; +} + +trait Y: X { + fn foo(x: &Self::T); +} + +impl X for () { + type T = (); +} + +impl Y> for () where (): Y { + fn foo(_x: &()) {} +} + +fn main () {} diff --git a/tests/ui/where-clauses/issue-50825.rs b/tests/ui/where-clauses/issue-50825.rs new file mode 100644 index 000000000..1ece2e9fc --- /dev/null +++ b/tests/ui/where-clauses/issue-50825.rs @@ -0,0 +1,15 @@ +// run-pass +// regression test for issue #50825 +// Make sure that the built-in bound {integer}: Sized is preferred over +// the u64: Sized bound in the where clause. + +fn foo(y: &[()]) +where + u64: Sized, +{ + y[0] +} + +fn main () { + foo(&[()]); +} diff --git a/tests/ui/xcrate/xcrate-private-by-default.stderr b/tests/ui/xcrate/xcrate-private-by-default.stderr index 0bdd4002f..25bbbf5f6 100644 --- a/tests/ui/xcrate/xcrate-private-by-default.stderr +++ b/tests/ui/xcrate/xcrate-private-by-default.stderr @@ -62,7 +62,9 @@ error[E0603]: module `foo` is private --> $DIR/xcrate-private-by-default.rs:35:29 | LL | static_priv_by_default::foo::a; - | ^^^ private module + | ^^^ - static `a` is not publicly re-exported + | | + | private module | note: the module `foo` is defined here --> $DIR/auxiliary/static_priv_by_default.rs:12:1 @@ -74,7 +76,9 @@ error[E0603]: module `foo` is private --> $DIR/xcrate-private-by-default.rs:37:29 | LL | static_priv_by_default::foo::b; - | ^^^ private module + | ^^^ - function `b` is not publicly re-exported + | | + | private module | note: the module `foo` is defined here --> $DIR/auxiliary/static_priv_by_default.rs:12:1 @@ -86,7 +90,9 @@ error[E0603]: module `foo` is private --> $DIR/xcrate-private-by-default.rs:39:29 | LL | static_priv_by_default::foo::c; - | ^^^ private module + | ^^^ - unit struct `c` is not publicly re-exported + | | + | private module | note: the module `foo` is defined here --> $DIR/auxiliary/static_priv_by_default.rs:12:1 @@ -98,7 +104,9 @@ error[E0603]: module `foo` is private --> $DIR/xcrate-private-by-default.rs:41:35 | LL | foo::(); - | ^^^ private module + | ^^^ - enum `d` is not publicly re-exported + | | + | private module | note: the module `foo` is defined here --> $DIR/auxiliary/static_priv_by_default.rs:12:1 @@ -110,7 +118,9 @@ error[E0603]: module `foo` is private --> $DIR/xcrate-private-by-default.rs:43:35 | LL | foo::(); - | ^^^ private module + | ^^^ - type alias `e` is not publicly re-exported + | | + | private module | note: the module `foo` is defined here --> $DIR/auxiliary/static_priv_by_default.rs:12:1 -- cgit v1.2.3

(processor: P) -> Task -where P: Execute + 'static { - Task { - _processor: Box::new(move || { - let q = P::E::inject(&()); - processor.execute(q); - }) - } -} - -fn main() { - task(annotate( - Annotate::>::new(), - |value: &mut usize| { - *value = 2; - } - )); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs deleted file mode 100644 index 002054732..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// check-pass - -use std::marker::PhantomData; - -trait Lt<'a> { - type T; -} -struct Id(PhantomData); -impl<'a,T> Lt<'a> for Id { - type T = T; -} - -struct Ref(PhantomData) where T: ?Sized; -impl<'a,T> Lt<'a> for Ref -where T: 'a + Lt<'a> + ?Sized -{ - type T = &'a T; -} -struct Mut(PhantomData) where T: ?Sized; -impl<'a,T> Lt<'a> for Mut -where T: 'a + Lt<'a> + ?Sized -{ - type T = &'a mut T; -} - -struct C(for<'a> fn(>::T) -> O) where I: for<'a> Lt<'a>; - - -fn main() { - let c = C::,_>(|()| 3); - c.0(()); - -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs deleted file mode 100644 index d84e30f49..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.rs +++ /dev/null @@ -1,32 +0,0 @@ -trait ATC<'a> { - type Type: Sized; -} - -trait WithDefault: for<'a> ATC<'a> { - fn with_default Fn(>::Type)>(f: F); -} - -fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(>::Type)>( - f: F, - x: >::Type, -) { - f(x); -} - -impl<'a> ATC<'a> for () { - type Type = Self; -} - -impl WithDefault for () { - fn with_default Fn(>::Type)>(f: F) { - // Errors with a bogus type mismatch. - //f(()); - // Going through another generic function works fine. - call(f, ()); - //~^ expected a - } -} - -fn main() { - // <()>::with_default(|_| {}); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr deleted file mode 100644 index b30dd36d2..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-3.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: expected a `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` - --> $DIR/issue-62529-3.rs:25:14 - | -LL | call(f, ()); - | ---- ^ expected an `Fn<(<_ as ATC<'a>>::Type,)>` closure, found `F` - | | - | required by a bound introduced by this call - | - = note: expected a closure with arguments `((),)` - found a closure with arguments `(<_ as ATC<'a>>::Type,)` -note: required by a bound in `call` - --> $DIR/issue-62529-3.rs:9:36 - | -LL | fn call<'b, T: for<'a> ATC<'a>, F: for<'a> Fn(>::Type)>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `call` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs deleted file mode 100644 index 8c2a59868..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-4.rs +++ /dev/null @@ -1,39 +0,0 @@ -// check-pass - -use std::marker::PhantomData; -use std::mem; - -trait Container<'a> { - type Root: 'a; -} - -type RootOf<'a, T> = >::Root; - -struct Test<'a, T> where T: Container<'a> { - pub root: T::Root, - marker: PhantomData<&'a mut &'a mut ()>, -} - -impl<'a, 'b> Container<'b> for &'a str { - type Root = &'b str; -} - -impl<'a, T> Test<'a, T> where T: for<'b> Container<'b> { - fn new(root: RootOf<'a, T>) -> Test<'a, T> { - Test { - root: root, - marker: PhantomData - } - } - - fn with_mut(&mut self, f: F) -> R where - F: for<'b> FnOnce(&'b mut RootOf<'b, T>) -> R { - f(unsafe { mem::transmute(&mut self.root) }) - } -} - -fn main() { - let val = "root"; - let mut test: Test<&str> = Test::new(val); - test.with_mut(|_| { }); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs deleted file mode 100644 index 03f257a02..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-5.rs +++ /dev/null @@ -1,27 +0,0 @@ -// check-pass - -pub struct Struct {} - -pub trait Trait<'a> { - type Assoc; - - fn method() -> Self::Assoc; -} - -impl<'a> Trait<'a> for Struct { - type Assoc = (); - - fn method() -> Self::Assoc {} -} - -pub fn function(f: F) -where - F: for<'a> FnOnce(>::Assoc), - T: for<'b> Trait<'b>, -{ - f(T::method()); -} - -fn main() { - function::<_, Struct>(|_| {}); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs deleted file mode 100644 index 74a4785e4..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-62529-6.rs +++ /dev/null @@ -1,77 +0,0 @@ -// check-pass - -use std::cell::RefMut; - -fn main() { - StateMachine2::Init.resume(); -} - -enum StateMachine2<'a> { - Init, - #[allow(dead_code)] // match required for ICE - AfterTwoYields { - p: Backed<'a, *mut String>, - }, -} - -impl<'a> StateMachine2<'a> { - fn take(&self) -> Self { - StateMachine2::Init - } -} - -impl<'a> StateMachine2<'a> { - fn resume(&mut self) -> () { - use StateMachine2::*; - match self.take() { - AfterTwoYields { p } => { - p.with(|_| {}); - } - _ => panic!("Resume after completed."), - } - } -} - -unsafe trait Unpack<'a> { - type Unpacked: 'a; - - fn unpack(&self) -> Self::Unpacked { - unsafe { std::mem::transmute_copy(&self) } - } -} - -unsafe trait Pack { - type Packed; - - fn pack(&self) -> Self::Packed { - unsafe { std::mem::transmute_copy(&self) } - } -} - -unsafe impl<'a> Unpack<'a> for String { - type Unpacked = String; -} - -unsafe impl Pack for String { - type Packed = String; -} - -unsafe impl<'a> Unpack<'a> for *mut String { - type Unpacked = &'a mut String; -} - -unsafe impl<'a> Pack for &'a mut String { - type Packed = *mut String; -} - -struct Backed<'a, U>(RefMut<'a, Option>, U); - -impl<'a, 'b, U: Unpack<'b>> Backed<'a, U> { - fn with(self, f: F) -> Backed<'a, ()> - where - F: for<'f> FnOnce(>::Unpacked) -> (), - { - let result = f(self.1.unpack()); - Backed(self.0, result) - } -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs deleted file mode 100644 index 3ced40230..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.rs +++ /dev/null @@ -1,31 +0,0 @@ -// check-pass - -pub trait MyTrait<'a> { - type Output: 'a; - fn gimme_value(&self) -> Self::Output; -} - -pub struct MyStruct; - -impl<'a> MyTrait<'a> for MyStruct { - type Output = &'a usize; - fn gimme_value(&self) -> Self::Output { - unimplemented!() - } -} - -fn meow(t: T, f: F) -where - T: for<'any> MyTrait<'any>, - F: for<'any2> Fn(>::Output), -{ - let v = t.gimme_value(); - f(v); -} - -fn main() { - let struc = MyStruct; - meow(struc, |foo| { - println!("{:?}", foo); - }) -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.migrate.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.migrate.stderr deleted file mode 100644 index 0f38f8e32..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.migrate.stderr +++ /dev/null @@ -1,79 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:54:5 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>` - found type `for<'r> FnOnce<(&'r &str,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:54:24 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:9 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:54:5 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected type `FnOnce<(&&str,)>` - found type `for<'r> FnOnce<(&'r &str,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:54:24 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:44 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:58:5 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>` - found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:58:24 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:9 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:58:5 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected type `FnOnce<(&Wrapper<'_>,)>` - found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:58:24 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:34:44 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs deleted file mode 100644 index 1d90226a3..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs +++ /dev/null @@ -1,51 +0,0 @@ -// check-fail -#![feature(rustc_attrs)] - -trait Parser<'s> { - type Output; - - fn call(&self, input: &'s str) -> (&'s str, Self::Output); -} - -impl<'s, F, T> Parser<'s> for F -where F: Fn(&'s str) -> (&'s str, T) { - type Output = T; - fn call(&self, input: &'s str) -> (&'s str, T) { - self(input) - } -} - -fn foo( - f1: F1, - base: &'static str, - f2: F2 -) -where - F1: for<'a> Parser<'a>, - F2: FnOnce(&::Output) -> bool -{ - let s: String = base.to_owned(); - let str_ref = s.as_ref(); - let (remaining, produced) = f1.call(str_ref); - assert!(f2(&produced)); - assert_eq!(remaining.len(), 0); -} - -struct Wrapper<'a>(&'a str); - -fn main() { - fn bar<'a>(s: &'a str) -> (&'a str, &'a str) { - (&s[..1], &s[..]) - } - - fn baz<'a>(s: &'a str) -> (&'a str, Wrapper<'a>) { - (&s[..1], Wrapper(&s[..])) - } - - foo(bar, "string", |s| s.len() == 5); - //~^ ERROR mismatched types - //~| ERROR mismatched types - foo(baz, "string", |s| s.0.len() == 5); - //~^ ERROR mismatched types - //~| ERROR mismatched types -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr deleted file mode 100644 index 4ef96cd95..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.stderr +++ /dev/null @@ -1,79 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:45:5 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> FnOnce<(&'a &'b str,)>` - found trait `for<'a> FnOnce<(&'a &str,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:45:24 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:25:9 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:45:5 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> FnOnce<(&'a &'b str,)>` - found trait `for<'a> FnOnce<(&'a &str,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:45:24 - | -LL | foo(bar, "string", |s| s.len() == 5); - | ^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:25:44 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:48:5 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> FnOnce<(&'a Wrapper<'b>,)>` - found trait `for<'a> FnOnce<(&'a Wrapper<'_>,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:48:24 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:25:9 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/issue-71955.rs:48:5 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other - | - = note: expected trait `for<'a, 'b> FnOnce<(&'a Wrapper<'b>,)>` - found trait `for<'a> FnOnce<(&'a Wrapper<'_>,)>` -note: this closure does not fulfill the lifetime requirements - --> $DIR/issue-71955.rs:48:24 - | -LL | foo(baz, "string", |s| s.0.len() == 5); - | ^^^ -note: the lifetime requirement is introduced here - --> $DIR/issue-71955.rs:25:44 - | -LL | F2: FnOnce(&::Output) -> bool - | ^^^^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-74261.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-74261.rs deleted file mode 100644 index 93ccb4268..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-74261.rs +++ /dev/null @@ -1,30 +0,0 @@ -// check-pass - -use std::marker::PhantomData; - -trait A<'a> { - type B; - fn b(self) -> Self::B; -} - -struct T; -struct S<'a>(PhantomData<&'a ()>); - -impl<'a> A<'a> for T { - type B = S<'a>; - fn b(self) -> Self::B { - S(PhantomData) - } -} - -fn s(t: TT, f: F) -where - TT: for<'a> A<'a>, - F: for<'a> FnOnce(>::B) -{ - f(t.b()); -} - -fn main() { - s(T, |_| {}); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-76956.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-76956.rs deleted file mode 100644 index 583470080..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-76956.rs +++ /dev/null @@ -1,15 +0,0 @@ -// check-pass - -use std::ops::Deref; - -struct Data { - boxed: Box<&'static i32> -} - -impl Data { - fn use_data(&self, user: impl for <'a> FnOnce( as Deref>::Target)) { - user(*self.boxed) - } -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs deleted file mode 100644 index 00a866f22..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs +++ /dev/null @@ -1,71 +0,0 @@ -// build-pass -// edition:2018 - -type BoxFuture = std::pin::Pin>>; - -fn main() { - f(); -} - -async fn f() { - run("dependency").await; -} - -struct InMemoryStorage; - -struct User<'dep> { - dep: &'dep str, -} - -impl<'a> StorageRequest for SaveUser<'a> { - fn execute(&self) -> BoxFuture> { - todo!() - } -} - -trait Storage { - type Error; -} - -impl Storage for InMemoryStorage { - type Error = String; -} - -trait StorageRequestReturnType { - type Output; -} - -trait StorageRequest: StorageRequestReturnType { - fn execute( - &self, - ) -> BoxFuture::Output, ::Error>>; -} - -struct SaveUser<'a> { - name: &'a str, -} - -impl<'a> StorageRequestReturnType for SaveUser<'a> { - type Output = (); -} - -impl<'dep> User<'dep> { - async fn save(self) - where - S: Storage, - for<'a> SaveUser<'a>: StorageRequest, - { - SaveUser { name: "Joe" } - .execute() - .await; - } -} - -async fn run(dep: &str) -where - S: Storage, - for<'a> SaveUser<'a>: StorageRequest, - for<'a> SaveUser<'a>: StorageRequestReturnType, -{ - User { dep }.save().await; -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80956.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80956.rs deleted file mode 100644 index 6316ceea1..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80956.rs +++ /dev/null @@ -1,21 +0,0 @@ -// check-pass - -trait Bar { - type Type; -} -struct Foo<'a>(&'a ()); -impl<'a> Bar for Foo<'a> { - type Type = (); -} - -fn func<'a>(_: as Bar>::Type) {} -fn assert_is_func(_: fn(A)) {} - -fn test() -where - for<'a> as Bar>::Type: Sized, -{ - assert_is_func(func); -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-81809.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-81809.rs deleted file mode 100644 index f6ab9c203..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-81809.rs +++ /dev/null @@ -1,21 +0,0 @@ -// check-pass - -pub trait Indexable { - type Idx; -} -impl Indexable for u8 { - type Idx = u8; -} -impl Indexable for u16 { - type Idx = u16; -} - -pub trait Indexer: std::ops::Index {} - -trait StoreIndex: Indexer + Indexer {} - -fn foo(st: &impl StoreIndex) -> &dyn StoreIndex { - st as &dyn StoreIndex -} - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs deleted file mode 100644 index 8aa29926d..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(unboxed_closures)] - -trait SomeTrait<'a> { - type Associated; -} - -fn give_me_ice() { - callee:: >::Associated>(); - //~^ ERROR the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied [E0277] - //~| ERROR the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied [E0277] -} - -fn callee>() { - println!("{}", std::any::type_name::<>::Output>()); -} - -fn main() { - give_me_ice::<()>(); -} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr deleted file mode 100644 index 3240518fb..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-85455.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0277]: the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied - --> $DIR/issue-85455.rs:8:14 - | -LL | callee:: >::Associated>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> SomeTrait<'a>` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | fn give_me_ice SomeTrait<'a>>() { - | +++++++++++++++++++++++ - -error[E0277]: the trait bound `for<'a> T: SomeTrait<'a>` is not satisfied - --> $DIR/issue-85455.rs:8:5 - | -LL | callee:: >::Associated>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> SomeTrait<'a>` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | fn give_me_ice SomeTrait<'a>>() { - | +++++++++++++++++++++++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs deleted file mode 100644 index fffb54f86..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs +++ /dev/null @@ -1,32 +0,0 @@ -trait BufferMut {} -struct Ctx(D); - -trait BufferUdpStateContext {} -impl BufferUdpStateContext for C {} - -trait StackContext -where - Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, -{ - type Dispatcher; -} - -trait TimerContext { - type Handler; -} -impl TimerContext for C -where - C: StackContext, - //~^ ERROR: is not satisfied [E0277] -{ - type Handler = Ctx; - //~^ ERROR: is not satisfied [E0277] -} - -struct EthernetWorker(C) -where - Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; -impl EthernetWorker {} -//~^ ERROR: is not satisfied [E0277] - -fn main() {} diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr deleted file mode 100644 index edef6ccd3..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:19:8 - | -LL | C: StackContext, - | ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` - | -note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` - --> $DIR/issue-89118.rs:5:23 - | -LL | impl BufferUdpStateContext for C {} - | --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required by a bound in `StackContext` - --> $DIR/issue-89118.rs:9:14 - | -LL | trait StackContext - | ------------ required by a bound in this trait -LL | where -LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` - -error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:29:9 - | -LL | impl EthernetWorker {} - | ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` - | -note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` - --> $DIR/issue-89118.rs:5:23 - | -LL | impl BufferUdpStateContext for C {} - | --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required by a bound in `EthernetWorker` - --> $DIR/issue-89118.rs:28:14 - | -LL | struct EthernetWorker(C) - | -------------- required by a bound in this struct -LL | where -LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` - -error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:22:20 - | -LL | type Handler = Ctx; - | ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` - | -note: required for `Ctx<()>` to implement `for<'a> BufferUdpStateContext<&'a ()>` - --> $DIR/issue-89118.rs:5:23 - | -LL | impl BufferUdpStateContext for C {} - | --------- ^^^^^^^^^^^^^^^^^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required by a bound in `StackContext` - --> $DIR/issue-89118.rs:9:14 - | -LL | trait StackContext - | ------------ required by a bound in this trait -LL | where -LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89436.rs b/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89436.rs deleted file mode 100644 index f7e467b37..000000000 --- a/tests/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89436.rs +++ /dev/null @@ -1,44 +0,0 @@ -// check-pass - -#![allow(unused)] - -trait MiniYokeable<'a> { - type Output; -} - -struct MiniYoke MiniYokeable<'a>> { - pub yokeable: Y, -} - -fn map_project_broken( - source: MiniYoke, - f: impl for<'a> FnOnce( - >::Output, - core::marker::PhantomData<&'a ()>, - ) ->