summaryrefslogtreecommitdiffstats
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs25
-rw-r--r--tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr18
-rw-r--r--tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs32
-rw-r--r--tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr18
-rw-r--r--tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs28
-rw-r--r--tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr13
-rw-r--r--tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr4
-rw-r--r--tests/ui/impl-trait/async_scope_creep.rs13
-rw-r--r--tests/ui/impl-trait/auto-trait-coherence.next.stderr (renamed from tests/ui/impl-trait/auto-trait.stderr)4
-rw-r--r--tests/ui/impl-trait/auto-trait-coherence.old.stderr12
-rw-r--r--tests/ui/impl-trait/auto-trait-coherence.rs (renamed from tests/ui/impl-trait/auto-trait.rs)3
-rw-r--r--tests/ui/impl-trait/auto-trait-leak.rs5
-rw-r--r--tests/ui/impl-trait/auto-trait-leak.stderr115
-rw-r--r--tests/ui/impl-trait/autoderef.rs2
-rw-r--r--tests/ui/impl-trait/bivariant-lifetime-liveness.rs15
-rw-r--r--tests/ui/impl-trait/bound-normalization-fail.rs3
-rw-r--r--tests/ui/impl-trait/bound-normalization-fail.stderr16
-rw-r--r--tests/ui/impl-trait/bounds_regression.rs10
-rw-r--r--tests/ui/impl-trait/capture-lifetime-not-in-hir.rs21
-rw-r--r--tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr14
-rw-r--r--tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr13
-rw-r--r--tests/ui/impl-trait/coherence-treats-tait-ambig.rs16
-rw-r--r--tests/ui/impl-trait/coherence-treats-tait-ambig.stderr13
-rw-r--r--tests/ui/impl-trait/cross-return-site-inference.rs4
-rw-r--r--tests/ui/impl-trait/cross-return-site-inference.stderr27
-rw-r--r--tests/ui/impl-trait/deduce-signature-from-supertrait.rs4
-rw-r--r--tests/ui/impl-trait/defined-by-trait-resolution.rs12
-rw-r--r--tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr2
-rw-r--r--tests/ui/impl-trait/does-not-live-long-enough.stderr2
-rw-r--r--tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.rs9
-rw-r--r--tests/ui/impl-trait/dont-suggest-box-on-empty-else-arm.stderr16
-rw-r--r--tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr4
-rw-r--r--tests/ui/impl-trait/equality-in-canonical-query.clone.stderr29
-rw-r--r--tests/ui/impl-trait/equality-in-canonical-query.rs23
-rw-r--r--tests/ui/impl-trait/equality.stderr4
-rw-r--r--tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr14
-rw-r--r--tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr14
-rw-r--r--tests/ui/impl-trait/erased-regions-in-hidden-ty.rs23
-rw-r--r--tests/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr2
-rw-r--r--tests/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr2
-rw-r--r--tests/ui/impl-trait/extra-item.stderr2
-rw-r--r--tests/ui/impl-trait/fallback_inference.stderr2
-rw-r--r--tests/ui/impl-trait/feature-self-return-type.rs1
-rw-r--r--tests/ui/impl-trait/feature-self-return-type.stderr6
-rw-r--r--tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs22
-rw-r--r--tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr44
-rw-r--r--tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr2
-rw-r--r--tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr2
-rw-r--r--tests/ui/impl-trait/hidden-type-is-opaque-2.rs6
-rw-r--r--tests/ui/impl-trait/hidden-type-is-opaque-2.stderr24
-rw-r--r--tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr2
-rw-r--r--tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr2
-rw-r--r--tests/ui/impl-trait/impl-generic-mismatch-ab.stderr2
-rw-r--r--tests/ui/impl-trait/impl-subtyper.rs18
-rw-r--r--tests/ui/impl-trait/impl-subtyper2.rs7
-rw-r--r--tests/ui/impl-trait/impl-trait-in-macro.stderr2
-rw-r--r--tests/ui/impl-trait/implicit-capture-late.rs14
-rw-r--r--tests/ui/impl-trait/implicit-capture-late.stderr9
-rw-r--r--tests/ui/impl-trait/in-assoc-type-unconstrained.stderr4
-rw-r--r--tests/ui/impl-trait/in-assoc-type.rs3
-rw-r--r--tests/ui/impl-trait/in-assoc-type.stderr8
-rw-r--r--tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs12
-rw-r--r--tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs29
-rw-r--r--tests/ui/impl-trait/in-trait/async-and-ret-ref.rs11
-rw-r--r--tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr14
-rw-r--r--tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs9
-rw-r--r--tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs10
-rw-r--r--tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr33
-rw-r--r--tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs24
-rw-r--r--tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr33
-rw-r--r--tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs8
-rw-r--r--tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/deep-match-works.rs9
-rw-r--r--tests/ui/impl-trait/in-trait/deep-match.next.stderr15
-rw-r--r--tests/ui/impl-trait/in-trait/deep-match.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/deep-match.stderr (renamed from tests/ui/impl-trait/in-trait/deep-match.current.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr11
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-type-err-2.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr (renamed from tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-type-err.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-type-err.stderr (renamed from tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr24
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr24
-rw-r--r--tests/ui/impl-trait/in-trait/default-body-with-rpit.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/default-body.rs4
-rw-r--r--tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/default-method-constraint.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr17
-rw-r--r--tests/ui/impl-trait/in-trait/doesnt-satisfy.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr (renamed from tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr)6
-rw-r--r--tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs5
-rw-r--r--tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr (renamed from tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/early.rs4
-rw-r--r--tests/ui/impl-trait/in-trait/encode.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr5
-rw-r--r--tests/ui/impl-trait/in-trait/foreign.rs24
-rw-r--r--tests/ui/impl-trait/in-trait/gat-outlives.rs17
-rw-r--r--tests/ui/impl-trait/in-trait/gat-outlives.stderr24
-rw-r--r--tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/generics-mismatch.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/generics-mismatch.stderr (renamed from tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102140.next.stderr33
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102140.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102140.stderr (renamed from tests/ui/impl-trait/in-trait/issue-102140.current.stderr)6
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102301.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102571.next.stderr14
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102571.rs14
-rw-r--r--tests/ui/impl-trait/in-trait/issue-102571.stderr (renamed from tests/ui/impl-trait/in-trait/issue-102571.current.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs19
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr21
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr20
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr20
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.rs22
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.stderr74
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.too_few.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/method-signature-matches.too_many.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs10
-rw-r--r--tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr23
-rw-r--r--tests/ui/impl-trait/in-trait/nested-rpitit-bounds.rs11
-rw-r--r--tests/ui/impl-trait/in-trait/nested-rpitit.rs12
-rw-r--r--tests/ui/impl-trait/in-trait/object-safety-sized.rs22
-rw-r--r--tests/ui/impl-trait/in-trait/object-safety.next.stderr49
-rw-r--r--tests/ui/impl-trait/in-trait/object-safety.rs9
-rw-r--r--tests/ui/impl-trait/in-trait/object-safety.stderr (renamed from tests/ui/impl-trait/in-trait/object-safety.current.stderr)33
-rw-r--r--tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr17
-rw-r--r--tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr (renamed from tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/opaque-in-impl.rs3
-rw-r--r--tests/ui/impl-trait/in-trait/opaque-variances.rs14
-rw-r--r--tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs10
-rw-r--r--tests/ui/impl-trait/in-trait/placeholder-implied-bounds.rs14
-rw-r--r--tests/ui/impl-trait/in-trait/refine.rs58
-rw-r--r--tests/ui/impl-trait/in-trait/refine.stderr67
-rw-r--r--tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs14
-rw-r--r--tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/reveal.rs7
-rw-r--r--tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs24
-rw-r--r--tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs21
-rw-r--r--tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs19
-rw-r--r--tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr9
-rw-r--r--tests/ui/impl-trait/in-trait/sibling-function-constraint.rs21
-rw-r--r--tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr17
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr14
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr16
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.rs85
-rw-r--r--tests/ui/impl-trait/in-trait/specialization-broken.next.stderr31
-rw-r--r--tests/ui/impl-trait/in-trait/specialization-broken.rs4
-rw-r--r--tests/ui/impl-trait/in-trait/specialization-broken.stderr (renamed from tests/ui/impl-trait/in-trait/specialization-broken.current.stderr)14
-rw-r--r--tests/ui/impl-trait/in-trait/specialization-substs-remap.rs7
-rw-r--r--tests/ui/impl-trait/in-trait/success.rs11
-rw-r--r--tests/ui/impl-trait/in-trait/suggest-missing-item.fixed26
-rw-r--r--tests/ui/impl-trait/in-trait/suggest-missing-item.rs22
-rw-r--r--tests/ui/impl-trait/in-trait/suggest-missing-item.stderr21
-rw-r--r--tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr12
-rw-r--r--tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs6
-rw-r--r--tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr (renamed from tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr)4
-rw-r--r--tests/ui/impl-trait/in-trait/unconstrained-lt.rs13
-rw-r--r--tests/ui/impl-trait/in-trait/unconstrained-lt.stderr9
-rw-r--r--tests/ui/impl-trait/in-trait/variance.rs20
-rw-r--r--tests/ui/impl-trait/in-trait/variance.stderr26
-rw-r--r--tests/ui/impl-trait/in-trait/variances-of-gat.rs16
-rw-r--r--tests/ui/impl-trait/in-trait/wf-bounds.current.stderr40
-rw-r--r--tests/ui/impl-trait/in-trait/wf-bounds.rs10
-rw-r--r--tests/ui/impl-trait/in-trait/wf-bounds.stderr (renamed from tests/ui/impl-trait/in-trait/wf-bounds.next.stderr)23
-rw-r--r--tests/ui/impl-trait/in-trait/where-clause.rs3
-rw-r--r--tests/ui/impl-trait/issue-100075-2.stderr2
-rw-r--r--tests/ui/impl-trait/issue-100075.stderr2
-rw-r--r--tests/ui/impl-trait/issue-102605.stderr16
-rw-r--r--tests/ui/impl-trait/issue-103181-1.current.stderr2
-rw-r--r--tests/ui/impl-trait/issue-103181-1.next.stderr2
-rw-r--r--tests/ui/impl-trait/issue-103181-1.rs2
-rw-r--r--tests/ui/impl-trait/issue-103181-2.stderr2
-rw-r--r--tests/ui/impl-trait/issue-108591.rs3
-rw-r--r--tests/ui/impl-trait/issue-108592.rs3
-rw-r--r--tests/ui/impl-trait/issue-35668.stderr2
-rw-r--r--tests/ui/impl-trait/issue-54966.stderr2
-rw-r--r--tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr8
-rw-r--r--tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr8
-rw-r--r--tests/ui/impl-trait/issue-55872-2.rs5
-rw-r--r--tests/ui/impl-trait/issue-55872-2.stderr (renamed from tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr)6
-rw-r--r--tests/ui/impl-trait/issue-55872-3.rs1
-rw-r--r--tests/ui/impl-trait/issue-55872-3.stderr8
-rw-r--r--tests/ui/impl-trait/issue-55872.stderr2
-rw-r--r--tests/ui/impl-trait/issue-86465.rs6
-rw-r--r--tests/ui/impl-trait/issue-86465.stderr4
-rw-r--r--tests/ui/impl-trait/issue-87450.stderr2
-rw-r--r--tests/ui/impl-trait/issue-99073-2.rs1
-rw-r--r--tests/ui/impl-trait/issue-99073-2.stderr18
-rw-r--r--tests/ui/impl-trait/issue-99073.rs1
-rw-r--r--tests/ui/impl-trait/issue-99073.stderr21
-rw-r--r--tests/ui/impl-trait/issue-99914.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-54600.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-54600.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-54840.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-54840.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-54895.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-58504.rs10
-rw-r--r--tests/ui/impl-trait/issues/issue-58504.stderr6
-rw-r--r--tests/ui/impl-trait/issues/issue-58956.rs4
-rw-r--r--tests/ui/impl-trait/issues/issue-58956.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-62742.stderr5
-rw-r--r--tests/ui/impl-trait/issues/issue-65581.rs1
-rw-r--r--tests/ui/impl-trait/issues/issue-67830.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-70877.rs4
-rw-r--r--tests/ui/impl-trait/issues/issue-70877.stderr8
-rw-r--r--tests/ui/impl-trait/issues/issue-70971.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-70971.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-74282.rs9
-rw-r--r--tests/ui/impl-trait/issues/issue-74282.stderr20
-rw-r--r--tests/ui/impl-trait/issues/issue-78722-2.rs22
-rw-r--r--tests/ui/impl-trait/issues/issue-78722-2.stderr32
-rw-r--r--tests/ui/impl-trait/issues/issue-78722.rs3
-rw-r--r--tests/ui/impl-trait/issues/issue-78722.stderr6
-rw-r--r--tests/ui/impl-trait/issues/issue-79099.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-79099.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-82139.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-83919.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs4
-rw-r--r--tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-84073.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-84919.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-84919.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-86642.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-86642.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-86800.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-86800.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-87295.rs2
-rw-r--r--tests/ui/impl-trait/issues/issue-87295.stderr4
-rw-r--r--tests/ui/impl-trait/issues/issue-87340.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-88236.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-92305.stderr2
-rw-r--r--tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr2
-rw-r--r--tests/ui/impl-trait/lifetime-ambiguity-regression.rs13
-rw-r--r--tests/ui/impl-trait/lifetimes.rs4
-rw-r--r--tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs15
-rw-r--r--tests/ui/impl-trait/method-suggestion-no-duplication.stderr2
-rw-r--r--tests/ui/impl-trait/multiple-defining-usages-in-body.rs2
-rw-r--r--tests/ui/impl-trait/multiple-defining-usages-in-body.stderr12
-rw-r--r--tests/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr2
-rw-r--r--tests/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr2
-rw-r--r--tests/ui/impl-trait/multiple-lifetimes/error-handling.stderr2
-rw-r--r--tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr2
-rw-r--r--tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr2
-rw-r--r--tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr9
-rw-r--r--tests/ui/impl-trait/negative-reasoning.stderr4
-rw-r--r--tests/ui/impl-trait/nested-return-type2-tait.stderr4
-rw-r--r--tests/ui/impl-trait/nested-return-type2-tait2.rs4
-rw-r--r--tests/ui/impl-trait/nested-return-type2-tait2.stderr23
-rw-r--r--tests/ui/impl-trait/nested-return-type2-tait3.rs4
-rw-r--r--tests/ui/impl-trait/nested-return-type2-tait3.stderr25
-rw-r--r--tests/ui/impl-trait/nested-return-type3-tait.stderr4
-rw-r--r--tests/ui/impl-trait/nested-return-type3-tait2.stderr4
-rw-r--r--tests/ui/impl-trait/nested-return-type4.stderr4
-rw-r--r--tests/ui/impl-trait/nested-rpit-hrtb-2.rs9
-rw-r--r--tests/ui/impl-trait/nested-rpit-hrtb-2.stderr12
-rw-r--r--tests/ui/impl-trait/nested_impl_trait.rs2
-rw-r--r--tests/ui/impl-trait/nested_impl_trait.stderr2
-rw-r--r--tests/ui/impl-trait/no-trait.stderr2
-rw-r--r--tests/ui/impl-trait/normalize-opaque-with-bound-vars.rs27
-rw-r--r--tests/ui/impl-trait/normalize-tait-in-const.rs5
-rw-r--r--tests/ui/impl-trait/normalize-tait-in-const.stderr12
-rw-r--r--tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr6
-rw-r--r--tests/ui/impl-trait/opaque-cast-field-access-in-future.rs27
-rw-r--r--tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr11
-rw-r--r--tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr2
-rw-r--r--tests/ui/impl-trait/recursive-auto-trait.rs10
-rw-r--r--tests/ui/impl-trait/recursive-coroutine.current.stderr12
-rw-r--r--tests/ui/impl-trait/recursive-coroutine.next.stderr12
-rw-r--r--tests/ui/impl-trait/recursive-coroutine.rs (renamed from tests/ui/impl-trait/recursive-generator.rs)13
-rw-r--r--tests/ui/impl-trait/recursive-generator.stderr19
-rw-r--r--tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr152
-rw-r--r--tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr152
-rw-r--r--tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs18
-rw-r--r--tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr (renamed from tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr)52
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs3
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.stderr15
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr12
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs3
-rw-r--r--tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.stderr15
-rw-r--r--tests/ui/impl-trait/region-escape-via-bound.stderr2
-rw-r--r--tests/ui/impl-trait/reveal-during-codegen.rs11
-rw-r--r--tests/ui/impl-trait/rpit-not-sized.stderr2
-rw-r--r--tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs19
-rw-r--r--tests/ui/impl-trait/rpit/non-defining-use.rs14
-rw-r--r--tests/ui/impl-trait/rpit/non-defining-use.stderr31
-rw-r--r--tests/ui/impl-trait/static-lifetime-return-position-impl-trait.rs12
-rw-r--r--tests/ui/impl-trait/static-return-lifetime-infered.stderr4
-rw-r--r--tests/ui/impl-trait/suggest-calling-rpit-closure.stderr2
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other.current.stderr (renamed from tests/ui/impl-trait/two_tait_defining_each_other.stderr)8
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other.rs6
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr (renamed from tests/ui/impl-trait/two_tait_defining_each_other2.stderr)8
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr9
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other2.rs7
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr (renamed from tests/ui/impl-trait/two_tait_defining_each_other3.stderr)8
-rw-r--r--tests/ui/impl-trait/two_tait_defining_each_other3.rs5
-rw-r--r--tests/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr2
-rw-r--r--tests/ui/impl-trait/type_parameters_captured.stderr9
-rw-r--r--tests/ui/impl-trait/unactionable_diagnostic.fixed2
-rw-r--r--tests/ui/impl-trait/unactionable_diagnostic.rs2
-rw-r--r--tests/ui/impl-trait/unactionable_diagnostic.stderr7
-rw-r--r--tests/ui/impl-trait/universal-mismatched-type.stderr4
-rw-r--r--tests/ui/impl-trait/universal-two-impl-traits.stderr2
-rw-r--r--tests/ui/impl-trait/universal_wrong_hrtb.rs2
-rw-r--r--tests/ui/impl-trait/universal_wrong_hrtb.stderr12
-rw-r--r--tests/ui/impl-trait/variance.e2024.stderr26
-rw-r--r--tests/ui/impl-trait/variance.new.stderr26
-rw-r--r--tests/ui/impl-trait/variance.old.stderr26
-rw-r--r--tests/ui/impl-trait/variance.rs28
-rw-r--r--tests/ui/impl-trait/where-allowed-2.stderr8
-rw-r--r--tests/ui/impl-trait/where-allowed.rs79
-rw-r--r--tests/ui/impl-trait/where-allowed.stderr146
321 files changed, 2593 insertions, 1577 deletions
diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs
new file mode 100644
index 000000000..6863a3c73
--- /dev/null
+++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs
@@ -0,0 +1,25 @@
+// This test should never pass!
+
+#![feature(type_alias_impl_trait)]
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+struct MyTy<'a, 'b>(Option<*mut &'a &'b ()>);
+unsafe impl Send for MyTy<'_, 'static> {}
+
+fn step1<'a, 'b: 'a>() -> impl Sized + Captures<'b> + 'a {
+ MyTy::<'a, 'b>(None)
+}
+
+fn step2<'a, 'b: 'a>() -> impl Sized + 'a {
+ step1::<'a, 'b>()
+ //~^ ERROR hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds
+}
+
+fn step3<'a, 'b: 'a>() -> impl Send + 'a {
+ step2::<'a, 'b>()
+ // This should not be Send unless `'b: 'static`
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr
new file mode 100644
index 000000000..825682c52
--- /dev/null
+++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr
@@ -0,0 +1,18 @@
+error[E0700]: hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds
+ --> $DIR/rpit-hidden-erased-unsoundness.rs:16:5
+ |
+LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a {
+ | -- --------------- opaque type defined here
+ | |
+ | hidden type `impl Captures<'b> + 'a` captures the lifetime `'b` as defined here
+LL | step1::<'a, 'b>()
+ | ^^^^^^^^^^^^^^^^^
+ |
+help: to declare that `impl Sized + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
+ |
+LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a + 'b {
+ | ++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs
new file mode 100644
index 000000000..4de2ffbb8
--- /dev/null
+++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs
@@ -0,0 +1,32 @@
+// This test should never pass!
+
+use std::cell::RefCell;
+use std::rc::Rc;
+
+trait Swap: Sized {
+ fn swap(self, other: Self);
+}
+
+impl<T> Swap for Rc<RefCell<T>> {
+ fn swap(self, other: Self) {
+ <RefCell<T>>::swap(&self, &other);
+ }
+}
+
+fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
+ x
+ //~^ ERROR hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds
+}
+
+fn dangle() -> &'static [i32; 3] {
+ let long = Rc::new(RefCell::new(&[4, 5, 6]));
+ let x = [1, 2, 3];
+ let short = Rc::new(RefCell::new(&x));
+ hide(long.clone()).swap(hide(short));
+ let res: &'static [i32; 3] = *long.borrow();
+ res
+}
+
+fn main() {
+ println!("{:?}", dangle());
+}
diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr
new file mode 100644
index 000000000..b87e31acc
--- /dev/null
+++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr
@@ -0,0 +1,18 @@
+error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds
+ --> $DIR/rpit-hide-lifetime-for-swap.rs:17:5
+ |
+LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a {
+ | -- -------------- opaque type defined here
+ | |
+ | hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here
+LL | x
+ | ^
+ |
+help: to declare that `impl Swap + 'a` captures `'b`, you can add an explicit `'b` lifetime bound
+ |
+LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a + 'b {
+ | ++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs
new file mode 100644
index 000000000..40efd941e
--- /dev/null
+++ b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.rs
@@ -0,0 +1,28 @@
+// This test should never pass!
+
+#![feature(type_alias_impl_trait)]
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+struct MyTy<'a, 'b>(Option<*mut &'a &'b ()>);
+unsafe impl Send for MyTy<'_, 'static> {}
+
+fn step1<'a, 'b: 'a>() -> impl Sized + Captures<'b> + 'a {
+ MyTy::<'a, 'b>(None)
+}
+
+mod tait {
+ type Tait<'a> = impl Sized + 'a;
+ pub(super) fn step2<'a, 'b: 'a>() -> Tait<'a> {
+ super::step1::<'a, 'b>()
+ //~^ ERROR hidden type for `Tait<'a>` captures lifetime that does not appear in bounds
+ }
+}
+
+fn step3<'a, 'b: 'a>() -> impl Send + 'a {
+ tait::step2::<'a, 'b>()
+ // This should not be Send unless `'b: 'static`
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr
new file mode 100644
index 000000000..6c9b8cf24
--- /dev/null
+++ b/tests/ui/impl-trait/alias-liveness/tait-hidden-erased-unsoundness.stderr
@@ -0,0 +1,13 @@
+error[E0700]: hidden type for `Tait<'a>` captures lifetime that does not appear in bounds
+ --> $DIR/tait-hidden-erased-unsoundness.rs:18:9
+ |
+LL | type Tait<'a> = impl Sized + 'a;
+ | --------------- opaque type defined here
+LL | pub(super) fn step2<'a, 'b: 'a>() -> Tait<'a> {
+ | -- hidden type `impl Captures<'b> + 'a` captures the lifetime `'b` as defined here
+LL | super::step1::<'a, 'b>()
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
index 40446a3d3..158cfc834 100644
--- a/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
+++ b/tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
@@ -7,7 +7,7 @@ LL | | &mut Header,
LL | | &mut [EntryMetadata],
LL | | &mut [Entry<C::EncodedKey, C::EncodedValue>]
LL | | ) -> R,
- | |__________- this type parameter
+ | |__________- expected this type parameter
LL | ) {
LL | let () = y;
| ^^ - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`
@@ -17,6 +17,6 @@ LL | let () = y;
= note: expected type parameter `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`
found unit type `()`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/async_scope_creep.rs b/tests/ui/impl-trait/async_scope_creep.rs
index 7a9d64d33..60975439a 100644
--- a/tests/ui/impl-trait/async_scope_creep.rs
+++ b/tests/ui/impl-trait/async_scope_creep.rs
@@ -1,6 +1,7 @@
#![feature(type_alias_impl_trait)]
// edition:2021
// check-pass
+// revisions: tait rpit
struct Pending {}
@@ -12,17 +13,25 @@ impl AsyncRead for i32 {}
type PendingReader<'a> = impl AsyncRead + 'a;
-type OpeningReadFuture<'a> =
- impl std::future::Future<Output = Result<PendingReader<'a>, CantOpen>>;
+#[cfg(tait)]
+type OpeningReadFuture<'a> = impl std::future::Future<Output = Result<PendingReader<'a>, CantOpen>>;
impl Pending {
async fn read(&mut self) -> Result<impl AsyncRead + '_, CantOpen> {
Ok(42)
}
+ #[cfg(tait)]
fn read_fut(&mut self) -> OpeningReadFuture<'_> {
self.read()
}
+
+ #[cfg(rpit)]
+ fn read_fut(
+ &mut self,
+ ) -> impl std::future::Future<Output = Result<PendingReader<'_>, CantOpen>> {
+ self.read()
+ }
}
fn main() {}
diff --git a/tests/ui/impl-trait/auto-trait.stderr b/tests/ui/impl-trait/auto-trait-coherence.next.stderr
index 81009413c..3f979d1a5 100644
--- a/tests/ui/impl-trait/auto-trait.stderr
+++ b/tests/ui/impl-trait/auto-trait-coherence.next.stderr
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
- --> $DIR/auto-trait.rs:21:1
+ --> $DIR/auto-trait-coherence.rs:24:1
|
LL | impl<T: Send> AnotherTrait for T {}
| -------------------------------- first implementation here
@@ -7,6 +7,6 @@ LL | impl<T: Send> AnotherTrait for T {}
LL | impl AnotherTrait for D<OpaqueType> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/impl-trait/auto-trait-coherence.old.stderr b/tests/ui/impl-trait/auto-trait-coherence.old.stderr
new file mode 100644
index 000000000..3f979d1a5
--- /dev/null
+++ b/tests/ui/impl-trait/auto-trait-coherence.old.stderr
@@ -0,0 +1,12 @@
+error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
+ --> $DIR/auto-trait-coherence.rs:24:1
+ |
+LL | impl<T: Send> AnotherTrait for T {}
+ | -------------------------------- first implementation here
+...
+LL | impl AnotherTrait for D<OpaqueType> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/impl-trait/auto-trait.rs b/tests/ui/impl-trait/auto-trait-coherence.rs
index 35994e4a5..e4226b200 100644
--- a/tests/ui/impl-trait/auto-trait.rs
+++ b/tests/ui/impl-trait/auto-trait-coherence.rs
@@ -1,3 +1,6 @@
+// revisions: old next
+//[next] compile-flags: -Znext-solver
+
// Tests that type alias impls traits do not leak auto-traits for
// the purposes of coherence checking
#![feature(type_alias_impl_trait)]
diff --git a/tests/ui/impl-trait/auto-trait-leak.rs b/tests/ui/impl-trait/auto-trait-leak.rs
index c2fbbf94f..de4f523c2 100644
--- a/tests/ui/impl-trait/auto-trait-leak.rs
+++ b/tests/ui/impl-trait/auto-trait-leak.rs
@@ -3,14 +3,12 @@ use std::rc::Rc;
fn send<T: 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
send(cycle2().clone());
Rc::new(Cell::new(5))
@@ -18,6 +16,7 @@ fn cycle1() -> impl Clone {
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..3fab766fa 100644
--- a/tests/ui/impl-trait/auto-trait-leak.stderr
+++ b/tests/ui/impl-trait/auto-trait-leak.stderr
@@ -1,109 +1,26 @@
-error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}`
- --> $DIR/auto-trait-leak.rs:12:16
+error: cannot check whether the hidden type of opaque type satisfies auto traits
+ --> $DIR/auto-trait-leak.rs:18:10
|
-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 | send(cycle1().clone());
+ | ---- ^^^^^^^^^^^^^^^^
+ | |
+ | required by a bound introduced by this call
|
-LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building THIR for `cycle1`...
- --> $DIR/auto-trait-leak.rs:12:1
+note: opaque type is declared here
+ --> $DIR/auto-trait-leak.rs:11:16
|
LL | fn cycle1() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires type-checking `cycle1`...
- --> $DIR/auto-trait-leak.rs:14:5
- |
-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
- |
-LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^
-note: ...which requires borrow-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires promoting constants in MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires preparing `cycle2` for borrow checking...
- --> $DIR/auto-trait-leak.rs:19:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires unsafety-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
+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:17:4
|
LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building MIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires match-checking `cycle2`...
- --> $DIR/auto-trait-leak.rs:19:1
- |
-LL | fn cycle2() -> impl Clone {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
-note: ...which requires building THIR for `cycle2`...
- --> $DIR/auto-trait-leak.rs:19: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
+ | ^^^^^^
+note: required by a bound in `send`
+ --> $DIR/auto-trait-leak.rs:4:12
|
-LL | / use std::cell::Cell;
-LL | | use std::rc::Rc;
-LL | |
-LL | | fn send<T: Send>(_: T) {}
-... |
-LL | | Rc::new(String::from("foo"))
-LL | | }
- | |_^
+LL | fn send<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `send`
-error: aborting due to previous error
+error: aborting due to 1 previous error
-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..48ff8be65 100644
--- a/tests/ui/impl-trait/autoderef.rs
+++ b/tests/ui/impl-trait/autoderef.rs
@@ -1,3 +1,5 @@
+// revisions: current next
+//[next] compile-flags: -Znext-solver
// check-pass
use std::path::Path;
diff --git a/tests/ui/impl-trait/bivariant-lifetime-liveness.rs b/tests/ui/impl-trait/bivariant-lifetime-liveness.rs
new file mode 100644
index 000000000..fe99fe3f3
--- /dev/null
+++ b/tests/ui/impl-trait/bivariant-lifetime-liveness.rs
@@ -0,0 +1,15 @@
+// check-pass
+// issue: 116794
+
+// Uncaptured lifetimes should not be required to be live.
+
+struct Invariant<T>(*mut T);
+
+fn opaque<'a: 'a>(_: &'a str) -> Invariant<impl Sized> {
+ Invariant(&mut ())
+}
+
+fn main() {
+ let x = opaque(&String::new());
+ drop(x);
+}
diff --git a/tests/ui/impl-trait/bound-normalization-fail.rs b/tests/ui/impl-trait/bound-normalization-fail.rs
index 332959247..566a4a7ad 100644
--- a/tests/ui/impl-trait/bound-normalization-fail.rs
+++ b/tests/ui/impl-trait/bound-normalization-fail.rs
@@ -39,8 +39,7 @@ mod lifetimes {
/// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further.
fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
- //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
- //~| ERROR: type mismatch
+ //~^ ERROR: type mismatch
Foo(())
}
}
diff --git a/tests/ui/impl-trait/bound-normalization-fail.stderr b/tests/ui/impl-trait/bound-normalization-fail.stderr
index f04a753a0..fcac9ac34 100644
--- a/tests/ui/impl-trait/bound-normalization-fail.stderr
+++ b/tests/ui/impl-trait/bound-normalization-fail.stderr
@@ -19,21 +19,12 @@ help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc
LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> {
| ++++++++++++
-error[E0658]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope
- --> $DIR/bound-normalization-fail.rs:41:41
- |
-LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information
- = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable
-
error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as Trait<'a>>::Assoc`
--> $DIR/bound-normalization-fail.rs:41:41
|
LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as Trait<'a>>::Assoc`
-...
+LL |
LL | Foo(())
| ------- return type was inferred to be `Foo<()>` here
|
@@ -49,7 +40,6 @@ help: consider constraining the associated type `<T as lifetimes::Trait<'a>>::As
LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> {
| ++++++++++++
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
-Some errors have detailed explanations: E0271, E0658.
-For more information about an error, try `rustc --explain E0271`.
+For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/impl-trait/bounds_regression.rs b/tests/ui/impl-trait/bounds_regression.rs
index 31fc46203..f32d83c0c 100644
--- a/tests/ui/impl-trait/bounds_regression.rs
+++ b/tests/ui/impl-trait/bounds_regression.rs
@@ -1,6 +1,6 @@
// run-pass
-pub trait FakeGenerator {
+pub trait FakeCoroutine {
type Yield;
type Return;
}
@@ -9,15 +9,15 @@ pub trait FakeFuture {
type Output;
}
-pub fn future_from_generator<
- T: FakeGenerator<Yield = ()>
+pub fn future_from_coroutine<
+ T: FakeCoroutine<Yield = ()>
>(x: T) -> impl FakeFuture<Output = T::Return> {
GenFuture(x)
}
-struct GenFuture<T: FakeGenerator<Yield = ()>>(#[allow(unused_tuple_struct_fields)] T);
+struct GenFuture<T: FakeCoroutine<Yield = ()>>(#[allow(unused_tuple_struct_fields)] T);
-impl<T: FakeGenerator<Yield = ()>> FakeFuture for GenFuture<T> {
+impl<T: FakeCoroutine<Yield = ()>> FakeFuture for GenFuture<T> {
type Output = T::Return;
}
diff --git a/tests/ui/impl-trait/capture-lifetime-not-in-hir.rs b/tests/ui/impl-trait/capture-lifetime-not-in-hir.rs
new file mode 100644
index 000000000..9c067cb69
--- /dev/null
+++ b/tests/ui/impl-trait/capture-lifetime-not-in-hir.rs
@@ -0,0 +1,21 @@
+#![feature(rustc_attrs)]
+#![rustc_variance_of_opaques]
+
+trait Bar<'a> {
+ type Assoc: From<()>;
+}
+
+fn foo<'a, T: Bar<'a>>() -> impl Into<T::Assoc> {
+ //~^ ERROR [o, o]
+ // captures both T and 'a invariantly
+ ()
+}
+
+fn foo2<'a, T: Bar<'a>>() -> impl Into<T::Assoc> + 'a {
+ //~^ ERROR [o, o, o]
+ // captures both T and 'a invariantly, and also duplicates `'a`
+ // i.e. the opaque looks like `impl Into<<T as Bar<'a>>::Assoc> + 'a_duplicated`
+ ()
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr b/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr
new file mode 100644
index 000000000..9d52001b0
--- /dev/null
+++ b/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr
@@ -0,0 +1,14 @@
+error: [o, o]
+ --> $DIR/capture-lifetime-not-in-hir.rs:8:29
+ |
+LL | fn foo<'a, T: Bar<'a>>() -> impl Into<T::Assoc> {
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: [o, o, o]
+ --> $DIR/capture-lifetime-not-in-hir.rs:14:30
+ |
+LL | fn foo2<'a, T: Bar<'a>>() -> impl Into<T::Assoc> + 'a {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
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..444f3d668
--- /dev/null
+++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.current.stderr
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `Into<T>` for type `Foo`
+ --> $DIR/coherence-treats-tait-ambig.rs:10:1
+ |
+LL | impl Into<T> for Foo {
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: conflicting implementation in crate `core`:
+ - impl<T, U> Into<U> for T
+ where U: From<T>;
+
+error: aborting due to 1 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..df47208bf
--- /dev/null
+++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.rs
@@ -0,0 +1,16 @@
+#![feature(type_alias_impl_trait)]
+
+type T = impl Sized;
+
+struct Foo;
+
+impl Into<T> for Foo {
+//~^ ERROR conflicting implementations of trait `Into<T>` for type `Foo`
+ fn into(self) -> T {
+ Foo
+ }
+}
+
+fn main() {
+ let _: T = Foo.into();
+}
diff --git a/tests/ui/impl-trait/coherence-treats-tait-ambig.stderr b/tests/ui/impl-trait/coherence-treats-tait-ambig.stderr
new file mode 100644
index 000000000..faaad2769
--- /dev/null
+++ b/tests/ui/impl-trait/coherence-treats-tait-ambig.stderr
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `Into<T>` for type `Foo`
+ --> $DIR/coherence-treats-tait-ambig.rs:7:1
+ |
+LL | impl Into<T> for Foo {
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: conflicting implementation in crate `core`:
+ - impl<T, U> Into<U> for T
+ where U: From<T>;
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/impl-trait/cross-return-site-inference.rs b/tests/ui/impl-trait/cross-return-site-inference.rs
index 00aed2ad9..e1071b08c 100644
--- a/tests/ui/impl-trait/cross-return-site-inference.rs
+++ b/tests/ui/impl-trait/cross-return-site-inference.rs
@@ -36,13 +36,13 @@ fn muh() -> Result<(), impl std::fmt::Debug> {
fn muh2() -> Result<(), impl std::fmt::Debug> {
return Err(From::from("foo"));
- //~^ ERROR type annotations needed
+ //~^ ERROR cannot call associated function on trait
Ok(())
}
fn muh3() -> Result<(), impl std::fmt::Debug> {
Err(From::from("foo"))
- //~^ ERROR type annotations needed
+ //~^ ERROR cannot call associated function on trait
}
fn main() {}
diff --git a/tests/ui/impl-trait/cross-return-site-inference.stderr b/tests/ui/impl-trait/cross-return-site-inference.stderr
index 766614e9e..8ee3e9abf 100644
--- a/tests/ui/impl-trait/cross-return-site-inference.stderr
+++ b/tests/ui/impl-trait/cross-return-site-inference.stderr
@@ -9,28 +9,29 @@ help: consider specifying the generic arguments
LL | Ok::<(), E>(())
| +++++++++
-error[E0282]: type annotations needed
- --> $DIR/cross-return-site-inference.rs:38:12
+error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
+ --> $DIR/cross-return-site-inference.rs:38:16
|
LL | return Err(From::from("foo"));
- | ^^^ cannot infer type of the type parameter `E` declared on the enum `Result`
+ | ^^^^^^^^^^ cannot call associated function of trait
|
-help: consider specifying the generic arguments
+help: use a fully-qualified path to a specific available implementation
|
-LL | return Err::<(), E>(From::from("foo"));
- | +++++++++
+LL | return Err(</* self type */ as From>::from("foo"));
+ | +++++++++++++++++++ +
-error[E0282]: type annotations needed
- --> $DIR/cross-return-site-inference.rs:44:5
+error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
+ --> $DIR/cross-return-site-inference.rs:44:9
|
LL | Err(From::from("foo"))
- | ^^^ cannot infer type of the type parameter `E` declared on the enum `Result`
+ | ^^^^^^^^^^ cannot call associated function of trait
|
-help: consider specifying the generic arguments
+help: use a fully-qualified path to a specific available implementation
|
-LL | Err::<(), E>(From::from("foo"))
- | +++++++++
+LL | Err(</* self type */ as From>::from("foo"))
+ | +++++++++++++++++++ +
error: aborting due to 3 previous errors
-For more information about this error, try `rustc --explain E0282`.
+Some errors have detailed explanations: E0282, E0790.
+For more information about an error, try `rustc --explain E0282`.
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<T: Fn(i32)> 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/diagnostics/fully-qualified-path-impl-trait.stderr b/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr
index a1a629bdd..06b5ae6e3 100644
--- a/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr
+++ b/tests/ui/impl-trait/diagnostics/fully-qualified-path-impl-trait.stderr
@@ -4,6 +4,6 @@ error[E0282]: type annotations needed
LL | ().foo(|| ())
| ^^^ cannot infer type for type parameter `T` declared on the trait `Foo`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/does-not-live-long-enough.stderr b/tests/ui/impl-trait/does-not-live-long-enough.stderr
index 750687e23..cfc132980 100644
--- a/tests/ui/impl-trait/does-not-live-long-enough.stderr
+++ b/tests/ui/impl-trait/does-not-live-long-enough.stderr
@@ -16,6 +16,6 @@ help: to force the closure to take ownership of `prefix` (and any other referenc
LL | self.data.iter().filter(move |s| s.starts_with(prefix)).map(|s| s.as_ref())
| ++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0373`.
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..ea3d7f324
--- /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 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
index ed9261d0d..4a52f8254 100644
--- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
+++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr
@@ -16,7 +16,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) }
| doesn't have a size known at compile-time
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
- = note: required because it appears within the type `(usize, dyn Trait)`
+ = note: required because it appears within the type `(usize, (dyn Trait + 'static))`
= note: the return type of a function must have a statically known size
error[E0308]: mismatched types
@@ -37,7 +37,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) }
| doesn't have a size known at compile-time
|
= help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)`
- = note: required because it appears within the type `(usize, dyn Trait)`
+ = note: required because it appears within the type `(usize, (dyn Trait + 'static))`
= note: the return type of a function must have a statically known size
error[E0746]: return type cannot have an unboxed trait object
diff --git a/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr b/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr
new file mode 100644
index 000000000..046d35e4e
--- /dev/null
+++ b/tests/ui/impl-trait/equality-in-canonical-query.clone.stderr
@@ -0,0 +1,29 @@
+error: internal compiler error: no errors encountered even though `span_delayed_bug` issued
+
+error: internal compiler error: {OpaqueTypeKey { def_id: DefId(rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }) } }}
+ |
+ =
+
+
+error: internal compiler error: error performing ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: ProvePredicate { predicate: Binder { value: ProjectionPredicate(AliasTy { args: [FnDef(DefId(rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(foo::{opaque#0}) }))), bound_vars: [] } } }
+ --> $DIR/equality-in-canonical-query.rs:19:5
+ |
+LL | same_output(foo, rpit);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+
+ --> $DIR/equality-in-canonical-query.rs:19:5
+ |
+LL | same_output(foo, rpit);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+
+
+
+
+
+
+query stack during panic:
+end of query stack
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/impl-trait/equality-in-canonical-query.rs b/tests/ui/impl-trait/equality-in-canonical-query.rs
new file mode 100644
index 000000000..672b1eeea
--- /dev/null
+++ b/tests/ui/impl-trait/equality-in-canonical-query.rs
@@ -0,0 +1,23 @@
+// issue: #116877
+// revisions: sized clone
+//[sized] check-pass
+
+//[clone] known-bug: #108498
+//[clone] failure-status: 101
+//[clone] normalize-stderr-test: "DefId\(.*?\]::" -> "DefId("
+//[clone] normalize-stderr-test: "(?m)note: .*$" -> ""
+//[clone] normalize-stderr-test: "(?m)^ *\d+: .*\n" -> ""
+//[clone] normalize-stderr-test: "(?m)^ *at .*\n" -> ""
+
+#[cfg(sized)] fn rpit() -> impl Sized {}
+#[cfg(clone)] fn rpit() -> impl Clone {}
+
+fn same_output<Out>(_: impl Fn() -> Out, _: impl Fn() -> Out) {}
+
+pub fn foo() -> impl Sized {
+ same_output(rpit, foo);
+ same_output(foo, rpit);
+ rpit()
+}
+
+fn main () {}
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<impl Foo>` is not implemented for `u32`
= help: the following other types implement trait `Add<Rhs>`:
+ <u32 as Add>
+ <u32 as Add<&u32>>
<&'a u32 as Add<u32>>
<&u32 as Add<&u32>>
- <u32 as Add<&u32>>
- <u32 as Add>
error: aborting due to 2 previous errors; 1 warning emitted
diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr b/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr
new file mode 100644
index 000000000..4cd4febc4
--- /dev/null
+++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.current.stderr
@@ -0,0 +1,14 @@
+error: {foo<ReEarlyParam(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
+ --> $DIR/erased-regions-in-hidden-ty.rs:11:36
+ |
+LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: Opaque(DefId(..), [ReErased])
+ --> $DIR/erased-regions-in-hidden-ty.rs:17:13
+ |
+LL | fn bar() -> impl Fn() + 'static {
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr b/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr
new file mode 100644
index 000000000..4cd4febc4
--- /dev/null
+++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.next.stderr
@@ -0,0 +1,14 @@
+error: {foo<ReEarlyParam(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
+ --> $DIR/erased-regions-in-hidden-ty.rs:11:36
+ |
+LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: Opaque(DefId(..), [ReErased])
+ --> $DIR/erased-regions-in-hidden-ty.rs:17:13
+ |
+LL | fn bar() -> impl Fn() + 'static {
+ | ^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs b/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs
new file mode 100644
index 000000000..b1f36fc24
--- /dev/null
+++ b/tests/ui/impl-trait/erased-regions-in-hidden-ty.rs
@@ -0,0 +1,23 @@
+// revisions: current next
+// compile-flags: -Zverbose
+//[next] compile-flags: -Znext-solver
+// normalize-stderr-test "DefId\([^\)]+\)" -> "DefId(..)"
+
+#![feature(rustc_attrs)]
+#![rustc_hidden_type_of_opaques]
+
+// Make sure that the compiler can handle `ReErased` in the hidden type of an opaque.
+
+fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
+//~^ ERROR 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
+// Can't write whole type because of lack of path sanitization
+ || ()
+}
+
+fn bar() -> impl Fn() + 'static {
+//~^ ERROR , [ReErased])
+// Can't write whole type because of lack of path sanitization
+ foo(&vec![])
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr b/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr
index 9c1011018..e8cd16bc3 100644
--- a/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr
+++ b/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/explicit-generic-args-for-impl.stderr
@@ -13,6 +13,6 @@ LL | fn foo<T: ?Sized>(_f: impl AsRef<T>) {}
| ^^^ -
= note: `impl Trait` cannot be explicitly specified as a generic argument
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr b/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr
index a26460c8e..b2478c4cd 100644
--- a/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr
+++ b/tests/ui/impl-trait/explicit-generic-args-with-impl-trait/not-enough-args.stderr
@@ -16,6 +16,6 @@ help: add missing generic argument
LL | f::<[u8], U>("a", b"a");
| +++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/impl-trait/extra-item.stderr b/tests/ui/impl-trait/extra-item.stderr
index 728bcc0aa..622997072 100644
--- a/tests/ui/impl-trait/extra-item.stderr
+++ b/tests/ui/impl-trait/extra-item.stderr
@@ -4,6 +4,6 @@ error[E0407]: method `extra` is not a member of trait `extra_item::MyTrait`
LL | fn extra() {}
| ^^^^^^^^^^^^^ not a member of trait `extra_item::MyTrait`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0407`.
diff --git a/tests/ui/impl-trait/fallback_inference.stderr b/tests/ui/impl-trait/fallback_inference.stderr
index 4ac3c238f..4f8121ae8 100644
--- a/tests/ui/impl-trait/fallback_inference.stderr
+++ b/tests/ui/impl-trait/fallback_inference.stderr
@@ -9,6 +9,6 @@ help: consider specifying the generic argument
LL | PhantomData::<T>
| +++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/feature-self-return-type.rs b/tests/ui/impl-trait/feature-self-return-type.rs
index 51877e9cc..7555df1b2 100644
--- a/tests/ui/impl-trait/feature-self-return-type.rs
+++ b/tests/ui/impl-trait/feature-self-return-type.rs
@@ -1,5 +1,4 @@
// edition:2018
-#![feature(impl_trait_projections)]
// This test checks that we emit the correct borrowck error when `Self` or a projection is used as
// a return type. See #61949 for context.
diff --git a/tests/ui/impl-trait/feature-self-return-type.stderr b/tests/ui/impl-trait/feature-self-return-type.stderr
index b9b8d00ce..e7113a9df 100644
--- a/tests/ui/impl-trait/feature-self-return-type.stderr
+++ b/tests/ui/impl-trait/feature-self-return-type.stderr
@@ -1,5 +1,5 @@
error[E0597]: `bar` does not live long enough
- --> $DIR/feature-self-return-type.rs:23:22
+ --> $DIR/feature-self-return-type.rs:22:22
|
LL | let x = {
| - borrow later stored here
@@ -12,7 +12,7 @@ LL | };
| - `bar` dropped here while still borrowed
error[E0597]: `y` does not live long enough
- --> $DIR/feature-self-return-type.rs:63:17
+ --> $DIR/feature-self-return-type.rs:62:17
|
LL | let x = {
| - borrow later stored here
@@ -25,7 +25,7 @@ LL | };
| - `y` dropped here while still borrowed
error[E0597]: `y` does not live long enough
- --> $DIR/feature-self-return-type.rs:95:17
+ --> $DIR/feature-self-return-type.rs:94:17
|
LL | let x = {
| - borrow later stored here
diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs
new file mode 100644
index 000000000..57d688492
--- /dev/null
+++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.rs
@@ -0,0 +1,22 @@
+// edition:2015
+// check-pass
+// issue: 114664
+
+fn ice() -> impl AsRef<Fn(&())> {
+ //~^ WARN trait objects without an explicit `dyn` are deprecated
+ //~| WARN trait objects without an explicit `dyn` are deprecated
+ //~| WARN trait objects without an explicit `dyn` are deprecated
+ //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ Foo
+}
+
+struct Foo;
+impl AsRef<dyn Fn(&())> for Foo {
+ fn as_ref(&self) -> &(dyn for<'a> Fn(&'a ()) + 'static) {
+ todo!()
+ }
+}
+
+pub fn main() {}
diff --git a/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr
new file mode 100644
index 000000000..d3c2d5d5b
--- /dev/null
+++ b/tests/ui/impl-trait/fresh-lifetime-from-bare-trait-obj-114664.stderr
@@ -0,0 +1,44 @@
+warning: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
+ |
+LL | fn ice() -> impl AsRef<Fn(&())> {
+ | ^^^^^^^
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+ = note: `#[warn(bare_trait_objects)]` on by default
+help: use `dyn`
+ |
+LL | fn ice() -> impl AsRef<dyn Fn(&())> {
+ | +++
+
+warning: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
+ |
+LL | fn ice() -> impl AsRef<Fn(&())> {
+ | ^^^^^^^
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+help: use `dyn`
+ |
+LL | fn ice() -> impl AsRef<dyn Fn(&())> {
+ | +++
+
+warning: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/fresh-lifetime-from-bare-trait-obj-114664.rs:5:24
+ |
+LL | fn ice() -> impl AsRef<Fn(&())> {
+ | ^^^^^^^
+ |
+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+help: use `dyn`
+ |
+LL | fn ice() -> impl AsRef<dyn Fn(&())> {
+ | +++
+
+warning: 3 warnings emitted
+
diff --git a/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr b/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr
index edf3911e2..6e36922b4 100644
--- a/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr
+++ b/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2015.stderr
@@ -4,6 +4,6 @@ error[E0277]: the trait bound `(): AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is
LL | fn ice() -> impl AsRef<Fn(&())> {
| ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'a> Fn(&'a ()) + 'static)>` is not implemented for `()`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr b/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr
index 30fbba168..2e13ca753 100644
--- a/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr
+++ b/tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.edition2021.stderr
@@ -9,6 +9,6 @@ help: add `dyn` keyword before this trait
LL | fn ice() -> impl AsRef<dyn Fn(&())> {
| +++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0782`.
diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs
index 970d84120..212e7b108 100644
--- a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs
+++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs
@@ -6,7 +6,8 @@
fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> {
Thunk::new(|mut cont| {
- cont.reify_as(); //~ ERROR type annotations needed
+ //~^ ERROR type annotations needed
+ cont.reify_as();
cont
})
}
@@ -15,7 +16,8 @@ type Tait = impl FnOnce(Continuation) -> Continuation;
fn reify_as_tait() -> Thunk<Tait> {
Thunk::new(|mut cont| {
- cont.reify_as(); //~ ERROR type annotations needed
+ //~^ ERROR type annotations needed
+ cont.reify_as();
cont
})
}
diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr
index 957052feb..39bf22142 100644
--- a/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr
+++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr
@@ -1,14 +1,30 @@
error[E0282]: type annotations needed
- --> $DIR/hidden-type-is-opaque-2.rs:9:9
+ --> $DIR/hidden-type-is-opaque-2.rs:8:17
|
+LL | Thunk::new(|mut cont| {
+ | ^^^^^^^^
+LL |
LL | cont.reify_as();
- | ^^^^ cannot infer type
+ | ---- type must be known at this point
+ |
+help: consider giving this closure parameter an explicit type
+ |
+LL | Thunk::new(|mut cont: /* Type */| {
+ | ++++++++++++
error[E0282]: type annotations needed
- --> $DIR/hidden-type-is-opaque-2.rs:18:9
+ --> $DIR/hidden-type-is-opaque-2.rs:18:17
|
+LL | Thunk::new(|mut cont| {
+ | ^^^^^^^^
+LL |
LL | cont.reify_as();
- | ^^^^ cannot infer type
+ | ---- type must be known at this point
+ |
+help: consider giving this closure parameter an explicit type
+ |
+LL | Thunk::new(|mut cont: /* Type */| {
+ | ++++++++++++
error: aborting due to 2 previous errors
diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr
index 835f7f765..4e453c108 100644
--- a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr
+++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr
@@ -8,6 +8,6 @@ LL | |x| x
| |
| hidden type `&u8` captures the anonymous lifetime as defined here
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
index 443ffeb55..a5982a554 100644
--- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
+++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
@@ -5,7 +5,7 @@ LL | fn d() -> impl Fn() -> (impl Debug + '_) {
| ^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
-help: consider using the `'static` lifetime
+help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
LL | fn d() -> impl Fn() -> (impl Debug + 'static) {
| ~~~~~~~
diff --git a/tests/ui/impl-trait/impl-generic-mismatch-ab.stderr b/tests/ui/impl-trait/impl-generic-mismatch-ab.stderr
index db97fc2bd..7046e729e 100644
--- a/tests/ui/impl-trait/impl-generic-mismatch-ab.stderr
+++ b/tests/ui/impl-trait/impl-generic-mismatch-ab.stderr
@@ -18,6 +18,6 @@ LL | fn foo<A: Debug>(&self, a: &A, b: &impl Debug);
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/impl-subtyper.rs b/tests/ui/impl-trait/impl-subtyper.rs
new file mode 100644
index 000000000..2d99cdd4f
--- /dev/null
+++ b/tests/ui/impl-trait/impl-subtyper.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![crate_type = "lib"]
+fn checkpoints() -> impl Iterator {
+ Some(()).iter().flat_map(|_| std::iter::once(()))
+}
+
+fn block_checkpoints() -> impl Iterator {
+ checkpoints()
+}
+
+fn iter_raw() -> impl Iterator {
+ let mut iter = block_checkpoints();
+
+ (0..9).map(move |_| {
+ iter.next();
+ })
+}
diff --git a/tests/ui/impl-trait/impl-subtyper2.rs b/tests/ui/impl-trait/impl-subtyper2.rs
new file mode 100644
index 000000000..2e0acbae6
--- /dev/null
+++ b/tests/ui/impl-trait/impl-subtyper2.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+fn ages() -> Option<impl Iterator> {
+ None::<std::slice::Iter<()>>
+}
+
+fn main(){}
diff --git a/tests/ui/impl-trait/impl-trait-in-macro.stderr b/tests/ui/impl-trait/impl-trait-in-macro.stderr
index 7cfbe3447..4380f47c5 100644
--- a/tests/ui/impl-trait/impl-trait-in-macro.stderr
+++ b/tests/ui/impl-trait/impl-trait-in-macro.stderr
@@ -17,6 +17,6 @@ LL | a = y;
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/implicit-capture-late.rs b/tests/ui/impl-trait/implicit-capture-late.rs
new file mode 100644
index 000000000..8bfb16760
--- /dev/null
+++ b/tests/ui/impl-trait/implicit-capture-late.rs
@@ -0,0 +1,14 @@
+// known-bug: #117647
+
+#![feature(lifetime_capture_rules_2024)]
+#![feature(rustc_attrs)]
+#![allow(internal_features)]
+#![rustc_variance_of_opaques]
+
+use std::ops::Deref;
+
+fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> {
+ Box::new(x)
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/implicit-capture-late.stderr b/tests/ui/impl-trait/implicit-capture-late.stderr
new file mode 100644
index 000000000..9b3a4ff5f
--- /dev/null
+++ b/tests/ui/impl-trait/implicit-capture-late.stderr
@@ -0,0 +1,9 @@
+error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
+ --> $DIR/implicit-capture-late.rs:10:36
+ |
+LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> {
+ | ^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0657`.
diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr
index 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<T> {
diff --git a/tests/ui/impl-trait/in-assoc-type.stderr b/tests/ui/impl-trait/in-assoc-type.stderr
index f0a272dc2..d5b543ea9 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,11 +12,11 @@ LL | fn foo(&self) -> <Self as Foo<()>>::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) -> <Self as Foo<()>>::Bar {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs b/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs
new file mode 100644
index 000000000..09fbef2ec
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs
@@ -0,0 +1,12 @@
+// compile-flags: --crate-type=lib
+// check-pass
+
+#![deny(refining_impl_trait)]
+
+pub trait Tr<T> {
+ fn foo() -> impl for<'a> Tr<&'a Self>;
+}
+
+impl<T> Tr<T> for () {
+ fn foo() -> impl for<'a> Tr<&'a Self> {}
+}
diff --git a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs
new file mode 100644
index 000000000..afb9992de
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs
@@ -0,0 +1,29 @@
+// check-pass
+// edition: 2021
+// issue: 113796
+
+
+trait AsyncLendingIterator {
+ type Item<'a>
+ where
+ Self: 'a;
+
+ #[allow(async_fn_in_trait)]
+ async fn next(&mut self) -> Option<Self::Item<'_>>;
+}
+
+struct Lend<I>(I);
+impl<I> AsyncLendingIterator for Lend<I> {
+ type Item<'a> = &'a I
+ where
+ Self: 'a;
+
+ // Checking that the synthetic `<Self as AsyncLendingIterator>::next()` GAT
+ // is well-formed requires being able to assume the WF types of `next`.
+
+ async fn next(&mut self) -> Option<Self::Item<'_>> {
+ todo!()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/async-and-ret-ref.rs b/tests/ui/impl-trait/in-trait/async-and-ret-ref.rs
new file mode 100644
index 000000000..af6ffe833
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/async-and-ret-ref.rs
@@ -0,0 +1,11 @@
+// edition:2021
+// https://github.com/rust-lang/rust/issues/117547
+
+trait T {}
+
+trait MyTrait {
+ async fn foo() -> &'static impl T;
+ //~^ ERROR the associated type `<Self as MyTrait>::{opaque#0}` may not live long enough
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr b/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr
new file mode 100644
index 000000000..79a86b0a3
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr
@@ -0,0 +1,14 @@
+error[E0310]: the associated type `<Self as MyTrait>::{opaque#0}` may not live long enough
+ --> $DIR/async-and-ret-ref.rs:7:5
+ |
+LL | async fn foo() -> &'static impl T;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | the associated type `<Self as MyTrait>::{opaque#0}` must be valid for the static lifetime...
+ | ...so that the reference type `&'static impl T` does not outlive the data it points at
+ |
+ = help: consider adding an explicit lifetime bound `<Self as MyTrait>::{opaque#0}: 'static`...
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0310`.
diff --git a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs
index 776006124..a213994ff 100644
--- a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs
+++ b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs
@@ -1,6 +1,4 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-
-#![feature(return_position_impl_trait_in_trait)]
+#![feature(lint_reasons)]
use std::ops::Deref;
@@ -10,5 +8,8 @@ pub trait Foo {
pub struct Foreign;
impl Foo for Foreign {
- fn bar(self) -> &'static () { &() }
+ #[expect(refining_impl_trait)]
+ fn bar(self) -> &'static () {
+ &()
+ }
}
diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs
new file mode 100644
index 000000000..41d5f0f64
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.rs
@@ -0,0 +1,10 @@
+// issue: 114146
+
+
+trait Foo {
+ fn bar<'other: 'a>() -> impl Sized + 'a {}
+ //~^ ERROR use of undeclared lifetime name `'a`
+ //~| ERROR use of undeclared lifetime name `'a`
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr
new file mode 100644
index 000000000..b0832eb33
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit-2.stderr
@@ -0,0 +1,33 @@
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/bad-item-bound-within-rpitit-2.rs:5:20
+ |
+LL | fn bar<'other: 'a>() -> impl Sized + 'a {}
+ | ^^ undeclared lifetime
+ |
+help: consider introducing lifetime `'a` here
+ |
+LL | fn bar<'a, 'other: 'a>() -> impl Sized + 'a {}
+ | +++
+help: consider introducing lifetime `'a` here
+ |
+LL | trait Foo<'a> {
+ | ++++
+
+error[E0261]: use of undeclared lifetime name `'a`
+ --> $DIR/bad-item-bound-within-rpitit-2.rs:5:42
+ |
+LL | fn bar<'other: 'a>() -> impl Sized + 'a {}
+ | ^^ undeclared lifetime
+ |
+help: consider introducing lifetime `'a` here
+ |
+LL | fn bar<'a, 'other: 'a>() -> impl Sized + 'a {}
+ | +++
+help: consider introducing lifetime `'a` here
+ |
+LL | trait Foo<'a> {
+ | ++++
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0261`.
diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs
new file mode 100644
index 000000000..5ddc97f1a
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.rs
@@ -0,0 +1,24 @@
+// issue: 114145
+
+
+pub trait Iterable {
+ type Item<'a>
+ where
+ Self: 'a;
+
+ fn iter(&self) -> impl '_ + Iterator<Item = Self::Item<'_>>;
+}
+
+impl<'a, I: 'a + Iterable> Iterable for &'a I {
+ type Item<'b> = I::Item<'a>
+ where
+ 'b: 'a;
+ //~^ ERROR impl has stricter requirements than trait
+
+ fn iter(&self) -> impl 'a + Iterator<Item = I::Item<'a>> {
+ //~^ WARN impl trait in impl method signature does not match trait method signature
+ (*self).iter()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr
new file mode 100644
index 000000000..c898d17f4
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/bad-item-bound-within-rpitit.stderr
@@ -0,0 +1,33 @@
+error[E0276]: impl has stricter requirements than trait
+ --> $DIR/bad-item-bound-within-rpitit.rs:15:13
+ |
+LL | type Item<'a>
+ | ------------- definition of `Item` from trait
+...
+LL | 'b: 'a;
+ | ^^ impl has extra requirement `'b: 'a`
+ |
+help: copy the `where` clause predicates from the trait
+ |
+LL | where Self: 'b;
+ | ~~~~~~~~~~~~~~
+
+warning: impl trait in impl method signature does not match trait method signature
+ --> $DIR/bad-item-bound-within-rpitit.rs:18:28
+ |
+LL | fn iter(&self) -> impl '_ + Iterator<Item = Self::Item<'_>>;
+ | ----------------------------------------- return type from trait method defined here
+...
+LL | fn iter(&self) -> impl 'a + Iterator<Item = I::Item<'a>> {
+ | ^^ this bound is stronger than that defined on the trait
+ |
+ = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
+ = note: `#[warn(refining_impl_trait)]` on by default
+help: replace the return type so that it matches the trait
+ |
+LL | fn iter(&self) -> impl Iterator<Item = <Self as Iterable>::Item<'_>> + '_ {
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to 1 previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0276`.
diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs
index f5290a5f4..87eb7beb1 100644
--- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs
+++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs
@@ -1,8 +1,5 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
struct TestA {}
struct TestB {}
diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs
new file mode 100644
index 000000000..2845b401b
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.rs
@@ -0,0 +1,8 @@
+struct Wrapper<G: Send>(G);
+
+trait Foo {
+ fn bar() -> Wrapper<impl Sized>;
+ //~^ ERROR `impl Sized` cannot be sent between threads safely
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr
new file mode 100644
index 000000000..86f9cc4d9
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr
@@ -0,0 +1,16 @@
+error[E0277]: `impl Sized` cannot be sent between threads safely
+ --> $DIR/check-wf-on-non-defaulted-rpitit.rs:4:17
+ |
+LL | fn bar() -> Wrapper<impl Sized>;
+ | ^^^^^^^^^^^^^^^^^^^ `impl Sized` cannot be sent between threads safely
+ |
+ = help: the trait `Send` is not implemented for `impl Sized`
+note: required by a bound in `Wrapper`
+ --> $DIR/check-wf-on-non-defaulted-rpitit.rs:1:19
+ |
+LL | struct Wrapper<G: Send>(G);
+ | ^^^^ required by this bound in `Wrapper`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/deep-match-works.rs b/tests/ui/impl-trait/in-trait/deep-match-works.rs
index 5c9d2e356..8c9927438 100644
--- a/tests/ui/impl-trait/in-trait/deep-match-works.rs
+++ b/tests/ui/impl-trait/in-trait/deep-match-works.rs
@@ -1,17 +1,16 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
+#![feature(lint_reasons)]
#![allow(incomplete_features)]
-struct Wrapper<T>(T);
+pub struct Wrapper<T>(T);
-trait Foo {
+pub trait Foo {
fn bar() -> Wrapper<impl Sized>;
}
impl Foo for () {
+ #[expect(refining_impl_trait)]
fn bar() -> Wrapper<i32> {
Wrapper(0)
}
diff --git a/tests/ui/impl-trait/in-trait/deep-match.next.stderr b/tests/ui/impl-trait/in-trait/deep-match.next.stderr
deleted file mode 100644
index 400db20c7..000000000
--- a/tests/ui/impl-trait/in-trait/deep-match.next.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0053]: method `bar` has an incompatible return type for trait
- --> $DIR/deep-match.rs:14:17
- |
-LL | fn bar() -> i32 {
- | ^^^
- | |
- | expected `Wrapper<_>`, found `i32`
- | return type in trait
- |
- = note: expected struct `Wrapper<_>`
- found type `i32`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/in-trait/deep-match.rs b/tests/ui/impl-trait/in-trait/deep-match.rs
index 413d054e1..82eac7760 100644
--- a/tests/ui/impl-trait/in-trait/deep-match.rs
+++ b/tests/ui/impl-trait/in-trait/deep-match.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
struct Wrapper<T>(T);
trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/deep-match.current.stderr b/tests/ui/impl-trait/in-trait/deep-match.stderr
index 400db20c7..8ec30239e 100644
--- a/tests/ui/impl-trait/in-trait/deep-match.current.stderr
+++ b/tests/ui/impl-trait/in-trait/deep-match.stderr
@@ -1,5 +1,5 @@
error[E0053]: method `bar` has an incompatible return type for trait
- --> $DIR/deep-match.rs:14:17
+ --> $DIR/deep-match.rs:8:17
|
LL | fn bar() -> i32 {
| ^^^
@@ -10,6 +10,6 @@ LL | fn bar() -> i32 {
= note: expected struct `Wrapper<_>`
found type `i32`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr
deleted file mode 100644
index 85450e3b0..000000000
--- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/default-body-type-err-2.rs:10:9
- |
-LL | 42
- | ^^- help: try using a conversion method: `.to_string()`
- | |
- | expected `String`, found integer
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs
index 623237763..29bcbe16d 100644
--- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs
+++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs
@@ -1,9 +1,6 @@
// edition:2021
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
#![allow(incomplete_features)]
-#![feature(async_fn_in_trait)]
pub trait Foo {
async fn woopsie_async(&self) -> String {
diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr
index 85450e3b0..77f6945f0 100644
--- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr
+++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr
@@ -1,11 +1,11 @@
error[E0308]: mismatched types
- --> $DIR/default-body-type-err-2.rs:10:9
+ --> $DIR/default-body-type-err-2.rs:7:9
|
LL | 42
| ^^- help: try using a conversion method: `.to_string()`
| |
| expected `String`, found integer
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr
deleted file mode 100644
index c949168a3..000000000
--- a/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String`
- --> $DIR/default-body-type-err.rs:10:22
- |
-LL | fn lol(&self) -> impl Deref<Target = String> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String`
-LL |
-LL | &1i32
- | ----- return type was inferred to be `&i32` here
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.rs b/tests/ui/impl-trait/in-trait/default-body-type-err.rs
index 9bd5b7779..ac7a50a36 100644
--- a/tests/ui/impl-trait/in-trait/default-body-type-err.rs
+++ b/tests/ui/impl-trait/in-trait/default-body-type-err.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![allow(incomplete_features)]
-#![feature(return_position_impl_trait_in_trait)]
-
use std::ops::Deref;
pub trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr
index c949168a3..6f1ac4bce 100644
--- a/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr
+++ b/tests/ui/impl-trait/in-trait/default-body-type-err.stderr
@@ -1,5 +1,5 @@
error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String`
- --> $DIR/default-body-type-err.rs:10:22
+ --> $DIR/default-body-type-err.rs:4:22
|
LL | fn lol(&self) -> impl Deref<Target = String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String`
@@ -7,6 +7,6 @@ LL |
LL | &1i32
| ----- return type was inferred to be `&i32` here
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr
deleted file mode 100644
index 3c24eff9a..000000000
--- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-error: concrete type differs from previous defining opaque type use
- --> $DIR/default-body-with-rpit.rs:13:9
- |
-LL | ""
- | ^^ expected `impl Debug`, got `&'static str`
- |
-note: previous use here
- --> $DIR/default-body-with-rpit.rs:12:39
- |
-LL | async fn baz(&self) -> impl Debug {
- | _______________________________________^
-LL | | ""
-LL | | }
- | |_____^
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/default-body-with-rpit.rs:12:28
- |
-LL | async fn baz(&self) -> impl Debug {
- | ^^^^^^^^^^ cannot resolve opaque type
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr
deleted file mode 100644
index 3c24eff9a..000000000
--- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-error: concrete type differs from previous defining opaque type use
- --> $DIR/default-body-with-rpit.rs:13:9
- |
-LL | ""
- | ^^ expected `impl Debug`, got `&'static str`
- |
-note: previous use here
- --> $DIR/default-body-with-rpit.rs:12:39
- |
-LL | async fn baz(&self) -> impl Debug {
- | _______________________________________^
-LL | | ""
-LL | | }
- | |_____^
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/default-body-with-rpit.rs:12:28
- |
-LL | async fn baz(&self) -> impl Debug {
- | ^^^^^^^^^^ cannot resolve opaque type
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs
index 6bcc7b9ef..1d1f55508 100644
--- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs
+++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs
@@ -1,14 +1,12 @@
// edition:2021
-// known-bug: #108304
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
+// check-pass
-#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
trait Foo {
+ #[allow(async_fn_in_trait)]
async fn baz(&self) -> impl Debug {
""
}
diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs
index ab6a51c6b..ff70f1e23 100644
--- a/tests/ui/impl-trait/in-trait/default-body.rs
+++ b/tests/ui/impl-trait/in-trait/default-body.rs
@@ -1,14 +1,12 @@
// check-pass
// edition:2021
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
trait Foo {
+ #[allow(async_fn_in_trait)]
async fn baz(&self) -> &str {
""
}
diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs
index 187039f44..ca41eb8bc 100644
--- a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs
+++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs
@@ -1,8 +1,5 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
trait Trait {
type Type;
diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs
index 4f0bf2e7d..8ab2e2797 100644
--- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs
+++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs
@@ -1,10 +1,7 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
// This didn't work in the previous default RPITIT method hack attempt
-#![feature(return_position_impl_trait_in_trait)]
trait Foo {
fn bar(x: bool) -> impl Sized {
diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr
deleted file mode 100644
index 653016cf0..000000000
--- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0277]: `()` doesn't implement `std::fmt::Display`
- --> $DIR/doesnt-satisfy.rs:12:17
- |
-LL | fn bar() -> () {}
- | ^^ `()` cannot be formatted with the default formatter
- |
- = help: the trait `std::fmt::Display` is not implemented for `()`
- = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
-note: required by a bound in `Foo::bar::{opaque#0}`
- --> $DIR/doesnt-satisfy.rs:8:22
- |
-LL | fn bar() -> impl std::fmt::Display;
- | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::bar::{opaque#0}`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs
index fcd0b51ee..0ac60918b 100644
--- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs
+++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
trait Foo {
fn bar() -> impl std::fmt::Display;
}
diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr
index f0cd43bcf..baee1b5db 100644
--- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr
+++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr
@@ -1,5 +1,5 @@
error[E0277]: `()` doesn't implement `std::fmt::Display`
- --> $DIR/doesnt-satisfy.rs:12:17
+ --> $DIR/doesnt-satisfy.rs:6:17
|
LL | fn bar() -> () {}
| ^^ `()` cannot be formatted with the default formatter
@@ -7,11 +7,11 @@ LL | fn bar() -> () {}
= help: the trait `std::fmt::Display` is not implemented for `()`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `Foo::{opaque#0}`
- --> $DIR/doesnt-satisfy.rs:8:22
+ --> $DIR/doesnt-satisfy.rs:2:22
|
LL | fn bar() -> impl std::fmt::Display;
| ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr
deleted file mode 100644
index d4d0124a6..000000000
--- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0046]: not all trait items implemented, missing: `foo`
- --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1
- |
-LL | fn foo(&self) -> impl Sized;
- | ---------------------------- `foo` from trait
-...
-LL | impl MyTrait for i32 {
- | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs
index 4d50b8c92..fe0f011b6 100644
--- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs
+++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs
@@ -1,8 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-
trait MyTrait {
fn foo(&self) -> impl Sized;
fn bar(&self) -> impl Sized;
diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr
index d4d0124a6..39f70e413 100644
--- a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr
+++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.stderr
@@ -1,5 +1,5 @@
error[E0046]: not all trait items implemented, missing: `foo`
- --> $DIR/dont-project-to-rpitit-with-no-value.rs:11:1
+ --> $DIR/dont-project-to-rpitit-with-no-value.rs:6:1
|
LL | fn foo(&self) -> impl Sized;
| ---------------------------- `foo` from trait
@@ -7,6 +7,6 @@ LL | fn foo(&self) -> impl Sized;
LL | impl MyTrait for i32 {
| ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/impl-trait/in-trait/early.rs b/tests/ui/impl-trait/in-trait/early.rs
index 831033a58..c4996674d 100644
--- a/tests/ui/impl-trait/in-trait/early.rs
+++ b/tests/ui/impl-trait/in-trait/early.rs
@@ -1,12 +1,10 @@
// check-pass
// edition:2021
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(async_fn_in_trait, return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
pub trait Foo {
+ #[allow(async_fn_in_trait)]
async fn bar<'a: 'a>(&'a mut self);
}
diff --git a/tests/ui/impl-trait/in-trait/encode.rs b/tests/ui/impl-trait/in-trait/encode.rs
index 98aaf4a65..4df26b0f2 100644
--- a/tests/ui/impl-trait/in-trait/encode.rs
+++ b/tests/ui/impl-trait/in-trait/encode.rs
@@ -1,9 +1,6 @@
// build-pass
// compile-flags: --crate-type=lib
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
index 6eef392c0..9cc4c4b2f 100644
--- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
+++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
@@ -5,11 +5,12 @@ LL | let _: &dyn rpitit::Foo = todo!();
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/auxiliary/rpitit.rs:8:21
+ --> $DIR/auxiliary/rpitit.rs:6:21
|
LL | fn bar(self) -> impl Deref<Target = impl Sized>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because method `bar` references an `impl Trait` type in its return type
+ = help: only type `rpitit::Foreign` implements the trait, consider using it directly instead
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs
index 98417b343..6285d7786 100644
--- a/tests/ui/impl-trait/in-trait/foreign.rs
+++ b/tests/ui/impl-trait/in-trait/foreign.rs
@@ -1,7 +1,7 @@
// check-pass
// aux-build: rpitit.rs
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
+
+#![feature(lint_reasons)]
extern crate rpitit;
@@ -9,9 +9,24 @@ use rpitit::{Foo, Foreign};
use std::sync::Arc;
// Implement an RPITIT from another crate.
-struct Local;
+pub struct Local;
impl Foo for Local {
- fn bar(self) -> Arc<String> { Arc::new(String::new()) }
+ #[expect(refining_impl_trait)]
+ fn bar(self) -> Arc<String> {
+ Arc::new(String::new())
+ }
+}
+
+struct LocalIgnoreRefining;
+impl Foo for LocalIgnoreRefining {
+ #[deny(refining_impl_trait)]
+ fn bar(self) -> Arc<String> {
+ Arc::new(String::new())
+ }
+}
+
+fn generic(f: impl Foo) {
+ let x = &*f.bar();
}
fn main() {
@@ -19,4 +34,5 @@ fn main() {
let &() = Foreign.bar();
let x: Arc<String> = Local.bar();
+ let x: Arc<String> = LocalIgnoreRefining.bar();
}
diff --git a/tests/ui/impl-trait/in-trait/gat-outlives.rs b/tests/ui/impl-trait/in-trait/gat-outlives.rs
new file mode 100644
index 000000000..83dd6cfce
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/gat-outlives.rs
@@ -0,0 +1,17 @@
+// edition: 2021
+
+use std::future::Future;
+
+trait Trait {
+ type Gat<'a>;
+ //~^ ERROR missing required bound on `Gat`
+ async fn foo(&self) -> Self::Gat<'_>;
+}
+
+trait Trait2 {
+ type Gat<'a>;
+ //~^ ERROR missing required bound on `Gat`
+ async fn foo(&self) -> impl Future<Output = Self::Gat<'_>>;
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/gat-outlives.stderr b/tests/ui/impl-trait/in-trait/gat-outlives.stderr
new file mode 100644
index 000000000..8ec4b0ab2
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/gat-outlives.stderr
@@ -0,0 +1,24 @@
+error: missing required bound on `Gat`
+ --> $DIR/gat-outlives.rs:6:5
+ |
+LL | type Gat<'a>;
+ | ^^^^^^^^^^^^-
+ | |
+ | help: add the required where clause: `where Self: 'a`
+ |
+ = note: this bound is currently required to ensure that impls have maximum flexibility
+ = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
+
+error: missing required bound on `Gat`
+ --> $DIR/gat-outlives.rs:12:5
+ |
+LL | type Gat<'a>;
+ | ^^^^^^^^^^^^-
+ | |
+ | help: add the required where clause: `where Self: 'a`
+ |
+ = note: this bound is currently required to ensure that impls have maximum flexibility
+ = note: we are soliciting feedback, see issue #87479 <https://github.com/rust-lang/rust/issues/87479> for more information
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr
deleted file mode 100644
index 310edbcb6..000000000
--- a/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters
- --> $DIR/generics-mismatch.rs:14:12
- |
-LL | fn bar(&self) -> impl Sized;
- | - expected 0 type parameters
-...
-LL | fn bar<T>(&self) {}
- | ^ found 1 type parameter
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0049`.
diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.rs b/tests/ui/impl-trait/in-trait/generics-mismatch.rs
index 9259ca193..3ea31cc93 100644
--- a/tests/ui/impl-trait/in-trait/generics-mismatch.rs
+++ b/tests/ui/impl-trait/in-trait/generics-mismatch.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
struct U;
trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr
index 310edbcb6..d847065eb 100644
--- a/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr
+++ b/tests/ui/impl-trait/in-trait/generics-mismatch.stderr
@@ -1,5 +1,5 @@
error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters
- --> $DIR/generics-mismatch.rs:14:12
+ --> $DIR/generics-mismatch.rs:8:12
|
LL | fn bar(&self) -> impl Sized;
| - expected 0 type parameters
@@ -7,6 +7,6 @@ LL | fn bar(&self) -> impl Sized;
LL | fn bar<T>(&self) {}
| ^ found 1 type parameter
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0049`.
diff --git a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr
deleted file mode 100644
index 7aa7880e2..000000000
--- a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr
+++ /dev/null
@@ -1,33 +0,0 @@
-error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
- --> $DIR/issue-102140.rs:26:22
- |
-LL | MyTrait::foo(&self)
- | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
- | |
- | required by a bound introduced by this call
- |
-help: consider removing the leading `&`-reference
- |
-LL - MyTrait::foo(&self)
-LL + MyTrait::foo(self)
- |
-
-error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
- --> $DIR/issue-102140.rs:26:9
- |
-LL | MyTrait::foo(&self)
- | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
- |
- = help: the trait `MyTrait` is implemented for `Outer`
-
-error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
- --> $DIR/issue-102140.rs:26:9
- |
-LL | MyTrait::foo(&self)
- | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
- |
- = help: the trait `MyTrait` is implemented for `Outer`
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/issue-102140.rs b/tests/ui/impl-trait/in-trait/issue-102140.rs
index 4dcac4f5b..796001848 100644
--- a/tests/ui/impl-trait/in-trait/issue-102140.rs
+++ b/tests/ui/impl-trait/in-trait/issue-102140.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
trait Marker {}
impl Marker for u32 {}
diff --git a/tests/ui/impl-trait/in-trait/issue-102140.current.stderr b/tests/ui/impl-trait/in-trait/issue-102140.stderr
index 7aa7880e2..9cd2cdfd1 100644
--- a/tests/ui/impl-trait/in-trait/issue-102140.current.stderr
+++ b/tests/ui/impl-trait/in-trait/issue-102140.stderr
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
- --> $DIR/issue-102140.rs:26:22
+ --> $DIR/issue-102140.rs:20:22
|
LL | MyTrait::foo(&self)
| ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
@@ -13,7 +13,7 @@ LL + MyTrait::foo(self)
|
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
- --> $DIR/issue-102140.rs:26:9
+ --> $DIR/issue-102140.rs:20:9
|
LL | MyTrait::foo(&self)
| ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
@@ -21,7 +21,7 @@ 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
+ --> $DIR/issue-102140.rs:20:9
|
LL | MyTrait::foo(&self)
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
diff --git a/tests/ui/impl-trait/in-trait/issue-102301.rs b/tests/ui/impl-trait/in-trait/issue-102301.rs
index 1329ca29d..600a21b07 100644
--- a/tests/ui/impl-trait/in-trait/issue-102301.rs
+++ b/tests/ui/impl-trait/in-trait/issue-102301.rs
@@ -1,8 +1,5 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
trait Foo<T> {
diff --git a/tests/ui/impl-trait/in-trait/issue-102571.next.stderr b/tests/ui/impl-trait/in-trait/issue-102571.next.stderr
deleted file mode 100644
index cac9a29f6..000000000
--- a/tests/ui/impl-trait/in-trait/issue-102571.next.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/issue-102571.rs:23:9
- |
-LL | let () = t.bar();
- | ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
- | |
- | expected associated type, found `()`
- |
- = note: expected associated type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
- found unit type `()`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/issue-102571.rs b/tests/ui/impl-trait/in-trait/issue-102571.rs
index f0ddab5e7..4fa3fdd31 100644
--- a/tests/ui/impl-trait/in-trait/issue-102571.rs
+++ b/tests/ui/impl-trait/in-trait/issue-102571.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
use std::fmt::Display;
use std::ops::Deref;
@@ -11,14 +5,6 @@ trait Foo {
fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
}
-struct A;
-
-impl Foo for A {
- fn bar(self) -> &'static str {
- "Hello, world"
- }
-}
-
fn foo<T: Foo>(t: T) {
let () = t.bar();
//~^ ERROR mismatched types
diff --git a/tests/ui/impl-trait/in-trait/issue-102571.current.stderr b/tests/ui/impl-trait/in-trait/issue-102571.stderr
index cac9a29f6..1f25069a0 100644
--- a/tests/ui/impl-trait/in-trait/issue-102571.current.stderr
+++ b/tests/ui/impl-trait/in-trait/issue-102571.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/issue-102571.rs:23:9
+ --> $DIR/issue-102571.rs:9:9
|
LL | let () = t.bar();
| ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
@@ -9,6 +9,6 @@ LL | let () = t.bar();
= note: expected associated type `impl Deref<Target = impl std::fmt::Display + ?Sized>`
found unit type `()`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs b/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs
new file mode 100644
index 000000000..4073ef8ac
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/lifetime-in-associated-trait-bound.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+#![feature(associated_type_bounds)]
+
+trait Trait {
+ type Type;
+
+ fn method(&self) -> impl Trait<Type: '_>;
+}
+
+impl Trait for () {
+ type Type = ();
+
+ fn method(&self) -> impl Trait<Type: '_> {
+ ()
+ }
+}
+
+fn main() {}
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..59ffea6fb
--- /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:57:27
+ |
+LL | fn early<'late, T>(_: &'late ()) {}
+ | - ^^^^^^^^^
+ | | |
+ | | expected type parameter `T`, found `()`
+ | | help: change the parameter type to match the trait: `&T`
+ | expected this type parameter
+ |
+note: type in trait
+ --> $DIR/method-signature-matches.rs:52:28
+ |
+LL | fn early<'early, T>(x: &'early T) -> impl Sized;
+ | ^^^^^^^^^
+ = note: expected signature `fn(&T)`
+ found signature `fn(&'late ())`
+
+error: aborting due to 1 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..f8980828b
--- /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:13: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:8:15
+ |
+LL | fn owo(x: ()) -> impl Sized;
+ | ^^
+ = note: expected signature `fn(())`
+ found signature `fn(u8)`
+
+error: aborting due to 1 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..a6fb1a200
--- /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:24: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:19:21
+ |
+LL | async fn owo(x: ()) {}
+ | ^^
+ = note: expected signature `fn(()) -> _`
+ found signature `fn(u8) -> _`
+
+error: aborting due to 1 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..99ace66fa 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,61 @@
// 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..0b26e039e
--- /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:46: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 1 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..9226e1f8b
--- /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:35: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 1 previous error
+
+For more information about this error, try `rustc --explain E0050`.
diff --git a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs
new file mode 100644
index 000000000..6088dcc61
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.rs
@@ -0,0 +1,10 @@
+trait Iterable {
+ type Item<'a>
+ where
+ Self: 'a;
+
+ fn iter(&self) -> impl Iterator<Item = Self::Item<'missing>>;
+ //~^ ERROR use of undeclared lifetime name `'missing`
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr
new file mode 100644
index 000000000..3e763c9f1
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/missing-lt-outlives-in-rpitit-114274.stderr
@@ -0,0 +1,23 @@
+error[E0261]: use of undeclared lifetime name `'missing`
+ --> $DIR/missing-lt-outlives-in-rpitit-114274.rs:6:55
+ |
+LL | fn iter(&self) -> impl Iterator<Item = Self::Item<'missing>>;
+ | ^^^^^^^^ undeclared lifetime
+ |
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the bound lifetime-generic with a new `'missing` lifetime
+ |
+LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missing>>;
+ | +++++++++++++
+help: consider introducing lifetime `'missing` here
+ |
+LL | fn iter<'missing>(&self) -> impl Iterator<Item = Self::Item<'missing>>;
+ | ++++++++++
+help: consider introducing lifetime `'missing` here
+ |
+LL | trait Iterable<'missing> {
+ | ++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0261`.
diff --git a/tests/ui/impl-trait/in-trait/nested-rpitit-bounds.rs b/tests/ui/impl-trait/in-trait/nested-rpitit-bounds.rs
new file mode 100644
index 000000000..b97fd7d1f
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/nested-rpitit-bounds.rs
@@ -0,0 +1,11 @@
+// check-pass
+
+use std::ops::Deref;
+
+trait Foo {
+ fn foo() -> impl Deref<Target = impl Deref<Target = impl Sized>> {
+ &&()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/nested-rpitit.rs b/tests/ui/impl-trait/in-trait/nested-rpitit.rs
index 360207537..58b79c991 100644
--- a/tests/ui/impl-trait/in-trait/nested-rpitit.rs
+++ b/tests/ui/impl-trait/in-trait/nested-rpitit.rs
@@ -1,28 +1,28 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
+#![feature(lint_reasons)]
#![allow(incomplete_features)]
use std::fmt::Display;
use std::ops::Deref;
-trait Foo {
+pub trait Foo {
fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
}
-struct A;
+pub struct A;
impl Foo for A {
+ #[expect(refining_impl_trait)]
fn bar(self) -> &'static str {
"Hello, world"
}
}
-struct B;
+pub struct B;
impl Foo for B {
+ #[expect(refining_impl_trait)]
fn bar(self) -> Box<i32> {
Box::new(42)
}
diff --git a/tests/ui/impl-trait/in-trait/object-safety-sized.rs b/tests/ui/impl-trait/in-trait/object-safety-sized.rs
new file mode 100644
index 000000000..1a23493a9
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/object-safety-sized.rs
@@ -0,0 +1,22 @@
+// check-pass
+// revisions: current next
+//[next] compile-flags: -Znext-solver
+
+
+fn main() {
+ let vec: Vec<Box<dyn Trait>> = Vec::new();
+
+ for i in vec {
+ i.fn_2();
+ }
+}
+
+trait OtherTrait {}
+
+trait Trait {
+ fn fn_1(&self) -> impl OtherTrait
+ where
+ Self: Sized;
+
+ fn fn_2(&self) -> bool;
+}
diff --git a/tests/ui/impl-trait/in-trait/object-safety.next.stderr b/tests/ui/impl-trait/in-trait/object-safety.next.stderr
deleted file mode 100644
index 2c340a023..000000000
--- a/tests/ui/impl-trait/in-trait/object-safety.next.stderr
+++ /dev/null
@@ -1,49 +0,0 @@
-error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/object-safety.rs:20:33
- |
-LL | let i = Box::new(42_u32) as Box<dyn Foo>;
- | ^^^^^^^^^^^^ `Foo` cannot be made into an object
- |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/object-safety.rs:10:22
- |
-LL | trait Foo {
- | --- this trait cannot be made into an object...
-LL | fn baz(&self) -> impl Debug;
- | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
- = help: consider moving `baz` to another trait
-
-error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/object-safety.rs:23:13
- |
-LL | let s = i.baz();
- | ^^^^^^^ `Foo` cannot be made into an object
- |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/object-safety.rs:10:22
- |
-LL | trait Foo {
- | --- this trait cannot be made into an object...
-LL | fn baz(&self) -> impl Debug;
- | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
- = help: consider moving `baz` to another trait
-
-error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/object-safety.rs:20:13
- |
-LL | let i = Box::new(42_u32) as Box<dyn Foo>;
- | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
- |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/object-safety.rs:10:22
- |
-LL | trait Foo {
- | --- this trait cannot be made into an object...
-LL | fn baz(&self) -> impl Debug;
- | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
- = help: consider moving `baz` to another trait
- = note: required for the cast from `Box<u32>` to `Box<dyn Foo>`
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs
index 016a0aaae..5cca4ad83 100644
--- a/tests/ui/impl-trait/in-trait/object-safety.rs
+++ b/tests/ui/impl-trait/in-trait/object-safety.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
use std::fmt::Debug;
trait Foo {
@@ -11,7 +5,7 @@ trait Foo {
}
impl Foo for u32 {
- fn baz(&self) -> u32 {
+ fn baz(&self) -> impl Debug {
32
}
}
@@ -22,4 +16,5 @@ fn main() {
//~| ERROR the trait `Foo` cannot be made into an object
let s = i.baz();
//~^ ERROR the trait `Foo` cannot be made into an object
+ //~| ERROR the trait `Foo` cannot be made into an object
}
diff --git a/tests/ui/impl-trait/in-trait/object-safety.current.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr
index 2c340a023..a7be0516c 100644
--- a/tests/ui/impl-trait/in-trait/object-safety.current.stderr
+++ b/tests/ui/impl-trait/in-trait/object-safety.stderr
@@ -1,49 +1,68 @@
error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/object-safety.rs:20:33
+ --> $DIR/object-safety.rs:14:33
|
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/object-safety.rs:10:22
+ --> $DIR/object-safety.rs:4:22
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
+ = help: only type `u32` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/object-safety.rs:23:13
+ --> $DIR/object-safety.rs:17:15
+ |
+LL | let s = i.baz();
+ | ^^^ `Foo` cannot be made into an object
+ |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+ --> $DIR/object-safety.rs:4:22
+ |
+LL | trait Foo {
+ | --- this trait cannot be made into an object...
+LL | fn baz(&self) -> impl Debug;
+ | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
+ = help: consider moving `baz` to another trait
+ = help: only type `u32` implements the trait, consider using it directly instead
+
+error[E0038]: the trait `Foo` cannot be made into an object
+ --> $DIR/object-safety.rs:17:13
|
LL | let s = i.baz();
| ^^^^^^^ `Foo` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/object-safety.rs:10:22
+ --> $DIR/object-safety.rs:4:22
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
+ = help: only type `u32` implements the trait, consider using it directly instead
error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/object-safety.rs:20:13
+ --> $DIR/object-safety.rs:14:13
|
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
- --> $DIR/object-safety.rs:10:22
+ --> $DIR/object-safety.rs:4:22
|
LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
+ = help: only type `u32` implements the trait, consider using it directly instead
= note: required for the cast from `Box<u32>` to `Box<dyn Foo>`
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr
deleted file mode 100644
index a57653b2c..000000000
--- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/opaque-in-impl-is-opaque.rs:20:19
- |
-LL | fn bar(&self) -> impl Display {
- | ------------ the found opaque type
-...
-LL | let x: &str = ().bar();
- | ---- ^^^^^^^^ expected `&str`, found opaque type
- | |
- | expected due to this
- |
- = note: expected reference `&str`
- found opaque type `impl std::fmt::Display`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs
index c07ece15a..1f18bb3b7 100644
--- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs
+++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
use std::fmt::Display;
trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr
index a57653b2c..4996e6839 100644
--- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr
+++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/opaque-in-impl-is-opaque.rs:20:19
+ --> $DIR/opaque-in-impl-is-opaque.rs:14:19
|
LL | fn bar(&self) -> impl Display {
| ------------ the found opaque type
@@ -12,6 +12,6 @@ LL | let x: &str = ().bar();
= note: expected reference `&str`
found opaque type `impl std::fmt::Display`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs
index f48d9fa26..3edd588a1 100644
--- a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs
+++ b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs
@@ -1,8 +1,5 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
diff --git a/tests/ui/impl-trait/in-trait/opaque-variances.rs b/tests/ui/impl-trait/in-trait/opaque-variances.rs
new file mode 100644
index 000000000..63e56051d
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/opaque-variances.rs
@@ -0,0 +1,14 @@
+// check-pass
+// compile-flags: -Znext-solver
+
+fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Sized {
+ ()
+}
+
+fn main() {
+ // in NLL, we want to make sure that the `'a` subst of `foo` does not get
+ // related between `x` and the RHS of the assignment. That would require
+ // that the temp is live for the lifetime of the variable `x`, which of
+ // course is not necessary since `'a` is not captured by the RPIT.
+ let x = foo(&Vec::new());
+}
diff --git a/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs b/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs
new file mode 100644
index 000000000..317ff7fe8
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/outlives-in-nested-rpit.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+
+trait Foo {
+ fn early<'a, T: 'a>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
+
+ fn late<'a, T>(x: &'a T) -> impl Iterator<Item = impl Into<&'a T>>;
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/placeholder-implied-bounds.rs b/tests/ui/impl-trait/in-trait/placeholder-implied-bounds.rs
new file mode 100644
index 000000000..33d348703
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/placeholder-implied-bounds.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+pub fn main() {}
+
+pub trait Iced {
+ fn get(&self) -> &impl Sized;
+}
+
+/// Impl causes ICE
+impl Iced for () {
+ fn get(&self) -> &impl Sized {
+ &()
+ }
+}
diff --git a/tests/ui/impl-trait/in-trait/refine.rs b/tests/ui/impl-trait/in-trait/refine.rs
new file mode 100644
index 000000000..100e6da06
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/refine.rs
@@ -0,0 +1,58 @@
+#![deny(refining_impl_trait)]
+
+pub trait Foo {
+ fn bar() -> impl Sized;
+}
+
+pub struct A;
+impl Foo for A {
+ fn bar() -> impl Copy {}
+ //~^ ERROR impl method signature does not match trait method signature
+}
+
+pub struct B;
+impl Foo for B {
+ fn bar() {}
+ //~^ ERROR impl method signature does not match trait method signature
+}
+
+pub struct C;
+impl Foo for C {
+ fn bar() -> () {}
+ //~^ ERROR impl method signature does not match trait method signature
+}
+
+struct Private;
+impl Foo for Private {
+ fn bar() -> () {}
+}
+
+pub trait Arg<A> {
+ fn bar() -> impl Sized;
+}
+impl Arg<Private> for A {
+ fn bar() -> () {}
+}
+
+pub trait Late {
+ fn bar<'a>(&'a self) -> impl Sized + 'a;
+}
+
+pub struct D;
+impl Late for D {
+ fn bar(&self) -> impl Copy + '_ {}
+ //~^ ERROR impl method signature does not match trait method signature
+}
+
+mod unreachable {
+ pub trait UnreachablePub {
+ fn bar() -> impl Sized;
+ }
+
+ struct E;
+ impl UnreachablePub for E {
+ fn bar() {}
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/refine.stderr b/tests/ui/impl-trait/in-trait/refine.stderr
new file mode 100644
index 000000000..96a9bc059
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/refine.stderr
@@ -0,0 +1,67 @@
+error: impl trait in impl method signature does not match trait method signature
+ --> $DIR/refine.rs:9:22
+ |
+LL | fn bar() -> impl Sized;
+ | ---------- return type from trait method defined here
+...
+LL | fn bar() -> impl Copy {}
+ | ^^^^ this bound is stronger than that defined on the trait
+ |
+ = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
+note: the lint level is defined here
+ --> $DIR/refine.rs:1:9
+ |
+LL | #![deny(refining_impl_trait)]
+ | ^^^^^^^^^^^^^^^^^^^
+help: replace the return type so that it matches the trait
+ |
+LL | fn bar() -> impl Sized {}
+ | ~~~~~~~~~~
+
+error: impl trait in impl method signature does not match trait method signature
+ --> $DIR/refine.rs:15:5
+ |
+LL | fn bar() -> impl Sized;
+ | ---------- return type from trait method defined here
+...
+LL | fn bar() {}
+ | ^^^^^^^^
+ |
+ = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
+help: replace the return type so that it matches the trait
+ |
+LL | fn bar()-> impl Sized {}
+ | +++++++++++++
+
+error: impl trait in impl method signature does not match trait method signature
+ --> $DIR/refine.rs:21:17
+ |
+LL | fn bar() -> impl Sized;
+ | ---------- return type from trait method defined here
+...
+LL | fn bar() -> () {}
+ | ^^
+ |
+ = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
+help: replace the return type so that it matches the trait
+ |
+LL | fn bar() -> impl Sized {}
+ | ~~~~~~~~~~
+
+error: impl trait in impl method signature does not match trait method signature
+ --> $DIR/refine.rs:43:27
+ |
+LL | fn bar<'a>(&'a self) -> impl Sized + 'a;
+ | --------------- return type from trait method defined here
+...
+LL | fn bar(&self) -> impl Copy + '_ {}
+ | ^^^^ this bound is stronger than that defined on the trait
+ |
+ = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
+help: replace the return type so that it matches the trait
+ |
+LL | fn bar(&self) -> impl Sized + '_ {}
+ | ~~~~~~~~~~~~~~~
+
+error: aborting due to 4 previous errors
+
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..ad73b12fe
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs
@@ -0,0 +1,14 @@
+trait Foo<T> {
+ fn foo<F2>(self) -> impl Foo<T>;
+}
+
+struct Bar;
+
+impl Foo<char> for Bar {
+ fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
+ //~^ ERROR: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied [E0277]
+ self
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr
new file mode 100644
index 000000000..db587d069
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr
@@ -0,0 +1,16 @@
+error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied
+ --> $DIR/return-dont-satisfy-bounds.rs:8:34
+ |
+LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> {
+ | ^^^^^^^^^^^^ the trait `Foo<char>` is not implemented for `impl Foo<u8>`
+ |
+ = help: the trait `Foo<char>` is implemented for `Bar`
+note: required by a bound in `Foo::{opaque#0}`
+ --> $DIR/return-dont-satisfy-bounds.rs:2:30
+ |
+LL | fn foo<F2>(self) -> impl Foo<T>;
+ | ^^^^^^ required by this bound in `Foo::{opaque#0}`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/reveal.rs b/tests/ui/impl-trait/in-trait/reveal.rs
index 1f42ec744..cc78ce8fe 100644
--- a/tests/ui/impl-trait/in-trait/reveal.rs
+++ b/tests/ui/impl-trait/in-trait/reveal.rs
@@ -1,15 +1,14 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
+#![feature(lint_reasons)]
#![allow(incomplete_features)]
-trait Foo {
+pub trait Foo {
fn f() -> Box<impl Sized>;
}
impl Foo for () {
+ #[expect(refining_impl_trait)]
fn f() -> Box<String> {
Box::new(String::new())
}
diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs
new file mode 100644
index 000000000..37b0b2297
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs
@@ -0,0 +1,24 @@
+trait Extend {
+ fn extend<'a: 'a>(_: &'a str) -> (impl Sized + 'a, &'static str);
+}
+
+impl Extend for () {
+ fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str)
+ //~^ ERROR in type `&'static &'a ()`, reference has a longer lifetime than the data it references
+ where
+ 'a: 'static,
+ {
+ (None, s)
+ }
+}
+
+// This indirection is not necessary for reproduction,
+// but it makes this test future-proof against #114936.
+fn extend<T: Extend>(s: &str) -> &'static str {
+ <T as Extend>::extend(s).1
+}
+
+fn main() {
+ let use_after_free = extend::<()>(&String::from("temporary"));
+ println!("{}", use_after_free);
+}
diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr
new file mode 100644
index 000000000..5ace64b69
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr
@@ -0,0 +1,16 @@
+error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references
+ --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:6:38
+ |
+LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the pointer is valid for the static lifetime
+note: but the referenced data is only valid for the lifetime `'a` as defined here
+ --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:6:15
+ |
+LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str)
+ | ^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs
new file mode 100644
index 000000000..bacd50077
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs
@@ -0,0 +1,21 @@
+trait Extend {
+ fn extend(_: &str) -> (impl Sized + '_, &'static str);
+}
+
+impl Extend for () {
+ fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) {
+ //~^ ERROR in type `&'static &()`, reference has a longer lifetime than the data it references
+ (None, s)
+ }
+}
+
+// This indirection is not necessary for reproduction,
+// but it makes this test future-proof against #114936.
+fn extend<T: Extend>(s: &str) -> &'static str {
+ <T as Extend>::extend(s).1
+}
+
+fn main() {
+ let use_after_free = extend::<()>(&String::from("temporary"));
+ println!("{}", use_after_free);
+}
diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr
new file mode 100644
index 000000000..3430055da
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr
@@ -0,0 +1,16 @@
+error[E0491]: in type `&'static &()`, reference has a longer lifetime than the data it references
+ --> $DIR/rpitit-hidden-types-self-implied-wf.rs:6:27
+ |
+LL | fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the pointer is valid for the static lifetime
+note: but the referenced data is only valid for the anonymous lifetime defined here
+ --> $DIR/rpitit-hidden-types-self-implied-wf.rs:6:18
+ |
+LL | fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) {
+ | ^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs
new file mode 100644
index 000000000..b9fe8d8bf
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.rs
@@ -0,0 +1,19 @@
+// issue: 113903
+
+#![feature(lint_reasons)]
+
+use std::ops::Deref;
+
+pub trait Tr {
+ fn w() -> impl Deref<Target = Missing<impl Sized>>;
+ //~^ ERROR cannot find type `Missing` in this scope
+}
+
+impl Tr for () {
+ #[expect(refining_impl_trait)]
+ fn w() -> &'static () {
+ &()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr
new file mode 100644
index 000000000..73ada8d70
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/rpitit-shadowed-by-missing-adt.stderr
@@ -0,0 +1,9 @@
+error[E0412]: cannot find type `Missing` in this scope
+ --> $DIR/rpitit-shadowed-by-missing-adt.rs:8:35
+ |
+LL | fn w() -> impl Deref<Target = Missing<impl Sized>>;
+ | ^^^^^^^ not found in this scope
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs b/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs
new file mode 100644
index 000000000..fe162e6cf
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/sibling-function-constraint.rs
@@ -0,0 +1,21 @@
+// Checks that a sibling function (i.e. `foo`) cannot constrain
+// an RPITIT from another function (`bar`).
+
+trait Trait {
+ fn foo();
+
+ fn bar() -> impl Sized;
+}
+
+impl Trait for () {
+ fn foo() {
+ let _: String = Self::bar();
+ //~^ ERROR mismatched types
+ }
+
+ fn bar() -> impl Sized {
+ loop {}
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr b/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr
new file mode 100644
index 000000000..b8ac826ad
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/sibling-function-constraint.stderr
@@ -0,0 +1,17 @@
+error[E0308]: mismatched types
+ --> $DIR/sibling-function-constraint.rs:12:25
+ |
+LL | let _: String = Self::bar();
+ | ------ ^^^^^^^^^^^ expected `String`, found opaque type
+ | |
+ | expected due to this
+...
+LL | fn bar() -> impl Sized {
+ | ---------- the found opaque type
+ |
+ = note: expected struct `String`
+ found opaque type `impl Sized`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr
deleted file mode 100644
index eba270af7..000000000
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error: `impl` item signature doesn't match `trait` item signature
- --> $DIR/signature-mismatch.rs:17:5
- |
-LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
- | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
-...
-LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
- |
- = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
- found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '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
-
-error: aborting due to previous error
-
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr
new file mode 100644
index 000000000..0cd76815a
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr
@@ -0,0 +1,14 @@
+error[E0623]: lifetime mismatch
+ --> $DIR/signature-mismatch.rs:79:10
+ |
+LL | &'a self,
+ | -------- this parameter and the return type are declared with different lifetimes...
+...
+LL | ) -> impl Future<Output = Vec<u8>> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | ...but data from `buff` is returned here
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0623`.
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
deleted file mode 100644
index eba270af7..000000000
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error: `impl` item signature doesn't match `trait` item signature
- --> $DIR/signature-mismatch.rs:17:5
- |
-LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
- | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
-...
-LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
- |
- = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
- found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '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
-
-error: aborting due to previous error
-
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.rs b/tests/ui/impl-trait/in-trait/signature-mismatch.rs
index 38c902a97..d85ee5fc7 100644
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs
@@ -1,23 +1,98 @@
// edition:2021
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
+// revisions: success failure
+//[success] check-pass
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
+#![feature(lint_reasons)]
use std::future::Future;
+pub trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+pub trait Captures2<'a, 'b> {}
+impl<T> Captures2<'_, '_> for T {}
+
pub trait AsyncTrait {
+ #[cfg(success)]
fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
+
+ #[cfg(success)]
+ fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
+
+ #[cfg(success)]
+ fn async_fn_multiple<'a>(&'a self, buff: &[u8])
+ -> impl Future<Output = Vec<u8>> + Captures<'a>;
+
+ #[cfg(failure)]
+ fn async_fn_reduce_outlive<'a, T>(
+ &'a self,
+ buff: &[u8],
+ t: T,
+ ) -> impl Future<Output = Vec<u8>> + 'a;
+
+ #[cfg(success)]
+ fn async_fn_reduce<'a, T>(
+ &'a self,
+ buff: &[u8],
+ t: T,
+ ) -> impl Future<Output = Vec<u8>> + Captures<'a>;
}
pub struct Struct;
impl AsyncTrait for Struct {
+ // Does not capture more lifetimes that trait def'n, since trait def'n
+ // implicitly captures all in-scope lifetimes.
+ #[cfg(success)]
+ #[expect(refining_impl_trait)]
fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
- //~^ ERROR `impl` item signature doesn't match `trait` item signature
async move { buff.to_vec() }
}
+
+ // Does not capture more lifetimes that trait def'n, since trait def'n
+ // implicitly captures all in-scope lifetimes.
+ #[cfg(success)]
+ #[expect(refining_impl_trait)]
+ fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
+ async move { buff.to_vec() }
+ }
+
+ // Does not capture more lifetimes that trait def'n, since trait def'n
+ // implicitly captures all in-scope lifetimes.
+ #[cfg(success)]
+ #[expect(refining_impl_trait)]
+ fn async_fn_multiple<'a, 'b>(
+ &'a self,
+ buff: &'b [u8],
+ ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
+ async move { buff.to_vec() }
+ }
+
+ // This error message is awkward, but `impl Future<Output = Vec<u8>>`
+ // cannot outlive `'a` (from the trait signature) because it captures
+ // both `T` and `'b`.
+ #[cfg(failure)]
+ fn async_fn_reduce_outlive<'a, 'b, T>(
+ &'a self,
+ buff: &'b [u8],
+ t: T,
+ ) -> impl Future<Output = Vec<u8>> {
+ //[failure]~^ ERROR lifetime mismatch
+ async move {
+ let _t = t;
+ vec![]
+ }
+ }
+
+ // Does not capture fewer lifetimes that trait def'n (not that it matters),
+ // since impl also captures all in-scope lifetimes.
+ #[cfg(success)]
+ fn async_fn_reduce<'a, 'b, T>(&'a self, buff: &'b [u8], t: T) -> impl Future<Output = Vec<u8>> {
+ async move {
+ let _t = t;
+ vec![]
+ }
+ }
}
fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr
deleted file mode 100644
index f48e7a1ed..000000000
--- a/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr
+++ /dev/null
@@ -1,31 +0,0 @@
-error[E0053]: method `bar` has an incompatible type for trait
- --> $DIR/specialization-broken.rs:19:22
- |
-LL | default impl<U> Foo for U
- | - this type parameter
-...
-LL | fn bar(&self) -> U {
- | ^
- | |
- | expected associated type, found type parameter `U`
- | help: change the output type to match the trait: `impl Sized`
- |
-note: type in trait
- --> $DIR/specialization-broken.rs:12:22
- |
-LL | fn bar(&self) -> impl Sized;
- | ^^^^^^^^^^
- = note: expected signature `fn(&U) -> impl Sized`
- found signature `fn(&U) -> U`
-
-error: method with return-position `impl Trait` in trait cannot be specialized
- --> $DIR/specialization-broken.rs:19:5
- |
-LL | fn bar(&self) -> U {
- | ^^^^^^^^^^^^^^^^^^
- |
- = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0053`.
diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs
index 658d07097..a06cd814f 100644
--- a/tests/ui/impl-trait/in-trait/specialization-broken.rs
+++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs
@@ -1,11 +1,7 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
// FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not.
// But we fixed an ICE anyways.
#![feature(specialization)]
-#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr
index f48e7a1ed..b8a8e2401 100644
--- a/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr
+++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr
@@ -1,8 +1,8 @@
error[E0053]: method `bar` has an incompatible type for trait
- --> $DIR/specialization-broken.rs:19:22
+ --> $DIR/specialization-broken.rs:15:22
|
LL | default impl<U> Foo for U
- | - this type parameter
+ | - found this type parameter
...
LL | fn bar(&self) -> U {
| ^
@@ -11,20 +11,20 @@ LL | fn bar(&self) -> U {
| help: change the output type to match the trait: `impl Sized`
|
note: type in trait
- --> $DIR/specialization-broken.rs:12:22
+ --> $DIR/specialization-broken.rs:8:22
|
LL | fn bar(&self) -> impl Sized;
| ^^^^^^^^^^
- = note: expected signature `fn(&U) -> impl Sized`
- found signature `fn(&U) -> U`
+ = note: expected signature `fn(&_) -> impl Sized`
+ found signature `fn(&_) -> U`
error: method with return-position `impl Trait` in trait cannot be specialized
- --> $DIR/specialization-broken.rs:19:5
+ --> $DIR/specialization-broken.rs:15:5
|
LL | fn bar(&self) -> U {
| ^^^^^^^^^^^^^^^^^^
|
- = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed
+ = note: specialization behaves in inconsistent and surprising ways with return position `impl Trait` in traits, and for now is disallowed
error: aborting due to 2 previous errors
diff --git a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs
index dbc5d38f1..053866327 100644
--- a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs
+++ b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs
@@ -1,12 +1,10 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
#![feature(specialization)]
-#![feature(return_position_impl_trait_in_trait)]
+#![feature(lint_reasons)]
#![allow(incomplete_features)]
-trait Foo {
+pub trait Foo {
fn bar(&self) -> impl Sized;
}
@@ -14,6 +12,7 @@ impl<U> Foo for U
where
U: Copy,
{
+ #[expect(refining_impl_trait)]
fn bar(&self) -> U {
*self
}
diff --git a/tests/ui/impl-trait/in-trait/success.rs b/tests/ui/impl-trait/in-trait/success.rs
index 0e69e0490..eb2349feb 100644
--- a/tests/ui/impl-trait/in-trait/success.rs
+++ b/tests/ui/impl-trait/in-trait/success.rs
@@ -1,31 +1,32 @@
// check-pass
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
+#![feature(lint_reasons)]
#![allow(incomplete_features)]
use std::fmt::Display;
-trait Foo {
+pub trait Foo {
fn bar(&self) -> impl Display;
}
impl Foo for i32 {
+ #[expect(refining_impl_trait)]
fn bar(&self) -> i32 {
*self
}
}
impl Foo for &'static str {
+ #[expect(refining_impl_trait)]
fn bar(&self) -> &'static str {
*self
}
}
-struct Yay;
+pub struct Yay;
impl Foo for Yay {
+ #[expect(refining_impl_trait)]
fn bar(&self) -> String {
String::from(":^)")
}
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..8dc8e045d
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed
@@ -0,0 +1,26 @@
+// edition:2021
+// run-rustfix
+
+trait Trait {
+ #[allow(async_fn_in_trait)]
+ async fn foo();
+
+ #[allow(async_fn_in_trait)]
+ async fn bar() -> i32;
+
+ fn test(&self) -> impl Sized + '_;
+
+ #[allow(async_fn_in_trait)]
+ 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..30b04d87b
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs
@@ -0,0 +1,22 @@
+// edition:2021
+// run-rustfix
+
+trait Trait {
+ #[allow(async_fn_in_trait)]
+ async fn foo();
+
+ #[allow(async_fn_in_trait)]
+ async fn bar() -> i32;
+
+ fn test(&self) -> impl Sized + '_;
+
+ #[allow(async_fn_in_trait)]
+ 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..cf68ed870
--- /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:19:1
+ |
+LL | async fn foo();
+ | --------------- `foo` from trait
+...
+LL | async fn bar() -> i32;
+ | ---------------------- `bar` from trait
+LL |
+LL | fn test(&self) -> impl Sized + '_;
+ | ---------------------------------- `test` from trait
+...
+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 1 previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr
deleted file mode 100644
index 64c942705..000000000
--- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter
- --> $DIR/trait-more-generics-than-impl.rs:14:11
- |
-LL | fn bar<T>() -> impl Sized;
- | - expected 1 type parameter
-...
-LL | fn bar() -> impl Sized {}
- | ^ found 0 type parameters
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0049`.
diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs
index c2e394a1f..d9fac0238 100644
--- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs
+++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs
@@ -1,9 +1,3 @@
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-
-#![feature(return_position_impl_trait_in_trait)]
-#![allow(incomplete_features)]
-
struct S;
trait Foo {
diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr
index 64c942705..eed4c0771 100644
--- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr
+++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr
@@ -1,5 +1,5 @@
error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter
- --> $DIR/trait-more-generics-than-impl.rs:14:11
+ --> $DIR/trait-more-generics-than-impl.rs:8:11
|
LL | fn bar<T>() -> impl Sized;
| - expected 1 type parameter
@@ -7,6 +7,6 @@ LL | fn bar<T>() -> impl Sized;
LL | fn bar() -> impl Sized {}
| ^ found 0 type parameters
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0049`.
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..ff3753de5
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs
@@ -0,0 +1,13 @@
+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/unconstrained-lt.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr
new file mode 100644
index 000000000..4c5a42c0b
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/unconstrained-lt.rs:5:6
+ |
+LL | impl<'a, T> Foo for T {
+ | ^^ unconstrained lifetime parameter
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/impl-trait/in-trait/variance.rs b/tests/ui/impl-trait/in-trait/variance.rs
new file mode 100644
index 000000000..65565dcc2
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/variance.rs
@@ -0,0 +1,20 @@
+#![feature(rustc_attrs)]
+#![allow(internal_features)]
+#![rustc_variance_of_opaques]
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+trait Foo<'i> {
+ fn implicit_capture_early<'a: 'a>() -> impl Sized {}
+ //~^ [o, *, *, o, o]
+ // Self, 'i, 'a, 'i_duplicated, 'a_duplicated
+
+ fn explicit_capture_early<'a: 'a>() -> impl Sized + Captures<'a> {} //~ [o, *, *, o, o]
+
+ fn implicit_capture_late<'a>(_: &'a ()) -> impl Sized {} //~ [o, *, o, o]
+
+ fn explicit_capture_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} //~ [o, *, o, o]
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/variance.stderr b/tests/ui/impl-trait/in-trait/variance.stderr
new file mode 100644
index 000000000..8cae5a92f
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/variance.stderr
@@ -0,0 +1,26 @@
+error: [o, *, *, o, o]
+ --> $DIR/variance.rs:9:44
+ |
+LL | fn implicit_capture_early<'a: 'a>() -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [o, *, *, o, o]
+ --> $DIR/variance.rs:13:44
+ |
+LL | fn explicit_capture_early<'a: 'a>() -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o, *, o, o]
+ --> $DIR/variance.rs:15:48
+ |
+LL | fn implicit_capture_late<'a>(_: &'a ()) -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [o, *, o, o]
+ --> $DIR/variance.rs:17:48
+ |
+LL | fn explicit_capture_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+
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..aabb6f830
--- /dev/null
+++ b/tests/ui/impl-trait/in-trait/variances-of-gat.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+
+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
deleted file mode 100644
index 1a7071612..000000000
--- a/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr
+++ /dev/null
@@ -1,40 +0,0 @@
-error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:13:22
- |
-LL | fn nya() -> impl Wf<Vec<[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 `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
- |
-LL | fn nya2() -> impl Wf<[u8]>;
- | ^^^^^^^^ doesn't have a size known at compile-time
- |
- = help: the trait `Sized` is not implemented for `[u8]`
-note: required by a bound in `Wf`
- --> $DIR/wf-bounds.rs:8:10
- |
-LL | trait Wf<T> {
- | ^ required by this bound in `Wf`
-help: consider relaxing the implicit `Sized` restriction
- |
-LL | trait Wf<T: ?Sized> {
- | ++++++++
-
-error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
- --> $DIR/wf-bounds.rs:19:44
- |
-LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[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 `Vec`
- --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs
index 1c9590bd8..f1e372b19 100644
--- a/tests/ui/impl-trait/in-trait/wf-bounds.rs
+++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs
@@ -1,14 +1,15 @@
// issue #101663
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
+use std::fmt::Display;
+
trait Wf<T> {
type Output;
}
+struct NeedsDisplay<T: Display>(T);
+
trait Uwu {
fn nya() -> impl Wf<Vec<[u8]>>;
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
@@ -18,6 +19,9 @@ trait Uwu {
fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
+
+ fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
+ //~^ ERROR `T` doesn't implement `std::fmt::Display`
}
fn main() {}
diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.stderr
index 1a7071612..c20df9b40 100644
--- a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr
+++ b/tests/ui/impl-trait/in-trait/wf-bounds.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:14:22
|
LL | fn nya() -> impl Wf<Vec<[u8]>>;
| ^^^^^^^^^^^^^ 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:17: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:7:10
|
LL | trait Wf<T> {
| ^ required by this bound in `Wf`
@@ -26,7 +26,7 @@ LL | trait Wf<T: ?Sized> {
| ++++++++
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:20:44
|
LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -35,6 +35,19 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
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:23:26
+ |
+LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
+ | ^^^^^^^^^^^^^^^^^^^ `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:11:24
+ |
+LL | struct NeedsDisplay<T: Display>(T);
+ | ^^^^^^^ required by this bound in `NeedsDisplay`
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/in-trait/where-clause.rs b/tests/ui/impl-trait/in-trait/where-clause.rs
index 88d86e2b5..f7f4980b7 100644
--- a/tests/ui/impl-trait/in-trait/where-clause.rs
+++ b/tests/ui/impl-trait/in-trait/where-clause.rs
@@ -1,9 +1,6 @@
// check-pass
// edition: 2021
-// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
-// revisions: current next
-#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
diff --git a/tests/ui/impl-trait/issue-100075-2.stderr b/tests/ui/impl-trait/issue-100075-2.stderr
index d2dbd8c62..b3b696775 100644
--- a/tests/ui/impl-trait/issue-100075-2.stderr
+++ b/tests/ui/impl-trait/issue-100075-2.stderr
@@ -19,6 +19,6 @@ LL | fn opaque<T>(t: T) -> impl Sized {
LL | opaque(Some(t))
| --------------- returning here with type `impl Sized`
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/issue-100075.stderr b/tests/ui/impl-trait/issue-100075.stderr
index 267ecfdae..759634892 100644
--- a/tests/ui/impl-trait/issue-100075.stderr
+++ b/tests/ui/impl-trait/issue-100075.stderr
@@ -7,6 +7,6 @@ LL | fn _g<T>(t: &'static T) -> &'static impl Marker {
LL | return _g(t);
| ----- returning here with type `&impl Marker`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/issue-102605.stderr b/tests/ui/impl-trait/issue-102605.stderr
index dfe18e43e..dcb227971 100644
--- a/tests/ui/impl-trait/issue-102605.stderr
+++ b/tests/ui/impl-trait/issue-102605.stderr
@@ -1,3 +1,11 @@
+error[E0277]: `main` has invalid return type `Option<()>`
+ --> $DIR/issue-102605.rs:11:14
+ |
+LL | fn main() -> Option<()> {
+ | ^^^^^^^^^^ `main` can only return types that implement `Termination`
+ |
+ = help: consider using `()`, or a `Result`
+
error[E0308]: mismatched types
--> $DIR/issue-102605.rs:13:20
|
@@ -25,14 +33,6 @@ help: try wrapping the expression in `Err`
LL | convert_result(Err(foo()))
| ++++ +
-error[E0277]: `main` has invalid return type `Option<()>`
- --> $DIR/issue-102605.rs:11:14
- |
-LL | fn main() -> Option<()> {
- | ^^^^^^^^^^ `main` can only return types that implement `Termination`
- |
- = help: consider using `()`, or a `Result`
-
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0308.
diff --git a/tests/ui/impl-trait/issue-103181-1.current.stderr b/tests/ui/impl-trait/issue-103181-1.current.stderr
index e87a9d28a..83410dfc6 100644
--- a/tests/ui/impl-trait/issue-103181-1.current.stderr
+++ b/tests/ui/impl-trait/issue-103181-1.current.stderr
@@ -7,6 +7,6 @@ LL | }
LL | impl HttpBody for () {
| ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/impl-trait/issue-103181-1.next.stderr b/tests/ui/impl-trait/issue-103181-1.next.stderr
index e87a9d28a..83410dfc6 100644
--- a/tests/ui/impl-trait/issue-103181-1.next.stderr
+++ b/tests/ui/impl-trait/issue-103181-1.next.stderr
@@ -7,6 +7,6 @@ LL | }
LL | impl HttpBody for () {
| ^^^^^^^^^^^^^^^^^^^^ missing `Error` in implementation
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0046`.
diff --git a/tests/ui/impl-trait/issue-103181-1.rs b/tests/ui/impl-trait/issue-103181-1.rs
index 5154abcd6..14c813cf0 100644
--- a/tests/ui/impl-trait/issue-103181-1.rs
+++ b/tests/ui/impl-trait/issue-103181-1.rs
@@ -1,5 +1,5 @@
// revisions: current next
-//[next] compile-flags: -Ztrait-solver=next
+//[next] compile-flags: -Znext-solver
// edition:2021
mod hyper {
diff --git a/tests/ui/impl-trait/issue-103181-2.stderr b/tests/ui/impl-trait/issue-103181-2.stderr
index 5eb2dd918..cef4449db 100644
--- a/tests/ui/impl-trait/issue-103181-2.stderr
+++ b/tests/ui/impl-trait/issue-103181-2.stderr
@@ -4,6 +4,6 @@ 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: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/impl-trait/issue-108591.rs b/tests/ui/impl-trait/issue-108591.rs
index 6b9d14941..91ea2e9fb 100644
--- a/tests/ui/impl-trait/issue-108591.rs
+++ b/tests/ui/impl-trait/issue-108591.rs
@@ -13,7 +13,8 @@ impl MyTy<'_> {
}
}
-type Opaque<'a> = impl Sized;
+type Opaque2 = impl Sized;
+type Opaque<'a> = Opaque2;
fn define<'a>() -> Opaque<'a> {}
fn test<'a>() {
diff --git a/tests/ui/impl-trait/issue-108592.rs b/tests/ui/impl-trait/issue-108592.rs
index 58a0ed9bf..953fffc48 100644
--- a/tests/ui/impl-trait/issue-108592.rs
+++ b/tests/ui/impl-trait/issue-108592.rs
@@ -11,7 +11,8 @@ fn test_closure() {
closure(&opaque());
}
-type Opaque<'a> = impl Sized;
+type Opaque2 = impl Sized;
+type Opaque<'a> = Opaque2;
fn define<'a>() -> Opaque<'a> {}
fn test_tait(_: &Opaque<'_>) {
diff --git a/tests/ui/impl-trait/issue-35668.stderr b/tests/ui/impl-trait/issue-35668.stderr
index 84add5799..ba02d2898 100644
--- a/tests/ui/impl-trait/issue-35668.stderr
+++ b/tests/ui/impl-trait/issue-35668.stderr
@@ -11,6 +11,6 @@ help: consider introducing a `where` clause, but there might be an alternative b
LL | fn func<'a, T>(a: &'a [T]) -> impl Iterator<Item=&'a T> where &T: Mul<&T> {
| +++++++++++++++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0369`.
diff --git a/tests/ui/impl-trait/issue-54966.stderr b/tests/ui/impl-trait/issue-54966.stderr
index aa9a61cb5..4024c5afa 100644
--- a/tests/ui/impl-trait/issue-54966.stderr
+++ b/tests/ui/impl-trait/issue-54966.stderr
@@ -4,6 +4,6 @@ error[E0412]: cannot find type `Oper` in this scope
LL | fn generate_duration() -> Oper<impl FnMut()> {}
| ^^^^ not found in this scope
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr b/tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr
deleted file mode 100644
index 477c964bd..000000000
--- a/tests/ui/impl-trait/issue-55872-2.drop_tracking.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
- --> $DIR/issue-55872-2.rs:17:9
- |
-LL | async {}
- | ^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr b/tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr
deleted file mode 100644
index 477c964bd..000000000
--- a/tests/ui/impl-trait/issue-55872-2.no_drop_tracking.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
- --> $DIR/issue-55872-2.rs:17:9
- |
-LL | async {}
- | ^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/impl-trait/issue-55872-2.rs b/tests/ui/impl-trait/issue-55872-2.rs
index 7a5cb3b3d..8a96fdc5c 100644
--- a/tests/ui/impl-trait/issue-55872-2.rs
+++ b/tests/ui/impl-trait/issue-55872-2.rs
@@ -1,6 +1,3 @@
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
// edition:2018
#![feature(impl_trait_in_assoc_type)]
@@ -16,7 +13,7 @@ impl<S> Bar for S {
fn foo<T>() -> Self::E {
async {}
//~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
- //[drop_tracking_mir]~^^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
+ //~| ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
}
}
diff --git a/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr b/tests/ui/impl-trait/issue-55872-2.stderr
index c14bb5cc9..b5b7f293a 100644
--- a/tests/ui/impl-trait/issue-55872-2.drop_tracking_mir.stderr
+++ b/tests/ui/impl-trait/issue-55872-2.stderr
@@ -1,14 +1,16 @@
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
- --> $DIR/issue-55872-2.rs:17:9
+ --> $DIR/issue-55872-2.rs:14:9
|
LL | async {}
| ^^^^^^^^
error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
- --> $DIR/issue-55872-2.rs:17:9
+ --> $DIR/issue-55872-2.rs:14:9
|
LL | async {}
| ^^^^^^^^
+ |
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
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..9af0fad9c 100644
--- a/tests/ui/impl-trait/issue-55872-3.stderr
+++ b/tests/ui/impl-trait/issue-55872-3.stderr
@@ -1,9 +1,9 @@
-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<T>() -> 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
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/issue-55872.stderr b/tests/ui/impl-trait/issue-55872.stderr
index cb370fbe1..4ff8527bb 100644
--- a/tests/ui/impl-trait/issue-55872.stderr
+++ b/tests/ui/impl-trait/issue-55872.stderr
@@ -4,5 +4,5 @@ error: type parameter `T` is part of concrete type but not used in parameter lis
LL | || ()
| ^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/issue-86465.rs b/tests/ui/impl-trait/issue-86465.rs
index 8c7b41d73..a79bb6474 100644
--- a/tests/ui/impl-trait/issue-86465.rs
+++ b/tests/ui/impl-trait/issue-86465.rs
@@ -1,10 +1,6 @@
#![feature(type_alias_impl_trait)]
-pub trait Captures<'a> {}
-
-impl<'a, T: ?Sized> Captures<'a> for T {}
-
-type X<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
+type X<'a, 'b> = impl std::fmt::Debug;
fn f<'t, 'u>(a: &'t u32, b: &'u u32) -> (X<'t, 'u>, X<'u, 't>) {
(a, a)
diff --git a/tests/ui/impl-trait/issue-86465.stderr b/tests/ui/impl-trait/issue-86465.stderr
index b949b2b42..e330d178d 100644
--- a/tests/ui/impl-trait/issue-86465.stderr
+++ b/tests/ui/impl-trait/issue-86465.stderr
@@ -1,5 +1,5 @@
error: concrete type differs from previous defining opaque type use
- --> $DIR/issue-86465.rs:10:5
+ --> $DIR/issue-86465.rs:6:5
|
LL | (a, a)
| ^^^^^^
@@ -7,5 +7,5 @@ LL | (a, a)
| expected `&'a u32`, got `&'b u32`
| this expression supplies two conflicting concrete types for the same opaque type
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/issue-87450.stderr b/tests/ui/impl-trait/issue-87450.stderr
index 173fca63f..9567e0965 100644
--- a/tests/ui/impl-trait/issue-87450.stderr
+++ b/tests/ui/impl-trait/issue-87450.stderr
@@ -22,6 +22,6 @@ LL | wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo())))))))
LL | fn wrap(f: impl Fn()) -> impl Fn() {
| --------- returning this opaque type `impl Fn()`
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/issue-99073-2.rs b/tests/ui/impl-trait/issue-99073-2.rs
index 14ac68880..37ea211be 100644
--- a/tests/ui/impl-trait/issue-99073-2.rs
+++ b/tests/ui/impl-trait/issue-99073-2.rs
@@ -8,6 +8,7 @@ fn test<T: Display>(t: T, recurse: bool) -> impl Display {
let f = || {
let i: u32 = test::<i32>(-1, false);
//~^ ERROR concrete type differs from previous defining opaque type use
+ //~| ERROR expected generic type parameter, found `i32`
println!("{i}");
};
if recurse {
diff --git a/tests/ui/impl-trait/issue-99073-2.stderr b/tests/ui/impl-trait/issue-99073-2.stderr
index 913bc8f56..06b2b8456 100644
--- a/tests/ui/impl-trait/issue-99073-2.stderr
+++ b/tests/ui/impl-trait/issue-99073-2.stderr
@@ -1,3 +1,12 @@
+error[E0792]: expected generic type parameter, found `i32`
+ --> $DIR/issue-99073-2.rs:9:22
+ |
+LL | fn test<T: Display>(t: T, recurse: bool) -> impl Display {
+ | - this generic parameter must be used with a generic type parameter
+LL | let f = || {
+LL | let i: u32 = test::<i32>(-1, false);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
error: concrete type differs from previous defining opaque type use
--> $DIR/issue-99073-2.rs:9:22
|
@@ -5,10 +14,11 @@ LL | let i: u32 = test::<i32>(-1, false);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `T`, got `u32`
|
note: previous use here
- --> $DIR/issue-99073-2.rs:16:5
+ --> $DIR/issue-99073-2.rs:7:45
|
-LL | t
- | ^
+LL | fn test<T: Display>(t: T, recurse: bool) -> impl Display {
+ | ^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/impl-trait/issue-99073.rs b/tests/ui/impl-trait/issue-99073.rs
index 7798e247d..b4ef3e66f 100644
--- a/tests/ui/impl-trait/issue-99073.rs
+++ b/tests/ui/impl-trait/issue-99073.rs
@@ -5,4 +5,5 @@ fn main() {
fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() {
move || f(fix(&f))
//~^ ERROR concrete type differs from previous defining opaque type use
+ //~| ERROR expected generic type parameter, found `&F`
}
diff --git a/tests/ui/impl-trait/issue-99073.stderr b/tests/ui/impl-trait/issue-99073.stderr
index 546367953..3c32f1794 100644
--- a/tests/ui/impl-trait/issue-99073.stderr
+++ b/tests/ui/impl-trait/issue-99073.stderr
@@ -1,14 +1,23 @@
-error: concrete type differs from previous defining opaque type use
+error[E0792]: expected generic type parameter, found `&F`
--> $DIR/issue-99073.rs:6:11
|
+LL | fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() {
+ | - this generic parameter must be used with a generic type parameter
+LL | move || f(fix(&f))
+ | ^^^^^^^^^^
+
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/issue-99073.rs:6:13
+ |
LL | move || f(fix(&f))
- | ^^^^^^^^^^ expected `[closure@$DIR/issue-99073.rs:6:3: 6:10]`, got `G`
+ | ^^^^^^^ expected `{closure@$DIR/issue-99073.rs:6:3: 6:10}`, got `G`
|
note: previous use here
- --> $DIR/issue-99073.rs:6:3
+ --> $DIR/issue-99073.rs:5:36
|
-LL | move || f(fix(&f))
- | ^^^^^^^^^^^^^^^^^^
+LL | fn fix<F: Fn(G), G: Fn()>(f: F) -> impl Fn() {
+ | ^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/impl-trait/issue-99914.stderr b/tests/ui/impl-trait/issue-99914.stderr
index c86e9eadc..06e85e521 100644
--- a/tests/ui/impl-trait/issue-99914.stderr
+++ b/tests/ui/impl-trait/issue-99914.stderr
@@ -9,6 +9,6 @@ help: try wrapping the expression in `Ok`
LL | t.and_then(|t| -> _ { Ok(bar(t)) });
| +++ +
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr b/tests/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr
index 9150d957d..e5d718393 100644
--- a/tests/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr
+++ b/tests/ui/impl-trait/issues/issue-21659-show-relevant-trait-impls-3.stderr
@@ -14,6 +14,6 @@ note: `Foo` defines an item `foo`, perhaps you need to implement it
LL | trait Foo<A> {
| ^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/impl-trait/issues/issue-54600.rs b/tests/ui/impl-trait/issues/issue-54600.rs
index 3024fedf7..ccf276701 100644
--- a/tests/ui/impl-trait/issues/issue-54600.rs
+++ b/tests/ui/impl-trait/issues/issue-54600.rs
@@ -2,6 +2,6 @@ use std::fmt::Debug;
fn main() {
let x: Option<impl Debug> = Some(44_u32);
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
println!("{:?}", x);
}
diff --git a/tests/ui/impl-trait/issues/issue-54600.stderr b/tests/ui/impl-trait/issues/issue-54600.stderr
index 7ef063af9..946ad74b8 100644
--- a/tests/ui/impl-trait/issues/issue-54600.stderr
+++ b/tests/ui/impl-trait/issues/issue-54600.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-54600.rs:4:19
|
LL | let x: Option<impl Debug> = Some(44_u32);
| ^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
diff --git a/tests/ui/impl-trait/issues/issue-54840.rs b/tests/ui/impl-trait/issues/issue-54840.rs
index 8f1e0ece0..910d23f1d 100644
--- a/tests/ui/impl-trait/issues/issue-54840.rs
+++ b/tests/ui/impl-trait/issues/issue-54840.rs
@@ -3,5 +3,5 @@ use std::ops::Add;
fn main() {
let i: i32 = 0;
let j: &impl Add = &i;
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
}
diff --git a/tests/ui/impl-trait/issues/issue-54840.stderr b/tests/ui/impl-trait/issues/issue-54840.stderr
index 1d1316f0e..c4ab79f11 100644
--- a/tests/ui/impl-trait/issues/issue-54840.stderr
+++ b/tests/ui/impl-trait/issues/issue-54840.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-54840.rs:5:13
|
LL | let j: &impl Add = &i;
| ^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
diff --git a/tests/ui/impl-trait/issues/issue-54895.stderr b/tests/ui/impl-trait/issues/issue-54895.stderr
index 7d22f027a..999ffd521 100644
--- a/tests/ui/impl-trait/issues/issue-54895.stderr
+++ b/tests/ui/impl-trait/issues/issue-54895.stderr
@@ -10,5 +10,5 @@ note: lifetime declared here
LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> {
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr b/tests/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr
index 6bebbc01f..83d0d7765 100644
--- a/tests/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr
+++ b/tests/ui/impl-trait/issues/issue-57979-deeply-nested-impl-trait-in-assoc-proj.stderr
@@ -7,6 +7,6 @@ LL | pub fn demo(_: impl Quux<Assoc=Deeper<impl Foo<impl Bar>>>) { }
| | nested `impl Trait` here
| outer `impl Trait`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0666`.
diff --git a/tests/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr b/tests/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr
index e31393181..55f47785f 100644
--- a/tests/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr
+++ b/tests/ui/impl-trait/issues/issue-57979-impl-trait-in-path.stderr
@@ -4,6 +4,6 @@ error[E0667]: `impl Trait` is not allowed in path parameters
LL | pub fn demo(_: impl Quux<(), Assoc=<() as Quux<impl Bar>>::Assoc>) { }
| ^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0667`.
diff --git a/tests/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr b/tests/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr
index 8d3d4b5e2..0e105817b 100644
--- a/tests/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr
+++ b/tests/ui/impl-trait/issues/issue-57979-nested-impl-trait-in-assoc-proj.stderr
@@ -7,6 +7,6 @@ LL | pub fn demo(_: impl Quux<Assoc=impl Foo<impl Bar>>) { }
| | nested `impl Trait` here
| outer `impl Trait`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0666`.
diff --git a/tests/ui/impl-trait/issues/issue-58504.rs b/tests/ui/impl-trait/issues/issue-58504.rs
index e5865d0df..03b51ae92 100644
--- a/tests/ui/impl-trait/issues/issue-58504.rs
+++ b/tests/ui/impl-trait/issues/issue-58504.rs
@@ -1,12 +1,12 @@
-#![feature(generators, generator_trait, never_type)]
+#![feature(coroutines, coroutine_trait, never_type)]
-use std::ops::Generator;
+use std::ops::Coroutine;
-fn mk_gen() -> impl Generator<Return=!, Yield=()> {
+fn mk_gen() -> impl Coroutine<Return=!, Yield=()> {
|| { loop { yield; } }
}
fn main() {
- let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
- //~^ `impl Trait` only allowed in function and inherent method return types
+ let gens: [impl Coroutine<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
}
diff --git a/tests/ui/impl-trait/issues/issue-58504.stderr b/tests/ui/impl-trait/issues/issue-58504.stderr
index 26ec2a4f9..e67e48728 100644
--- a/tests/ui/impl-trait/issues/issue-58504.stderr
+++ b/tests/ui/impl-trait/issues/issue-58504.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-58504.rs:10:16
|
-LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
+LL | let gens: [impl Coroutine<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
diff --git a/tests/ui/impl-trait/issues/issue-58956.rs b/tests/ui/impl-trait/issues/issue-58956.rs
index 68cfcd9ba..5d5566860 100644
--- a/tests/ui/impl-trait/issues/issue-58956.rs
+++ b/tests/ui/impl-trait/issues/issue-58956.rs
@@ -5,9 +5,9 @@ impl Lam for B {}
pub struct Wrap<T>(T);
const _A: impl Lam = {
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
let x: Wrap<impl Lam> = Wrap(B);
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
x.0
};
diff --git a/tests/ui/impl-trait/issues/issue-58956.stderr b/tests/ui/impl-trait/issues/issue-58956.stderr
index 2b4d0abdf..5ee33352a 100644
--- a/tests/ui/impl-trait/issues/issue-58956.stderr
+++ b/tests/ui/impl-trait/issues/issue-58956.stderr
@@ -1,10 +1,10 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types
--> $DIR/issue-58956.rs:7:11
|
LL | const _A: impl Lam = {
| ^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-58956.rs:9:17
|
LL | let x: Wrap<impl Lam> = Wrap(B);
diff --git a/tests/ui/impl-trait/issues/issue-62742.stderr b/tests/ui/impl-trait/issues/issue-62742.stderr
index d872291c8..8d969e8e0 100644
--- a/tests/ui/impl-trait/issues/issue-62742.stderr
+++ b/tests/ui/impl-trait/issues/issue-62742.stderr
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
LL | WrongImpl::foo(0i32);
| ^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
|
- = help: the trait `Raw<[T]>` is implemented for `RawImpl<T>`
+ = help: the trait `Raw<[_]>` is implemented for `RawImpl<_>`
note: required by a bound in `SafeImpl`
--> $DIR/issue-62742.rs:26:35
|
@@ -42,7 +42,8 @@ error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
LL | WrongImpl::<()>::foo(0i32);
| ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
|
- = help: the trait `Raw<[T]>` is implemented for `RawImpl<T>`
+ = help: the trait `Raw<[()]>` is implemented for `RawImpl<()>`
+ = help: for that trait implementation, expected `[()]`, found `()`
note: required by a bound in `SafeImpl`
--> $DIR/issue-62742.rs:26:35
|
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-67830.stderr b/tests/ui/impl-trait/issues/issue-67830.stderr
index d3ea8cb03..17cfa151a 100644
--- a/tests/ui/impl-trait/issues/issue-67830.stderr
+++ b/tests/ui/impl-trait/issues/issue-67830.stderr
@@ -10,5 +10,5 @@ note: lifetime declared here
LL | fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> {
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
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..274139f01 100644
--- a/tests/ui/impl-trait/issues/issue-70877.stderr
+++ b/tests/ui/impl-trait/issues/issue-70877.stderr
@@ -5,15 +5,15 @@ 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
|
LL | type FooRet = impl std::fmt::Debug;
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/issues/issue-70971.rs b/tests/ui/impl-trait/issues/issue-70971.rs
index f8ae18bac..c24259a71 100644
--- a/tests/ui/impl-trait/issues/issue-70971.rs
+++ b/tests/ui/impl-trait/issues/issue-70971.rs
@@ -1,4 +1,4 @@
fn main() {
let x : (impl Copy,) = (true,);
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
}
diff --git a/tests/ui/impl-trait/issues/issue-70971.stderr b/tests/ui/impl-trait/issues/issue-70971.stderr
index d066256bf..fcc67291e 100644
--- a/tests/ui/impl-trait/issues/issue-70971.stderr
+++ b/tests/ui/impl-trait/issues/issue-70971.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-70971.rs:2:14
|
LL | let x : (impl Copy,) = (true,);
| ^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
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..f8e85f7ae 100644
--- a/tests/ui/impl-trait/issues/issue-74282.stderr
+++ b/tests/ui/impl-trait/issues/issue-74282.stderr
@@ -8,12 +8,13 @@ LL | Anonymous(|| {
| _____---------_^
| | |
| | arguments to this struct are incorrect
+LL | |
LL | | 3
LL | | })
| |_____^ expected opaque type, found closure
|
= note: expected opaque type `Closure`
- found closure `[closure@$DIR/issue-74282.rs:8:15: 8:17]`
+ found closure `{closure@$DIR/issue-74282.rs:8:15: 8:17}`
= note: no two closures, even if identical, have the same type
= help: consider boxing your closure and/or using it as a trait object
note: tuple struct defined here
@@ -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<Output = u8>;
+
+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..8817eb7d2
--- /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 <https://github.com/rust-lang/rust/issues/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<Output = u8>;
-
struct Bug {
V1: [(); {
+ type F = impl core::future::Future<Output = u8>;
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..5ad659697 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 <https://github.com/rust-lang/rust/issues/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/issues/issue-79099.rs b/tests/ui/impl-trait/issues/issue-79099.rs
index da53594f3..22c66491c 100644
--- a/tests/ui/impl-trait/issues/issue-79099.rs
+++ b/tests/ui/impl-trait/issues/issue-79099.rs
@@ -1,7 +1,7 @@
struct Bug {
V1: [(); {
let f: impl core::future::Future<Output = u8> = async { 1 };
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
//~| expected identifier
1
}],
diff --git a/tests/ui/impl-trait/issues/issue-79099.stderr b/tests/ui/impl-trait/issues/issue-79099.stderr
index 580250a62..82fc03c61 100644
--- a/tests/ui/impl-trait/issues/issue-79099.stderr
+++ b/tests/ui/impl-trait/issues/issue-79099.stderr
@@ -9,7 +9,7 @@ LL | let f: impl core::future::Future<Output = u8> = async { 1 };
= help: pass `--edition 2021` to `rustc`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-79099.rs:3:16
|
LL | let f: impl core::future::Future<Output = u8> = async { 1 };
diff --git a/tests/ui/impl-trait/issues/issue-82139.stderr b/tests/ui/impl-trait/issues/issue-82139.stderr
index 0adcd4a7a..b87084433 100644
--- a/tests/ui/impl-trait/issues/issue-82139.stderr
+++ b/tests/ui/impl-trait/issues/issue-82139.stderr
@@ -4,6 +4,6 @@ error[E0425]: cannot find value `j` in this scope
LL | Some(42).map(|_| j)
| ^ not found in this scope
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/impl-trait/issues/issue-83919.stderr b/tests/ui/impl-trait/issues/issue-83919.stderr
index d39dcf7fb..200257235 100644
--- a/tests/ui/impl-trait/issues/issue-83919.stderr
+++ b/tests/ui/impl-trait/issues/issue-83919.stderr
@@ -7,6 +7,6 @@ LL | fn get_fut(&self) -> Self::Fut {
= help: the trait `Future` is not implemented for `{integer}`
= note: {integer} must be a future or must implement `IntoFuture` to be awaited
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs
index 344f35952..3224145bf 100644
--- a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs
+++ b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.rs
@@ -1,8 +1,8 @@
struct Foo<T = impl Copy>(T);
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// should not cause ICE
fn x() -> Foo {
diff --git a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr
index 656bd0470..56be4577d 100644
--- a/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr
+++ b/tests/ui/impl-trait/issues/issue-83929-impl-trait-in-generic-default.stderr
@@ -1,10 +1,10 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16
|
LL | struct Foo<T = impl Copy>(T);
| ^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20
|
LL | type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;
diff --git a/tests/ui/impl-trait/issues/issue-84073.stderr b/tests/ui/impl-trait/issues/issue-84073.stderr
index 3c39aa6ce..d03e458ae 100644
--- a/tests/ui/impl-trait/issues/issue-84073.stderr
+++ b/tests/ui/impl-trait/issues/issue-84073.stderr
@@ -2,13 +2,13 @@ error[E0282]: type annotations needed for `RaceBuilder<T, Never<T>>`
--> $DIR/issue-84073.rs:32:16
|
LL | Race::new(|race| race.when());
- | ^^^^
+ | ^^^^ ---- type must be known at this point
|
help: consider giving this closure parameter an explicit type, where the type for type parameter `T` is specified
|
LL | Race::new(|race: RaceBuilder<T, Never<T>>| race.when());
| ++++++++++++++++++++++++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/impl-trait/issues/issue-84919.rs b/tests/ui/impl-trait/issues/issue-84919.rs
index a0b73743a..77d27d7c0 100644
--- a/tests/ui/impl-trait/issues/issue-84919.rs
+++ b/tests/ui/impl-trait/issues/issue-84919.rs
@@ -3,7 +3,7 @@ impl Trait for () {}
fn foo<'a: 'a>() {
let _x: impl Trait = ();
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
}
fn main() {}
diff --git a/tests/ui/impl-trait/issues/issue-84919.stderr b/tests/ui/impl-trait/issues/issue-84919.stderr
index 36010fdef..963865efa 100644
--- a/tests/ui/impl-trait/issues/issue-84919.stderr
+++ b/tests/ui/impl-trait/issues/issue-84919.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-84919.rs:5:13
|
LL | let _x: impl Trait = ();
| ^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
diff --git a/tests/ui/impl-trait/issues/issue-86642.rs b/tests/ui/impl-trait/issues/issue-86642.rs
index e6e957714..49f8944ac 100644
--- a/tests/ui/impl-trait/issues/issue-86642.rs
+++ b/tests/ui/impl-trait/issues/issue-86642.rs
@@ -1,5 +1,5 @@
static x: impl Fn(&str) -> Result<&str, ()> = move |source| {
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
let res = (move |source| Ok(source))(source);
let res = res.or((move |source| Ok(source))(source));
res
diff --git a/tests/ui/impl-trait/issues/issue-86642.stderr b/tests/ui/impl-trait/issues/issue-86642.stderr
index b6f8a54f3..3ad18a132 100644
--- a/tests/ui/impl-trait/issues/issue-86642.stderr
+++ b/tests/ui/impl-trait/issues/issue-86642.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types
--> $DIR/issue-86642.rs:1:11
|
LL | static x: impl Fn(&str) -> Result<&str, ()> = move |source| {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
diff --git a/tests/ui/impl-trait/issues/issue-86800.rs b/tests/ui/impl-trait/issues/issue-86800.rs
index ec4fda322..df70b324c 100644
--- a/tests/ui/impl-trait/issues/issue-86800.rs
+++ b/tests/ui/impl-trait/issues/issue-86800.rs
@@ -5,7 +5,7 @@
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
// failure-status:101
// normalize-stderr-test ".*note: .*\n\n" -> ""
-// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
+// normalize-stderr-test "thread 'rustc' panicked.*:\n.*\n" -> ""
// rustc-env:RUST_BACKTRACE=0
use std::future::Future;
diff --git a/tests/ui/impl-trait/issues/issue-86800.stderr b/tests/ui/impl-trait/issues/issue-86800.stderr
index facab390d..8228f8ace 100644
--- a/tests/ui/impl-trait/issues/issue-86800.stderr
+++ b/tests/ui/impl-trait/issues/issue-86800.stderr
@@ -7,6 +7,6 @@ LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResu
error: the compiler unexpectedly panicked. this is a bug.
query stack during panic:
-#0 [type_of] computing type of `TransactionFuture::{opaque#0}`
-#1 [check_mod_item_types] checking item types in top-level module
+#0 [type_of_opaque] computing type of opaque `TransactionFuture::{opaque#0}`
+#1 [type_of] computing type of `TransactionFuture::{opaque#0}`
end of query stack
diff --git a/tests/ui/impl-trait/issues/issue-87295.rs b/tests/ui/impl-trait/issues/issue-87295.rs
index aeb8f8332..eb44020ac 100644
--- a/tests/ui/impl-trait/issues/issue-87295.rs
+++ b/tests/ui/impl-trait/issues/issue-87295.rs
@@ -14,5 +14,5 @@ impl<F> Struct<F> {
fn main() {
let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());
- //~^ `impl Trait` only allowed in function and inherent method return types
+ //~^ `impl Trait` only allowed in function and inherent method argument and return types
}
diff --git a/tests/ui/impl-trait/issues/issue-87295.stderr b/tests/ui/impl-trait/issues/issue-87295.stderr
index ec59b719c..e9a635f24 100644
--- a/tests/ui/impl-trait/issues/issue-87295.stderr
+++ b/tests/ui/impl-trait/issues/issue-87295.stderr
@@ -1,9 +1,9 @@
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
--> $DIR/issue-87295.rs:16:31
|
LL | let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());
| ^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0562`.
diff --git a/tests/ui/impl-trait/issues/issue-87340.stderr b/tests/ui/impl-trait/issues/issue-87340.stderr
index 2ab1e6a03..8513cb288 100644
--- a/tests/ui/impl-trait/issues/issue-87340.stderr
+++ b/tests/ui/impl-trait/issues/issue-87340.stderr
@@ -4,6 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
LL | impl<T> X for () {
| ^ unconstrained type parameter
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/impl-trait/issues/issue-88236.stderr b/tests/ui/impl-trait/issues/issue-88236.stderr
index 7a4cc57b0..6cf1a42d6 100644
--- a/tests/ui/impl-trait/issues/issue-88236.stderr
+++ b/tests/ui/impl-trait/issues/issue-88236.stderr
@@ -10,5 +10,5 @@ note: lifetime declared here
LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {}
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/issues/issue-92305.stderr b/tests/ui/impl-trait/issues/issue-92305.stderr
index 86d7184da..88fb1fb27 100644
--- a/tests/ui/impl-trait/issues/issue-92305.stderr
+++ b/tests/ui/impl-trait/issues/issue-92305.stderr
@@ -9,6 +9,6 @@ help: add missing generic argument
LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> {
| +++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr b/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr
index f0dceb1b1..a83e0df91 100644
--- a/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr
+++ b/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr
@@ -20,6 +20,6 @@ note: required by a bound in `Foo::Item`
LL | type Item: Bar<Other = Self>;
| ^^^^^^^^^^^^ required by this bound in `Foo::Item`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/impl-trait/lifetime-ambiguity-regression.rs b/tests/ui/impl-trait/lifetime-ambiguity-regression.rs
new file mode 100644
index 000000000..ce6ae3786
--- /dev/null
+++ b/tests/ui/impl-trait/lifetime-ambiguity-regression.rs
@@ -0,0 +1,13 @@
+//! This test shows a situation where through subtle compiler changes we can
+//! suddenly infer a different lifetime in the hidden type, and thus not meet
+//! the opaque type bounds anymore. In this case `'a` and `'b` are equal, so
+//! picking either is fine, but then we'll fail an identity check of the hidden
+//! type and the expected hidden type.
+
+// check-pass
+
+fn test<'a: 'b, 'b: 'a>() -> impl IntoIterator<Item = (&'a u8, impl Into<(&'b u8, &'a u8)>)> {
+ None::<(_, (_, _))>
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/lifetimes.rs b/tests/ui/impl-trait/lifetimes.rs
index 9a9843375..f853117a9 100644
--- a/tests/ui/impl-trait/lifetimes.rs
+++ b/tests/ui/impl-trait/lifetimes.rs
@@ -1,7 +1,7 @@
// run-pass
#![allow(warnings)]
-#![feature(generators)]
+#![feature(coroutines)]
use std::fmt::Debug;
@@ -114,7 +114,7 @@ impl<'unnecessary_lifetime> MyVec {
self.0.iter().flat_map(|inner_vec| inner_vec.iter())
}
- fn generator_doesnt_capture_unnecessary_lifetime<'s: 's>() -> impl Sized {
+ fn coroutine_doesnt_capture_unnecessary_lifetime<'s: 's>() -> impl Sized {
|| yield
}
}
diff --git a/tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs b/tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs
new file mode 100644
index 000000000..a2dd0a930
--- /dev/null
+++ b/tests/ui/impl-trait/mapping-duplicated-lifetimes-issue-114597.rs
@@ -0,0 +1,15 @@
+// check-pass
+// issue: 114597
+// edition: 2021
+
+struct A<'a> {
+ dat: &'a (),
+}
+
+impl<'a> A<'a> {
+ async fn a(&self) -> impl Iterator<Item = std::iter::Repeat<()>> {
+ std::iter::repeat(()).map(|()| std::iter::repeat(()))
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/method-suggestion-no-duplication.stderr b/tests/ui/impl-trait/method-suggestion-no-duplication.stderr
index b727b2ca0..c401269da 100644
--- a/tests/ui/impl-trait/method-suggestion-no-duplication.stderr
+++ b/tests/ui/impl-trait/method-suggestion-no-duplication.stderr
@@ -11,6 +11,6 @@ LL | foo(|s| s.is_empty());
= note: the following trait defines an item `is_empty`, perhaps you need to implement it:
candidate #1: `ExactSizeIterator`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0599`.
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<T: Trait, U: Trait>() -> impl Trait {
//~^ WARN function cannot return without recursing [unconditional_recursion]
let a: T = foo::<T, U>();
- //~^ ERROR concrete type differs from previous defining opaque type use
loop {}
let _: T = foo::<U, T>();
+ //~^ 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..faa5d3ba4 100644
--- a/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr
+++ b/tests/ui/impl-trait/multiple-defining-usages-in-body.stderr
@@ -11,16 +11,16 @@ LL | let a: T = foo::<T, U>();
= 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::<T, U>();
- | ^^^^^^^^^^^^^ expected `U`, got `T`
+LL | let _: T = foo::<U, T>();
+ | ^^^^^^^^^^^^^ 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::<U, T>();
+LL | let a: T = foo::<T, U>();
| ^^^^^^^^^^^^^
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
diff --git a/tests/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr b/tests/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr
index 5b0b1cc5e..b968592be 100644
--- a/tests/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr
+++ b/tests/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr
@@ -10,6 +10,6 @@ LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
LL | u.0
| ^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr b/tests/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr
index ccd004003..c511081a8 100644
--- a/tests/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr
+++ b/tests/ui/impl-trait/multiple-lifetimes/error-handling.polonius.stderr
@@ -11,5 +11,5 @@ LL | let _: &'b i32 = *u.0;
|
= help: consider adding the following bound: `'a: 'b`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/multiple-lifetimes/error-handling.stderr b/tests/ui/impl-trait/multiple-lifetimes/error-handling.stderr
index 01d9f506a..00709ee74 100644
--- a/tests/ui/impl-trait/multiple-lifetimes/error-handling.stderr
+++ b/tests/ui/impl-trait/multiple-lifetimes/error-handling.stderr
@@ -11,5 +11,5 @@ LL | let _: &'b i32 = *u.0;
|
= help: consider adding the following bound: `'a: 'b`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr b/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
index 68ac22a05..4d4ba58c9 100644
--- a/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
+++ b/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr
@@ -14,6 +14,6 @@ help: to declare that `impl Trait<'d, 'e>` captures `'b`, you can add an explici
LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> + 'b
| ++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr b/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
index 493a9e66e..060eaa7e6 100644
--- a/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
+++ b/tests/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr
@@ -14,6 +14,6 @@ help: to declare that `impl Trait<'a, 'b>` captures `'b`, you can add an explici
LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> + 'b
| ++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr
index 55e3cd950..c60fe08c5 100644
--- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr
+++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr
@@ -104,7 +104,7 @@ error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not
LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) {
| -- ---------------- opaque type defined here
| |
- | hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:13]` captures the lifetime `'b` as defined here
+ | hidden type `{closure@$DIR/must_outlive_least_region_or_bound.rs:38:5: 38:13}` captures the lifetime `'b` as defined here
LL | move |_| println!("{}", y)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@@ -117,9 +117,12 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:43:5
|
LL | x
- | ^ ...so that the type `T` will meet its required lifetime bounds
+ | ^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the type `T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn ty_param_wont_outlive_static<T:Debug + 'static>(x: T) -> impl Debug + 'static {
| +++++++++
diff --git a/tests/ui/impl-trait/negative-reasoning.stderr b/tests/ui/impl-trait/negative-reasoning.stderr
index 6b8cc9e73..3cb4be16f 100644
--- a/tests/ui/impl-trait/negative-reasoning.stderr
+++ b/tests/ui/impl-trait/negative-reasoning.stderr
@@ -7,8 +7,8 @@ LL | impl<T: std::fmt::Debug> AnotherTrait for T {}
LL | impl AnotherTrait for D<OpaqueType> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
- = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
+ = note: upstream crates may add a new impl of trait `std::marker::FnPtr` for type `OpaqueType` in future versions
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0119`.
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<Assoc = Sendable> {
| ^^^^^^^^^^^^^^^^
|
= 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-type2-tait2.rs b/tests/ui/impl-trait/nested-return-type2-tait2.rs
index af8e06630..b7fee1d91 100644
--- a/tests/ui/impl-trait/nested-return-type2-tait2.rs
+++ b/tests/ui/impl-trait/nested-return-type2-tait2.rs
@@ -1,3 +1,5 @@
+// check-pass
+
#![feature(type_alias_impl_trait)]
trait Duh {}
@@ -17,6 +19,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F {
type Sendable = impl Send;
type Traitable = impl Trait<Assoc = Sendable>;
+//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds
// The `impl Send` here is then later compared against the inference var
// created, causing the inference var to be set to `impl Send` instead of
@@ -25,7 +28,6 @@ type Traitable = impl Trait<Assoc = Sendable>;
// type does not implement `Duh`, even if its hidden type does. So we error out.
fn foo() -> Traitable {
|| 42
- //~^ ERROR `Sendable: Duh` is not satisfied
}
fn main() {
diff --git a/tests/ui/impl-trait/nested-return-type2-tait2.stderr b/tests/ui/impl-trait/nested-return-type2-tait2.stderr
index b85bb5efd..790e339c8 100644
--- a/tests/ui/impl-trait/nested-return-type2-tait2.stderr
+++ b/tests/ui/impl-trait/nested-return-type2-tait2.stderr
@@ -1,18 +1,13 @@
-error[E0277]: the trait bound `Sendable: Duh` is not satisfied
- --> $DIR/nested-return-type2-tait2.rs:27:5
+warning: opaque type `Traitable` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type2-tait2.rs:21:29
|
-LL | || 42
- | ^^^^^ the trait `Duh` is not implemented for `Sendable`
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `Sendable`
+...
+LL | type Traitable = impl Trait<Assoc = Sendable>;
+ | ^^^^^^^^^^^^^^^^
|
- = help: the trait `Duh` is implemented for `i32`
-note: required for `[closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:7]` to implement `Trait`
- --> $DIR/nested-return-type2-tait2.rs:14:31
- |
-LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
- | --- ^^^^^ ^
- | |
- | unsatisfied trait bound introduced here
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
-error: aborting due to previous error
+warning: 1 warning emitted
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/nested-return-type2-tait3.rs b/tests/ui/impl-trait/nested-return-type2-tait3.rs
index 74fd8a9dd..eed5c271f 100644
--- a/tests/ui/impl-trait/nested-return-type2-tait3.rs
+++ b/tests/ui/impl-trait/nested-return-type2-tait3.rs
@@ -1,3 +1,5 @@
+// check-pass
+
#![feature(type_alias_impl_trait)]
trait Duh {}
@@ -16,6 +18,7 @@ impl<R: Duh, F: FnMut() -> R> Trait for F {
}
type Traitable = impl Trait<Assoc = impl Send>;
+//~^ WARN opaque type `Traitable` does not satisfy its associated type bounds
// The `impl Send` here is then later compared against the inference var
// created, causing the inference var to be set to `impl Send` instead of
@@ -24,7 +27,6 @@ type Traitable = impl Trait<Assoc = impl Send>;
// type does not implement `Duh`, even if its hidden type does. So we error out.
fn foo() -> Traitable {
|| 42
- //~^ ERROR `impl Send: Duh` is not satisfied
}
fn main() {
diff --git a/tests/ui/impl-trait/nested-return-type2-tait3.stderr b/tests/ui/impl-trait/nested-return-type2-tait3.stderr
index 19fd3c134..72aa51a23 100644
--- a/tests/ui/impl-trait/nested-return-type2-tait3.stderr
+++ b/tests/ui/impl-trait/nested-return-type2-tait3.stderr
@@ -1,18 +1,17 @@
-error[E0277]: the trait bound `impl Send: Duh` is not satisfied
- --> $DIR/nested-return-type2-tait3.rs:26:5
+warning: opaque type `Traitable` does not satisfy its associated type bounds
+ --> $DIR/nested-return-type2-tait3.rs:20:29
|
-LL | || 42
- | ^^^^^ the trait `Duh` is not implemented for `impl Send`
+LL | type Assoc: Duh;
+ | --- this associated type bound is unsatisfied for `impl Send`
+...
+LL | type Traitable = impl Trait<Assoc = impl Send>;
+ | ^^^^^^^^^^^^^^^^^
|
- = help: the trait `Duh` is implemented for `i32`
-note: required for `[closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:7]` to implement `Trait`
- --> $DIR/nested-return-type2-tait3.rs:14:31
+ = note: `#[warn(opaque_hidden_inferred_bound)]` on by default
+help: add this bound
|
-LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
- | --- ^^^^^ ^
- | |
- | unsatisfied trait bound introduced here
+LL | type Traitable = impl Trait<Assoc = impl Send + Duh>;
+ | +++++
-error: aborting due to previous error
+warning: 1 warning emitted
-For more information about this error, try `rustc --explain E0277`.
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<Assoc = Sendable> {
| ^^^^^^^^^^^^^^^^
|
= 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<Assoc = Sendable>;
| ^^^^^^^^^^^^^^^^
|
= 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-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr
index 907822ebb..14d51a1b0 100644
--- a/tests/ui/impl-trait/nested-return-type4.stderr
+++ b/tests/ui/impl-trait/nested-return-type4.stderr
@@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Future<Output = impl Sized>` captures lifeti
LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized> {
| -- --------------------------------------------- opaque type defined here
| |
- | hidden type `[async block@$DIR/nested-return-type4.rs:4:5: 4:31]` captures the lifetime `'s` as defined here
+ | hidden type `{async block@$DIR/nested-return-type4.rs:4:5: 4:31}` captures the lifetime `'s` as defined here
LL | async move { let _s = s; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@@ -17,6 +17,6 @@ help: to declare that `impl Sized` captures `'s`, you can add an explicit `'s` l
LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future<Output = impl Sized + 's> {
| ++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/nested-rpit-hrtb-2.rs b/tests/ui/impl-trait/nested-rpit-hrtb-2.rs
new file mode 100644
index 000000000..4d7296215
--- /dev/null
+++ b/tests/ui/impl-trait/nested-rpit-hrtb-2.rs
@@ -0,0 +1,9 @@
+// The nested impl Trait references a higher-ranked region
+
+trait Trait<'a> { type Assoc; }
+impl<'a> Trait<'a> for () { type Assoc = &'a str; }
+
+fn test() -> impl for<'a> Trait<'a, Assoc = impl Sized> {}
+//~^ ERROR captures lifetime that does not appear in bounds
+
+fn main() {}
diff --git a/tests/ui/impl-trait/nested-rpit-hrtb-2.stderr b/tests/ui/impl-trait/nested-rpit-hrtb-2.stderr
new file mode 100644
index 000000000..0fcacc19c
--- /dev/null
+++ b/tests/ui/impl-trait/nested-rpit-hrtb-2.stderr
@@ -0,0 +1,12 @@
+error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds
+ --> $DIR/nested-rpit-hrtb-2.rs:6:57
+ |
+LL | fn test() -> impl for<'a> Trait<'a, Assoc = impl Sized> {}
+ | -- ---------- ^^
+ | | |
+ | | opaque type defined here
+ | hidden type `&'a str` captures the lifetime `'a` as defined here
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0700`.
diff --git a/tests/ui/impl-trait/nested_impl_trait.rs b/tests/ui/impl-trait/nested_impl_trait.rs
index e95fab3b6..c036b9e36 100644
--- a/tests/ui/impl-trait/nested_impl_trait.rs
+++ b/tests/ui/impl-trait/nested_impl_trait.rs
@@ -9,7 +9,7 @@ fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
//~^ ERROR nested `impl Trait` is not allowed
-//~| `impl Trait` only allowed in function and inherent method return types
+//~| `impl Trait` only allowed in function and inherent method argument and return types
fn bad_in_arg_position(_: impl Into<impl Debug>) { }
//~^ ERROR nested `impl Trait` is not allowed
diff --git a/tests/ui/impl-trait/nested_impl_trait.stderr b/tests/ui/impl-trait/nested_impl_trait.stderr
index ffe84b8e8..f1cafd958 100644
--- a/tests/ui/impl-trait/nested_impl_trait.stderr
+++ b/tests/ui/impl-trait/nested_impl_trait.stderr
@@ -34,7 +34,7 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
| | nested `impl Trait` here
| outer `impl Trait`
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types
--> $DIR/nested_impl_trait.rs:10:32
|
LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
diff --git a/tests/ui/impl-trait/no-trait.stderr b/tests/ui/impl-trait/no-trait.stderr
index 3a636f252..a58fa5cd7 100644
--- a/tests/ui/impl-trait/no-trait.stderr
+++ b/tests/ui/impl-trait/no-trait.stderr
@@ -4,5 +4,5 @@ error: at least one trait must be specified
LL | fn f() -> impl 'static {}
| ^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
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<T>() -> impl Sized {}
+
+trait Trait<'a> {
+ type Assoc;
+
+ fn call() {
+ let _ = async {
+ let _value = func::<Self::Assoc>();
+ std::future::ready(()).await
+ };
+ }
+}
+
+impl Trait<'static> for () {
+ type Assoc = ();
+}
+
+fn main() {
+ <()>::call();
+}
diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs
index d2e34c00b..dd03fd3f7 100644
--- a/tests/ui/impl-trait/normalize-tait-in-const.rs
+++ b/tests/ui/impl-trait/normalize-tait-in-const.rs
@@ -1,9 +1,4 @@
// known-bug: #103507
-// failure-status: 101
-// normalize-stderr-test "note: .*\n\n" -> ""
-// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
-// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
-// rustc-env:RUST_BACKTRACE=0
#![feature(type_alias_impl_trait)]
#![feature(const_trait_impl)]
diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr
index 84b009187..e0513433b 100644
--- a/tests/ui/impl-trait/normalize-tait-in-const.stderr
+++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr
@@ -1,8 +1,8 @@
-error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:LL:CC: Failed to normalize <for<'a, 'b> fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead
+error: ~const can only be applied to `#[const_trait]` traits
+ --> $DIR/normalize-tait-in-const.rs:25:42
+ |
+LL | const fn with_positive<F: ~const for<'a> Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) {
+ | ^^^^^^^^^^^^^^^^^
-query stack during panic:
-#0 [eval_to_allocation_raw] const-evaluating + checking `BAR`
-#1 [eval_to_const_value_raw] simplifying constant for the type system `BAR`
-end of query stack
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
index 687dbe65e..37c96d9bc 100644
--- a/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
+++ b/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr
@@ -11,6 +11,9 @@ LL | trait NotObjectSafe {
| ------------- this trait cannot be made into an object...
LL | fn foo() -> Self;
| ^^^ ...because associated function `foo` has no `self` parameter
+ = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `NotObjectSafe` for this new enum and using it instead:
+ A
+ B
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) -> Self;
@@ -33,6 +36,9 @@ LL | trait NotObjectSafe {
| ------------- this trait cannot be made into an object...
LL | fn foo() -> Self;
| ^^^ ...because associated function `foo` has no `self` parameter
+ = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `NotObjectSafe` for this new enum and using it instead:
+ A
+ B
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) -> Self;
diff --git a/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs b/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs
new file mode 100644
index 000000000..3e3bc09a6
--- /dev/null
+++ b/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs
@@ -0,0 +1,27 @@
+// edition: 2021
+
+use std::future::Future;
+
+async fn bop() {
+ fold(run(), |mut foo| async move {
+ &mut foo.bar;
+ })
+}
+
+fn fold<Fut, F, U>(_: Foo<U>, f: F)
+where
+ F: FnMut(Foo<U>) -> Fut,
+{
+ loop {}
+}
+
+struct Foo<F> {
+ bar: Vec<F>,
+}
+
+fn run() -> Foo<impl Future<Output = ()>> {
+ //~^ ERROR type annotations needed
+ loop {}
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr b/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr
new file mode 100644
index 000000000..5ade6a69d
--- /dev/null
+++ b/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr
@@ -0,0 +1,11 @@
+error[E0283]: type annotations needed
+ --> $DIR/opaque-cast-field-access-in-future.rs:22:17
+ |
+LL | fn run() -> Foo<impl Future<Output = ()>> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
+ |
+ = note: cannot satisfy `_: Future`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
index a4ff51047..c4ea44740 100644
--- a/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
+++ b/tests/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr
@@ -15,6 +15,6 @@ note: required for `()` to implement `Test`
LL | impl<T> Test for T where T: Super<Assoc = ()> {}
| ^^^^ ^ ---------- unsatisfied trait bound introduced here
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0271`.
diff --git a/tests/ui/impl-trait/recursive-auto-trait.rs b/tests/ui/impl-trait/recursive-auto-trait.rs
new file mode 100644
index 000000000..d7b68144f
--- /dev/null
+++ b/tests/ui/impl-trait/recursive-auto-trait.rs
@@ -0,0 +1,10 @@
+// check-pass
+fn is_send<T: Send>(_: T) {}
+fn foo() -> impl Send {
+ if false {
+ is_send(foo());
+ }
+ ()
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/recursive-coroutine.current.stderr b/tests/ui/impl-trait/recursive-coroutine.current.stderr
new file mode 100644
index 000000000..e838634ed
--- /dev/null
+++ b/tests/ui/impl-trait/recursive-coroutine.current.stderr
@@ -0,0 +1,12 @@
+error[E0720]: cannot resolve opaque type
+ --> $DIR/recursive-coroutine.rs:7:13
+ |
+LL | fn foo() -> impl Coroutine<Yield = (), Return = ()> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type
+...
+LL | let mut gen = Box::pin(foo());
+ | ------- coroutine captures itself here
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/recursive-coroutine.next.stderr b/tests/ui/impl-trait/recursive-coroutine.next.stderr
new file mode 100644
index 000000000..e838634ed
--- /dev/null
+++ b/tests/ui/impl-trait/recursive-coroutine.next.stderr
@@ -0,0 +1,12 @@
+error[E0720]: cannot resolve opaque type
+ --> $DIR/recursive-coroutine.rs:7:13
+ |
+LL | fn foo() -> impl Coroutine<Yield = (), Return = ()> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type
+...
+LL | let mut gen = Box::pin(foo());
+ | ------- coroutine captures itself here
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/recursive-generator.rs b/tests/ui/impl-trait/recursive-coroutine.rs
index e876f0fb4..b82fe134a 100644
--- a/tests/ui/impl-trait/recursive-generator.rs
+++ b/tests/ui/impl-trait/recursive-coroutine.rs
@@ -1,17 +1,18 @@
-#![feature(generators, generator_trait)]
+// revisions: current next
+//[next] compile-flags: -Znext-solver
+#![feature(coroutines, coroutine_trait)]
-use std::ops::{Generator, GeneratorState};
+use std::ops::{Coroutine, CoroutineState};
-fn foo() -> impl Generator<Yield = (), Return = ()> {
+fn foo() -> impl Coroutine<Yield = (), Return = ()> {
//~^ ERROR cannot resolve opaque type
//~| NOTE recursive opaque type
//~| NOTE in this expansion of desugaring of
|| {
- //~^ NOTE returning here
let mut gen = Box::pin(foo());
- //~^ NOTE generator captures itself here
+ //~^ NOTE coroutine captures itself here
let mut r = gen.as_mut().resume(());
- while let GeneratorState::Yielded(v) = r {
+ while let CoroutineState::Yielded(v) = r {
yield v;
r = gen.as_mut().resume(());
}
diff --git a/tests/ui/impl-trait/recursive-generator.stderr b/tests/ui/impl-trait/recursive-generator.stderr
deleted file mode 100644
index e23fd4b4a..000000000
--- a/tests/ui/impl-trait/recursive-generator.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-generator.rs:5:13
- |
-LL | fn foo() -> impl Generator<Yield = (), Return = ()> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type
-...
-LL | / || {
-LL | |
-LL | | let mut gen = Box::pin(foo());
- | | ------- generator captures itself here
-LL | |
-... |
-LL | | }
-LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-generator.rs:9:5: 9:7]`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr
deleted file mode 100644
index 43118ae38..000000000
--- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking.stderr
+++ /dev/null
@@ -1,152 +0,0 @@
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:11:22
- |
-LL | fn option(i: i32) -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | if i < 0 { None } else { Some((option(i - 1), i)) }
- | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>`
- | |
- | returning here with type `Option<(impl Sized, i32)>`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:16:15
- |
-LL | fn tuple() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | (tuple(),)
- | ---------- returning here with type `(impl Sized,)`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:21:15
- |
-LL | fn array() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | [array()]
- | --------- returning here with type `[impl Sized; 1]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:26:13
- |
-LL | fn ptr() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | &ptr() as *const _
- | ------------------ returning here with type `*const impl Sized`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:31:16
- |
-LL | fn fn_ptr() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | fn_ptr as fn() -> _
- | ------------------- returning here with type `fn() -> impl Sized`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:36:25
- |
-LL | fn closure_capture() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-...
-LL | / move || {
-LL | | x;
- | | - closure captures itself here
-LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:44:29
- |
-LL | fn closure_ref_capture() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-...
-LL | / move || {
-LL | | &x;
- | | - closure captures itself here
-LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:52:21
- |
-LL | fn closure_sig() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | || closure_sig()
- | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:57:23
- |
-LL | fn generator_sig() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | || generator_sig()
- | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:62:27
- |
-LL | fn generator_capture() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-...
-LL | / move || {
-LL | | yield;
-LL | | x;
- | | - generator captures itself here
-LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:71:35
- |
-LL | fn substs_change<T: 'static>() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | (substs_change::<&T>(),)
- | ------------------------ returning here with type `(impl Sized,)`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:76:24
- |
-LL | fn generator_hold() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | / move || {
-LL | | let x = generator_hold();
- | | - generator captures itself here
-LL | | yield;
-LL | | x;
-LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:90:26
- |
-LL | fn mutual_recursion() -> impl Sync {
- | ^^^^^^^^^ recursive opaque type
-LL |
-LL | mutual_recursion_b()
- | -------------------- returning here with type `impl Sized`
-...
-LL | fn mutual_recursion_b() -> impl Sized {
- | ---------- returning this opaque type `impl Sized`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:95:28
- |
-LL | fn mutual_recursion() -> impl Sync {
- | --------- returning this opaque type `impl Sync`
-...
-LL | fn mutual_recursion_b() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | mutual_recursion()
- | ------------------ returning here with type `impl Sync`
-
-error: aborting due to 14 previous errors
-
-For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr
deleted file mode 100644
index 43118ae38..000000000
--- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.no_drop_tracking.stderr
+++ /dev/null
@@ -1,152 +0,0 @@
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:11:22
- |
-LL | fn option(i: i32) -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | if i < 0 { None } else { Some((option(i - 1), i)) }
- | ---- ------------------------ returning here with type `Option<(impl Sized, i32)>`
- | |
- | returning here with type `Option<(impl Sized, i32)>`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:16:15
- |
-LL | fn tuple() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | (tuple(),)
- | ---------- returning here with type `(impl Sized,)`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:21:15
- |
-LL | fn array() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | [array()]
- | --------- returning here with type `[impl Sized; 1]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:26:13
- |
-LL | fn ptr() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | &ptr() as *const _
- | ------------------ returning here with type `*const impl Sized`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:31:16
- |
-LL | fn fn_ptr() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | fn_ptr as fn() -> _
- | ------------------- returning here with type `fn() -> impl Sized`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:36:25
- |
-LL | fn closure_capture() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-...
-LL | / move || {
-LL | | x;
- | | - closure captures itself here
-LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:44:29
- |
-LL | fn closure_ref_capture() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-...
-LL | / move || {
-LL | | &x;
- | | - closure captures itself here
-LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:52:21
- |
-LL | fn closure_sig() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | || closure_sig()
- | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:57:23
- |
-LL | fn generator_sig() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | || generator_sig()
- | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:62:27
- |
-LL | fn generator_capture() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-...
-LL | / move || {
-LL | | yield;
-LL | | x;
- | | - generator captures itself here
-LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:71:35
- |
-LL | fn substs_change<T: 'static>() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | (substs_change::<&T>(),)
- | ------------------------ returning here with type `(impl Sized,)`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:76:24
- |
-LL | fn generator_hold() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | / move || {
-LL | | let x = generator_hold();
- | | - generator captures itself here
-LL | | yield;
-LL | | x;
-LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:78:5: 78:12]`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:90:26
- |
-LL | fn mutual_recursion() -> impl Sync {
- | ^^^^^^^^^ recursive opaque type
-LL |
-LL | mutual_recursion_b()
- | -------------------- returning here with type `impl Sized`
-...
-LL | fn mutual_recursion_b() -> impl Sized {
- | ---------- returning this opaque type `impl Sized`
-
-error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:95:28
- |
-LL | fn mutual_recursion() -> impl Sync {
- | --------- returning this opaque type `impl Sync`
-...
-LL | fn mutual_recursion_b() -> impl Sized {
- | ^^^^^^^^^^ recursive opaque type
-LL |
-LL | mutual_recursion()
- | ------------------ returning here with type `impl Sync`
-
-error: aborting due to 14 previous errors
-
-For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs
index 630372e13..8331eec90 100644
--- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs
+++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.rs
@@ -1,11 +1,7 @@
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
-
// Test that impl trait does not allow creating recursive types that are
// otherwise forbidden.
-#![feature(generators)]
+#![feature(coroutines)]
#![allow(unconditional_recursion)]
fn option(i: i32) -> impl Sized {
@@ -54,14 +50,14 @@ fn closure_sig() -> impl Sized {
|| closure_sig()
}
-fn generator_sig() -> impl Sized {
+fn coroutine_sig() -> impl Sized {
//~^ ERROR
- || generator_sig()
+ || coroutine_sig()
}
-fn generator_capture() -> impl Sized {
+fn coroutine_capture() -> impl Sized {
//~^ ERROR
- let x = generator_capture();
+ let x = coroutine_capture();
move || {
yield;
x;
@@ -73,10 +69,10 @@ fn substs_change<T: 'static>() -> impl Sized {
(substs_change::<&T>(),)
}
-fn generator_hold() -> impl Sized {
+fn coroutine_hold() -> impl Sized {
//~^ ERROR
move || {
- let x = generator_hold();
+ let x = coroutine_hold();
yield;
x;
}
diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr
index 9c67f17e9..8e9aa8ad0 100644
--- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr
+++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.stderr
@@ -1,5 +1,5 @@
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:11:22
+ --> $DIR/recursive-impl-trait-type-indirect.rs:7:22
|
LL | fn option(i: i32) -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -10,7 +10,7 @@ LL | if i < 0 { None } else { Some((option(i - 1), i)) }
| returning here with type `Option<(impl Sized, i32)>`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:16:15
+ --> $DIR/recursive-impl-trait-type-indirect.rs:12:15
|
LL | fn tuple() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -19,7 +19,7 @@ LL | (tuple(),)
| ---------- returning here with type `(impl Sized,)`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:21:15
+ --> $DIR/recursive-impl-trait-type-indirect.rs:17:15
|
LL | fn array() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -28,7 +28,7 @@ LL | [array()]
| --------- returning here with type `[impl Sized; 1]`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:26:13
+ --> $DIR/recursive-impl-trait-type-indirect.rs:22:13
|
LL | fn ptr() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -37,7 +37,7 @@ LL | &ptr() as *const _
| ------------------ returning here with type `*const impl Sized`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:31:16
+ --> $DIR/recursive-impl-trait-type-indirect.rs:27:16
|
LL | fn fn_ptr() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -46,7 +46,7 @@ LL | fn_ptr as fn() -> _
| ------------------- returning here with type `fn() -> impl Sized`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:36:25
+ --> $DIR/recursive-impl-trait-type-indirect.rs:32:25
|
LL | fn closure_capture() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -55,10 +55,10 @@ LL | / move || {
LL | | x;
| | - closure captures itself here
LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:39:5: 39:12]`
+ | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:35:5: 35:12}`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:44:29
+ --> $DIR/recursive-impl-trait-type-indirect.rs:40:29
|
LL | fn closure_ref_capture() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -67,41 +67,41 @@ LL | / move || {
LL | | &x;
| | - closure captures itself here
LL | | }
- | |_____- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:47:5: 47:12]`
+ | |_____- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:43:5: 43:12}`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:52:21
+ --> $DIR/recursive-impl-trait-type-indirect.rs:48:21
|
LL | fn closure_sig() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
LL |
LL | || closure_sig()
- | ---------------- returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:54:5: 54:7]`
+ | ---------------- returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:7}`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:57:23
+ --> $DIR/recursive-impl-trait-type-indirect.rs:53:23
|
-LL | fn generator_sig() -> impl Sized {
+LL | fn coroutine_sig() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
LL |
-LL | || generator_sig()
- | ------------------ returning here with type `[closure@$DIR/recursive-impl-trait-type-indirect.rs:59:5: 59:7]`
+LL | || coroutine_sig()
+ | ------------------ returning here with type `{closure@$DIR/recursive-impl-trait-type-indirect.rs:55:5: 55:7}`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:62:27
+ --> $DIR/recursive-impl-trait-type-indirect.rs:58:27
|
-LL | fn generator_capture() -> impl Sized {
+LL | fn coroutine_capture() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
...
LL | / move || {
LL | | yield;
LL | | x;
- | | - generator captures itself here
+ | | - coroutine captures itself here
LL | | }
- | |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:65:5: 65:12]`
+ | |_____- returning here with type `{coroutine@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 61:12}`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:71:35
+ --> $DIR/recursive-impl-trait-type-indirect.rs:67:35
|
LL | fn substs_change<T: 'static>() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
@@ -110,16 +110,16 @@ LL | (substs_change::<&T>(),)
| ------------------------ returning here with type `(impl Sized,)`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:76:24
+ --> $DIR/recursive-impl-trait-type-indirect.rs:72:24
|
-LL | fn generator_hold() -> impl Sized {
+LL | fn coroutine_hold() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
...
-LL | let x = generator_hold();
- | - generator captures itself here
+LL | let x = coroutine_hold();
+ | - coroutine captures itself here
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:90:26
+ --> $DIR/recursive-impl-trait-type-indirect.rs:86:26
|
LL | fn mutual_recursion() -> impl Sync {
| ^^^^^^^^^ recursive opaque type
@@ -131,7 +131,7 @@ LL | fn mutual_recursion_b() -> impl Sized {
| ---------- returning this opaque type `impl Sized`
error[E0720]: cannot resolve opaque type
- --> $DIR/recursive-impl-trait-type-indirect.rs:95:28
+ --> $DIR/recursive-impl-trait-type-indirect.rs:91:28
|
LL | fn mutual_recursion() -> impl Sync {
| --------- returning this opaque type `impl Sync`
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..07ac1a37e 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
@@ -18,8 +18,8 @@ LL | fn eq(&self, _other: &(Foo, i32)) -> bool {
| expected `a::Bar`, found opaque type
| help: change the parameter type to match the trait: `&(a::Bar, i32)`
|
- = note: expected signature `fn(&a::Bar, &(a::Bar, i32)) -> _`
- found signature `fn(&a::Bar, &(a::Foo, i32)) -> _`
+ = note: expected signature `fn(&a::Bar, &(a::Bar, _)) -> _`
+ found signature `fn(&a::Bar, &(a::Foo, _)) -> _`
error: unconstrained opaque type
--> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:18:16
@@ -41,13 +41,13 @@ LL | fn eq(&self, _other: &(Bar, i32)) -> bool {
| expected opaque type, found `b::Bar`
| help: change the parameter type to match the trait: `&(b::Foo, i32)`
|
- = note: expected signature `fn(&b::Bar, &(b::Foo, i32)) -> _`
- found signature `fn(&b::Bar, &(b::Bar, i32)) -> _`
+ = note: expected signature `fn(&b::Bar, &(b::Foo, _)) -> _`
+ found signature `fn(&b::Bar, &(b::Bar, _)) -> _`
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..bc810c0f8
--- /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 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/region-escape-via-bound.stderr b/tests/ui/impl-trait/region-escape-via-bound.stderr
index e4556bc21..43f0eeeb5 100644
--- a/tests/ui/impl-trait/region-escape-via-bound.stderr
+++ b/tests/ui/impl-trait/region-escape-via-bound.stderr
@@ -14,6 +14,6 @@ help: to declare that `impl Trait<'y>` captures `'x`, you can add an explicit `'
LL | fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> + 'x
| ++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0700`.
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..7b2ca9c33
--- /dev/null
+++ b/tests/ui/impl-trait/reveal-during-codegen.rs
@@ -0,0 +1,11 @@
+// build-pass
+// revisions: current next
+//[next] compile-flags: -Znext-solver
+
+fn test() -> Option<impl Sized> {
+ Some("")
+}
+
+fn main() {
+ test();
+}
diff --git a/tests/ui/impl-trait/rpit-not-sized.stderr b/tests/ui/impl-trait/rpit-not-sized.stderr
index 608c94fc0..7fe275f06 100644
--- a/tests/ui/impl-trait/rpit-not-sized.stderr
+++ b/tests/ui/impl-trait/rpit-not-sized.stderr
@@ -7,6 +7,6 @@ LL | fn foo() -> impl ?Sized {
= help: the trait `Sized` is not implemented for `impl ?Sized`
= note: the return type of a function must have a statically known size
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs b/tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs
new file mode 100644
index 000000000..6207381c7
--- /dev/null
+++ b/tests/ui/impl-trait/rpit/equal-lifetime-params-ok.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+// related to #113916, check that using RPITs in functions with lifetime params
+// which are constrained to be equal compiles.
+
+trait Trait<'a, 'b> {}
+impl Trait<'_, '_> for () {}
+fn pass<'a: 'b, 'b: 'a>() -> impl Trait<'a, 'b> {
+ (|| {})()
+}
+
+struct Foo<'a>(&'a ());
+impl<'a> Foo<'a> {
+ fn bar<'b: 'a>(&'b self) -> impl Trait<'a, 'b> {
+ let _: &'a &'b &'a ();
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/rpit/non-defining-use.rs b/tests/ui/impl-trait/rpit/non-defining-use.rs
new file mode 100644
index 000000000..255a8929a
--- /dev/null
+++ b/tests/ui/impl-trait/rpit/non-defining-use.rs
@@ -0,0 +1,14 @@
+// Regression test for #111935 that non-defining uses of RPIT result in errors
+#![allow(unconditional_recursion)]
+fn foo<T>() -> impl Sized {
+ let _: () = foo::<u8>(); //~ ERROR expected generic type parameter, found `u8`
+}
+
+fn bar<T>(val: T) -> impl Sized {
+ let _: u8 = bar(0u8);
+ //~^ ERROR concrete type differs from previous defining opaque type use
+ //~| ERROR expected generic type parameter, found `u8`
+ val
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/rpit/non-defining-use.stderr b/tests/ui/impl-trait/rpit/non-defining-use.stderr
new file mode 100644
index 000000000..19987d476
--- /dev/null
+++ b/tests/ui/impl-trait/rpit/non-defining-use.stderr
@@ -0,0 +1,31 @@
+error[E0792]: expected generic type parameter, found `u8`
+ --> $DIR/non-defining-use.rs:4:12
+ |
+LL | fn foo<T>() -> impl Sized {
+ | - this generic parameter must be used with a generic type parameter
+LL | let _: () = foo::<u8>();
+ | ^^
+
+error[E0792]: expected generic type parameter, found `u8`
+ --> $DIR/non-defining-use.rs:8:12
+ |
+LL | fn bar<T>(val: T) -> impl Sized {
+ | - this generic parameter must be used with a generic type parameter
+LL | let _: u8 = bar(0u8);
+ | ^^
+
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/non-defining-use.rs:8:17
+ |
+LL | let _: u8 = bar(0u8);
+ | ^^^^^^^^ expected `T`, got `u8`
+ |
+note: previous use here
+ --> $DIR/non-defining-use.rs:7:22
+ |
+LL | fn bar<T>(val: T) -> impl Sized {
+ | ^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/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..91a0e0d48
--- /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)]
+
+pub struct Element;
+
+pub trait Node {
+ fn elements<const T: &'static str>(&self) -> impl Iterator<Item = Element>;
+}
+
+fn main() {}
diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr
index 488cb821c..4be244068 100644
--- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr
+++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr
@@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that
LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
| ----- ----------------------- opaque type defined here
| |
- | hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30]>` captures the anonymous lifetime defined here
+ | hidden type `Map<std::slice::Iter<'_, (u32, u32)>, {closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30}>` captures the anonymous lifetime defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator<Item = u32>` captures lifetime that
LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
| -- ----------------------- opaque type defined here
| |
- | hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:11:27: 11:30]>` captures the lifetime `'a` as defined here
+ | hidden type `Map<std::slice::Iter<'a, (u32, u32)>, {closure@$DIR/static-return-lifetime-infered.rs:11:27: 11:30}>` captures the lifetime `'a` as defined here
LL | self.x.iter().map(|a| a.0)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
diff --git a/tests/ui/impl-trait/suggest-calling-rpit-closure.stderr b/tests/ui/impl-trait/suggest-calling-rpit-closure.stderr
index c10a856d8..b0ae10b8d 100644
--- a/tests/ui/impl-trait/suggest-calling-rpit-closure.stderr
+++ b/tests/ui/impl-trait/suggest-calling-rpit-closure.stderr
@@ -16,6 +16,6 @@ help: use parentheses to call this opaque type
LL | opaque()()
| ++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other.stderr b/tests/ui/impl-trait/two_tait_defining_each_other.current.stderr
index 1a42ac525..b60529ed0 100644
--- a/tests/ui/impl-trait/two_tait_defining_each_other.stderr
+++ b/tests/ui/impl-trait/two_tait_defining_each_other.current.stderr
@@ -1,19 +1,19 @@
error: opaque type's hidden type cannot be another opaque type from the same scope
- --> $DIR/two_tait_defining_each_other.rs:12:5
+ --> $DIR/two_tait_defining_each_other.rs:16:5
|
LL | x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other
| ^ 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/two_tait_defining_each_other.rs:4:10
+ --> $DIR/two_tait_defining_each_other.rs:8:10
|
LL | type B = impl Foo;
| ^^^^^^^^
note: opaque type being used as hidden type
- --> $DIR/two_tait_defining_each_other.rs:3:10
+ --> $DIR/two_tait_defining_each_other.rs:7:10
|
LL | type A = impl Foo;
| ^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other.rs b/tests/ui/impl-trait/two_tait_defining_each_other.rs
index 6eb2a11b2..6a9e33500 100644
--- a/tests/ui/impl-trait/two_tait_defining_each_other.rs
+++ b/tests/ui/impl-trait/two_tait_defining_each_other.rs
@@ -1,3 +1,7 @@
+// revisions: current next
+//[next] compile-flags: -Znext-solver
+//[next] check-pass
+
#![feature(type_alias_impl_trait)]
type A = impl Foo;
@@ -10,7 +14,7 @@ fn muh(x: A) -> B {
return Bar; // B's hidden type is Bar
}
x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other
- //~^ ERROR opaque type's hidden type cannot be another opaque type
+ //[current]~^ ERROR opaque type's hidden type cannot be another opaque type
}
struct Bar;
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr
index 4d8f96de1..33866451c 100644
--- a/tests/ui/impl-trait/two_tait_defining_each_other2.stderr
+++ b/tests/ui/impl-trait/two_tait_defining_each_other2.current.stderr
@@ -1,5 +1,5 @@
error: unconstrained opaque type
- --> $DIR/two_tait_defining_each_other2.rs:3:10
+ --> $DIR/two_tait_defining_each_other2.rs:5:10
|
LL | type A = impl Foo;
| ^^^^^^^^
@@ -7,18 +7,18 @@ LL | type A = impl Foo;
= note: `A` must be used in combination with a concrete type within the same module
error: opaque type's hidden type cannot be another opaque type from the same scope
- --> $DIR/two_tait_defining_each_other2.rs:9:5
+ --> $DIR/two_tait_defining_each_other2.rs:11:5
|
LL | x // B's hidden type is A (opaquely)
| ^ 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/two_tait_defining_each_other2.rs:4:10
+ --> $DIR/two_tait_defining_each_other2.rs:6:10
|
LL | type B = impl Foo;
| ^^^^^^^^
note: opaque type being used as hidden type
- --> $DIR/two_tait_defining_each_other2.rs:3:10
+ --> $DIR/two_tait_defining_each_other2.rs:5:10
|
LL | type A = impl Foo;
| ^^^^^^^^
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr
new file mode 100644
index 000000000..e49d1d18b
--- /dev/null
+++ b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr
@@ -0,0 +1,9 @@
+error[E0284]: type annotations needed: cannot satisfy `A <: B`
+ --> $DIR/two_tait_defining_each_other2.rs:11:5
+ |
+LL | x // B's hidden type is A (opaquely)
+ | ^ cannot satisfy `A <: B`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0284`.
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs
index 05b096680..8a79af197 100644
--- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs
+++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs
@@ -1,13 +1,16 @@
+// revisions: current next
+//[next] compile-flags: -Znext-solver
#![feature(type_alias_impl_trait)]
-type A = impl Foo; //~ ERROR unconstrained opaque type
+type A = impl Foo; //[current]~ ERROR unconstrained opaque type
type B = impl Foo;
trait Foo {}
fn muh(x: A) -> B {
x // B's hidden type is A (opaquely)
- //~^ ERROR opaque type's hidden type cannot be another opaque type
+ //[current]~^ ERROR opaque type's hidden type cannot be another opaque type
+ //[next]~^^ ERROR type annotations needed: cannot satisfy `A <: B`
}
struct Bar;
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other3.stderr b/tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr
index b06dc16d5..1dccfd17a 100644
--- a/tests/ui/impl-trait/two_tait_defining_each_other3.stderr
+++ b/tests/ui/impl-trait/two_tait_defining_each_other3.current.stderr
@@ -1,19 +1,19 @@
error: opaque type's hidden type cannot be another opaque type from the same scope
- --> $DIR/two_tait_defining_each_other3.rs:10:16
+ --> $DIR/two_tait_defining_each_other3.rs:13:16
|
LL | return x; // B's hidden type is A (opaquely)
| ^ 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/two_tait_defining_each_other3.rs:4:10
+ --> $DIR/two_tait_defining_each_other3.rs:7:10
|
LL | type B = impl Foo;
| ^^^^^^^^
note: opaque type being used as hidden type
- --> $DIR/two_tait_defining_each_other3.rs:3:10
+ --> $DIR/two_tait_defining_each_other3.rs:6:10
|
LL | type A = impl Foo;
| ^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/two_tait_defining_each_other3.rs b/tests/ui/impl-trait/two_tait_defining_each_other3.rs
index 37f8ae1b8..55def937f 100644
--- a/tests/ui/impl-trait/two_tait_defining_each_other3.rs
+++ b/tests/ui/impl-trait/two_tait_defining_each_other3.rs
@@ -1,3 +1,6 @@
+// revisions: current next
+//[next] compile-flags: -Znext-solver
+//[next] check-pass
#![feature(type_alias_impl_trait)]
type A = impl Foo;
@@ -8,7 +11,7 @@ trait Foo {}
fn muh(x: A) -> B {
if false {
return x; // B's hidden type is A (opaquely)
- //~^ ERROR opaque type's hidden type cannot be another opaque type
+ //[current]~^ ERROR opaque type's hidden type cannot be another opaque type
}
Bar // A's hidden type is `Bar`, because all the return types are compared with each other
}
diff --git a/tests/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr b/tests/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr
index 30322f88c..d3d651a28 100644
--- a/tests/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr
+++ b/tests/ui/impl-trait/type-arg-mismatch-due-to-impl-trait.stderr
@@ -10,6 +10,6 @@ LL | fn foo(&self, t: impl Clone) {}
| found 1 type parameter
| `impl Trait` introduces an implicit type parameter
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0049`.
diff --git a/tests/ui/impl-trait/type_parameters_captured.stderr b/tests/ui/impl-trait/type_parameters_captured.stderr
index fb502cfdd..28dfcd8b8 100644
--- a/tests/ui/impl-trait/type_parameters_captured.stderr
+++ b/tests/ui/impl-trait/type_parameters_captured.stderr
@@ -2,13 +2,16 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/type_parameters_captured.rs:8:5
|
LL | x
- | ^ ...so that the type `T` will meet its required lifetime bounds
+ | ^
+ | |
+ | the parameter type `T` must be valid for the static lifetime...
+ | ...so that the type `T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn foo<T: 'static>(x: T) -> impl Any + 'static {
| +++++++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0310`.
diff --git a/tests/ui/impl-trait/unactionable_diagnostic.fixed b/tests/ui/impl-trait/unactionable_diagnostic.fixed
index 6c2505177..d446512ff 100644
--- a/tests/ui/impl-trait/unactionable_diagnostic.fixed
+++ b/tests/ui/impl-trait/unactionable_diagnostic.fixed
@@ -14,7 +14,7 @@ fn foo<'x, P>(
}
pub fn bar<'t, T: 't>(
- //~^ HELP: consider adding an explicit lifetime bound...
+ //~^ HELP: consider adding an explicit lifetime bound
post: T,
x: &'t Foo,
) -> &'t impl Trait {
diff --git a/tests/ui/impl-trait/unactionable_diagnostic.rs b/tests/ui/impl-trait/unactionable_diagnostic.rs
index bce35cbdd..76b9a62ca 100644
--- a/tests/ui/impl-trait/unactionable_diagnostic.rs
+++ b/tests/ui/impl-trait/unactionable_diagnostic.rs
@@ -14,7 +14,7 @@ fn foo<'x, P>(
}
pub fn bar<'t, T>(
- //~^ HELP: consider adding an explicit lifetime bound...
+ //~^ HELP: consider adding an explicit lifetime bound
post: T,
x: &'t Foo,
) -> &'t impl Trait {
diff --git a/tests/ui/impl-trait/unactionable_diagnostic.stderr b/tests/ui/impl-trait/unactionable_diagnostic.stderr
index a32004cda..be37da08e 100644
--- a/tests/ui/impl-trait/unactionable_diagnostic.stderr
+++ b/tests/ui/impl-trait/unactionable_diagnostic.stderr
@@ -1,14 +1,17 @@
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/unactionable_diagnostic.rs:21:5
|
+LL | pub fn bar<'t, T>(
+ | -- the parameter type `T` must be valid for the lifetime `'t` as defined here...
+...
LL | foo(post, x)
| ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | pub fn bar<'t, T: 't>(
| ++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0309`.
diff --git a/tests/ui/impl-trait/universal-mismatched-type.stderr b/tests/ui/impl-trait/universal-mismatched-type.stderr
index a56e542d8..21da1d087 100644
--- a/tests/ui/impl-trait/universal-mismatched-type.stderr
+++ b/tests/ui/impl-trait/universal-mismatched-type.stderr
@@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | fn foo(x: impl Debug) -> String {
| ---------- ------ expected `String` because of return type
| |
- | this type parameter
+ | found this type parameter
LL | x
| ^ expected `String`, found type parameter `impl Debug`
|
= note: expected struct `String`
found type parameter `impl Debug`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/impl-trait/universal-two-impl-traits.stderr b/tests/ui/impl-trait/universal-two-impl-traits.stderr
index ab8a53d0d..3b4844ab1 100644
--- a/tests/ui/impl-trait/universal-two-impl-traits.stderr
+++ b/tests/ui/impl-trait/universal-two-impl-traits.stderr
@@ -15,6 +15,6 @@ LL | a = y;
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
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..e07189279 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
+error: aborting due to 1 previous error
diff --git a/tests/ui/impl-trait/variance.e2024.stderr b/tests/ui/impl-trait/variance.e2024.stderr
new file mode 100644
index 000000000..172450557
--- /dev/null
+++ b/tests/ui/impl-trait/variance.e2024.stderr
@@ -0,0 +1,26 @@
+error: [*, o]
+ --> $DIR/variance.rs:14:36
+ |
+LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [*, o]
+ --> $DIR/variance.rs:19:32
+ |
+LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:21:40
+ |
+LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:26:36
+ |
+LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/impl-trait/variance.new.stderr b/tests/ui/impl-trait/variance.new.stderr
new file mode 100644
index 000000000..172450557
--- /dev/null
+++ b/tests/ui/impl-trait/variance.new.stderr
@@ -0,0 +1,26 @@
+error: [*, o]
+ --> $DIR/variance.rs:14:36
+ |
+LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [*, o]
+ --> $DIR/variance.rs:19:32
+ |
+LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:21:40
+ |
+LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:26:36
+ |
+LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/impl-trait/variance.old.stderr b/tests/ui/impl-trait/variance.old.stderr
new file mode 100644
index 000000000..9410b54b4
--- /dev/null
+++ b/tests/ui/impl-trait/variance.old.stderr
@@ -0,0 +1,26 @@
+error: [*]
+ --> $DIR/variance.rs:14:36
+ |
+LL | fn not_captured_early<'a: 'a>() -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [*, o]
+ --> $DIR/variance.rs:19:32
+ |
+LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: []
+ --> $DIR/variance.rs:21:40
+ |
+LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
+ | ^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:26:36
+ |
+LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/impl-trait/variance.rs b/tests/ui/impl-trait/variance.rs
new file mode 100644
index 000000000..86da19085
--- /dev/null
+++ b/tests/ui/impl-trait/variance.rs
@@ -0,0 +1,28 @@
+// revisions: old new e2024
+//[e2024] edition: 2024
+//[e2024] compile-flags: -Z unstable-options
+
+#![cfg_attr(new, feature(lifetime_capture_rules_2024))]
+
+#![feature(rustc_attrs)]
+#![allow(internal_features)]
+#![rustc_variance_of_opaques]
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+fn not_captured_early<'a: 'a>() -> impl Sized {}
+//[old]~^ [*]
+//[new]~^^ [*, o]
+//[e2024]~^^^ [*, o]
+
+fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} //~ [*, o]
+
+fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
+//[old]~^ []
+//[new]~^^ [o]
+//[e2024]~^^^ [o]
+
+fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} //~ [o]
+
+fn main() {}
diff --git a/tests/ui/impl-trait/where-allowed-2.stderr b/tests/ui/impl-trait/where-allowed-2.stderr
index 2b328c01c..c421e587a 100644
--- a/tests/ui/impl-trait/where-allowed-2.stderr
+++ b/tests/ui/impl-trait/where-allowed-2.stderr
@@ -1,9 +1,11 @@
-error[E0282]: type annotations needed
+error[E0283]: type annotations needed
--> $DIR/where-allowed-2.rs:3:30
|
LL | fn in_adt_in_return() -> Vec<impl Debug> { panic!() }
| ^^^^^^^^^^ cannot infer type
+ |
+ = note: cannot satisfy `_: Debug`
-error: aborting due to previous error
+error: aborting due to 1 previous error
-For more information about this error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs
index 509d27166..158dc5ab9 100644
--- a/tests/ui/impl-trait/where-allowed.rs
+++ b/tests/ui/impl-trait/where-allowed.rs
@@ -16,47 +16,47 @@ fn in_adt_in_parameters(_: Vec<impl Debug>) { panic!() }
// Disallowed
fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Allowed
fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() }
// Disallowed
fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
//~^^ ERROR nested `impl Trait` is not allowed
// Disallowed
fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
//~| ERROR nested `impl Trait` is not allowed
// Allowed
@@ -64,11 +64,11 @@ fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!()
// Disallowed
fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Allowed
@@ -81,22 +81,22 @@ fn in_impl_Trait_in_return() -> impl IntoIterator<Item = impl IntoIterator> {
// Disallowed
struct InBraceStructField { x: impl Debug }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
struct InAdtInBraceStructField { x: Vec<impl Debug> }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
struct InTupleStructField(impl Debug);
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
enum InEnum {
InBraceVariant { x: impl Debug },
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
InTupleVariant(impl Debug),
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
// Allowed
@@ -104,10 +104,9 @@ trait InTraitDefnParameters {
fn in_parameters(_: impl Debug);
}
-// Disallowed
+// Allowed
trait InTraitDefnReturn {
fn in_return() -> impl Debug;
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
}
// Allowed and disallowed in trait impls
@@ -124,7 +123,7 @@ impl DummyTrait for () {
// Allowed
fn in_trait_impl_return() -> impl Debug { () }
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ // Allowed
}
// Allowed
@@ -137,10 +136,10 @@ impl DummyType {
// Disallowed
extern "C" {
fn in_foreign_parameters(_: impl Debug);
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
fn in_foreign_return() -> impl Debug;
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
// Allowed
@@ -156,97 +155,97 @@ type InTypeAlias<R> = impl Debug;
//~^ ERROR `impl Trait` in type aliases is unstable
type InReturnInTypeAlias<R> = fn() -> impl Debug;
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
//~| ERROR `impl Trait` in type aliases is unstable
// Disallowed in impl headers
impl PartialEq<impl Debug> for () {
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
// Disallowed in impl headers
impl PartialEq<()> for impl Debug {
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
// Disallowed in inherent impls
impl impl Debug {
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
// Disallowed in inherent impls
struct InInherentImplAdt<T> { t: T }
impl InInherentImplAdt<impl Debug> {
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
// Disallowed in where clauses
fn in_fn_where_clause()
where impl Debug: Debug
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
{
}
// Disallowed in where clauses
fn in_adt_in_fn_where_clause()
where Vec<impl Debug>: Debug
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
{
}
// Disallowed
fn in_trait_parameter_in_fn_where_clause<T>()
where T: PartialEq<impl Debug>
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
{
}
// Disallowed
fn in_Fn_parameter_in_fn_where_clause<T>()
where T: Fn(impl Debug)
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
{
}
// Disallowed
fn in_Fn_return_in_fn_where_clause<T>()
where T: Fn() -> impl Debug
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
{
}
// Disallowed
struct InStructGenericParamDefault<T = impl Debug>(T);
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
trait InTraitGenericParamDefault<T = impl Debug> {}
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
type InTypeAliasGenericParamDefault<T = impl Debug> = T;
-//~^ ERROR `impl Trait` only allowed in function and inherent method return types
+//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
// Disallowed
impl <T = impl Debug> T {}
//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
//~| WARNING this was previously accepted by the compiler but is being phased out
-//~| ERROR `impl Trait` only allowed in function and inherent method return types
+//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types
//~| ERROR no nominal type found
// Disallowed
fn in_method_generic_param_default<T = impl Debug>(_: T) {}
//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
//~| WARNING this was previously accepted by the compiler but is being phased out
-//~| ERROR `impl Trait` only allowed in function and inherent method return types
+//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types
fn main() {
let _in_local_variable: impl Fn() = || {};
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
let _in_return_in_local_variable = || -> impl Fn() { || {} };
- //~^ ERROR `impl Trait` only allowed in function and inherent method return types
+ //~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
}
diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr
index 3e2934379..2d8895030 100644
--- a/tests/ui/impl-trait/where-allowed.stderr
+++ b/tests/ui/impl-trait/where-allowed.stderr
@@ -17,7 +17,7 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic
| outer `impl Trait`
error[E0658]: `impl Trait` in associated types is unstable
- --> $DIR/where-allowed.rs:120:16
+ --> $DIR/where-allowed.rs:119:16
|
LL | type Out = impl Debug;
| ^^^^^^^^^^
@@ -26,7 +26,7 @@ LL | type Out = impl Debug;
= help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable
error[E0658]: `impl Trait` in type aliases is unstable
- --> $DIR/where-allowed.rs:155:23
+ --> $DIR/where-allowed.rs:154:23
|
LL | type InTypeAlias<R> = impl Debug;
| ^^^^^^^^^^
@@ -35,7 +35,7 @@ LL | type InTypeAlias<R> = impl Debug;
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
error[E0658]: `impl Trait` in type aliases is unstable
- --> $DIR/where-allowed.rs:158:39
+ --> $DIR/where-allowed.rs:157:39
|
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^
@@ -43,248 +43,230 @@ LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
= note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
= help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer params
--> $DIR/where-allowed.rs:18:40
|
LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types
--> $DIR/where-allowed.rs:22:42
|
LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer params
--> $DIR/where-allowed.rs:26:38
|
LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types
--> $DIR/where-allowed.rs:30:40
|
LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params
--> $DIR/where-allowed.rs:34:49
|
LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
--> $DIR/where-allowed.rs:38:51
|
LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params
--> $DIR/where-allowed.rs:42:55
|
LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params
--> $DIR/where-allowed.rs:49:51
|
LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
--> $DIR/where-allowed.rs:54:53
|
LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params
--> $DIR/where-allowed.rs:58:57
|
LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params
--> $DIR/where-allowed.rs:66:38
|
LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
--> $DIR/where-allowed.rs:70:40
|
LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types
--> $DIR/where-allowed.rs:83:32
|
LL | struct InBraceStructField { x: impl Debug }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types
--> $DIR/where-allowed.rs:87:41
|
LL | struct InAdtInBraceStructField { x: Vec<impl Debug> }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types
--> $DIR/where-allowed.rs:91:27
|
LL | struct InTupleStructField(impl Debug);
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types
--> $DIR/where-allowed.rs:96:25
|
LL | InBraceVariant { x: impl Debug },
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in field types
--> $DIR/where-allowed.rs:98:20
|
LL | InTupleVariant(impl Debug),
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types
- --> $DIR/where-allowed.rs:109:23
- |
-LL | fn in_return() -> impl Debug;
- | ^^^^^^^^^^
- |
- = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
- = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
-
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types
- --> $DIR/where-allowed.rs:126:34
- |
-LL | fn in_trait_impl_return() -> impl Debug { () }
- | ^^^^^^^^^^
- |
- = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
- = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
-
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` params
- --> $DIR/where-allowed.rs:139:33
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `extern fn` params
+ --> $DIR/where-allowed.rs:138:33
|
LL | fn in_foreign_parameters(_: impl Debug);
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return types
- --> $DIR/where-allowed.rs:142:31
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `extern fn` return types
+ --> $DIR/where-allowed.rs:141:31
|
LL | fn in_foreign_return() -> impl Debug;
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types
- --> $DIR/where-allowed.rs:158:39
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `fn` pointer return types
+ --> $DIR/where-allowed.rs:157:39
|
LL | type InReturnInTypeAlias<R> = fn() -> impl Debug;
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in traits
- --> $DIR/where-allowed.rs:163:16
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in traits
+ --> $DIR/where-allowed.rs:162:16
|
LL | impl PartialEq<impl Debug> for () {
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers
- --> $DIR/where-allowed.rs:168:24
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers
+ --> $DIR/where-allowed.rs:167:24
|
LL | impl PartialEq<()> for impl Debug {
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers
- --> $DIR/where-allowed.rs:173:6
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers
+ --> $DIR/where-allowed.rs:172:6
|
LL | impl impl Debug {
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers
- --> $DIR/where-allowed.rs:179:24
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers
+ --> $DIR/where-allowed.rs:178:24
|
LL | impl InInherentImplAdt<impl Debug> {
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds
- --> $DIR/where-allowed.rs:185:11
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds
+ --> $DIR/where-allowed.rs:184:11
|
LL | where impl Debug: Debug
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds
- --> $DIR/where-allowed.rs:192:15
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds
+ --> $DIR/where-allowed.rs:191:15
|
LL | where Vec<impl Debug>: Debug
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds
- --> $DIR/where-allowed.rs:199:24
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in bounds
+ --> $DIR/where-allowed.rs:198:24
|
LL | where T: PartialEq<impl Debug>
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params
- --> $DIR/where-allowed.rs:206:17
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait params
+ --> $DIR/where-allowed.rs:205:17
|
LL | where T: Fn(impl Debug)
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types
- --> $DIR/where-allowed.rs:213:22
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
+ --> $DIR/where-allowed.rs:212:22
|
LL | where T: Fn() -> impl Debug
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
- --> $DIR/where-allowed.rs:219:40
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
+ --> $DIR/where-allowed.rs:218:40
|
LL | struct InStructGenericParamDefault<T = impl Debug>(T);
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
- --> $DIR/where-allowed.rs:223:36
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
+ --> $DIR/where-allowed.rs:222:36
|
LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) }
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
- --> $DIR/where-allowed.rs:227:38
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
+ --> $DIR/where-allowed.rs:226:38
|
LL | trait InTraitGenericParamDefault<T = impl Debug> {}
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
- --> $DIR/where-allowed.rs:231:41
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
+ --> $DIR/where-allowed.rs:230:41
|
LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T;
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
- --> $DIR/where-allowed.rs:235:11
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
+ --> $DIR/where-allowed.rs:234:11
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
- --> $DIR/where-allowed.rs:242:40
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
+ --> $DIR/where-allowed.rs:241:40
|
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
| ^^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
- --> $DIR/where-allowed.rs:248:29
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
+ --> $DIR/where-allowed.rs:247:29
|
LL | let _in_local_variable: impl Fn() = || {};
| ^^^^^^^^^
-error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return types
- --> $DIR/where-allowed.rs:250:46
+error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in closure return types
+ --> $DIR/where-allowed.rs:249:46
|
LL | let _in_return_in_local_variable = || -> impl Fn() { || {} };
| ^^^^^^^^^
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
- --> $DIR/where-allowed.rs:235:7
+ --> $DIR/where-allowed.rs:234:7
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^^^^^
@@ -294,7 +276,7 @@ LL | impl <T = impl Debug> T {}
= note: `#[deny(invalid_type_param_default)]` on by default
error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
- --> $DIR/where-allowed.rs:242:36
+ --> $DIR/where-allowed.rs:241:36
|
LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
| ^^^^^^^^^^^^^^
@@ -303,14 +285,14 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {}
= note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887>
error[E0118]: no nominal type found for inherent implementation
- --> $DIR/where-allowed.rs:235:1
+ --> $DIR/where-allowed.rs:234:1
|
LL | impl <T = impl Debug> T {}
| ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type
|
= note: either implement a trait on it or create a newtype to wrap it instead
-error: aborting due to 47 previous errors
+error: aborting due to 45 previous errors
Some errors have detailed explanations: E0118, E0562, E0658, E0666.
For more information about an error, try `rustc --explain E0118`.