summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/type-alias-impl-trait')
-rw-r--r--tests/ui/type-alias-impl-trait/assoc-type-const.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs5
-rw-r--r--tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr36
-rw-r--r--tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs21
-rw-r--r--tests/ui/type-alias-impl-trait/bound_reduction2.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/bound_reduction2.stderr16
-rw-r--r--tests/ui/type-alias-impl-trait/bounds-are-checked-2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/bounds-are-checked.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/bounds-are-checked3.rs16
-rw-r--r--tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr20
-rw-r--r--tests/ui/type-alias-impl-trait/bounds.rs16
-rw-r--r--tests/ui/type-alias-impl-trait/broken_mir.rs16
-rw-r--r--tests/ui/type-alias-impl-trait/closure_args.rs11
-rw-r--r--tests/ui/type-alias-impl-trait/closure_args2.rs23
-rw-r--r--tests/ui/type-alias-impl-trait/closure_parent_substs.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/coherence.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/coherence.stderr10
-rw-r--r--tests/ui/type-alias-impl-trait/coherence_cross_crate.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs25
-rw-r--r--tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/coherence_generalization.rs7
-rw-r--r--tests/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/cross_inference.rs6
-rw-r--r--tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs12
-rw-r--r--tests/ui/type-alias-impl-trait/declared_but_never_defined.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr5
-rw-r--r--tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs19
-rw-r--r--tests/ui/type-alias-impl-trait/defining-use-submodule.rs6
-rw-r--r--tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs19
-rw-r--r--tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs23
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs6
-rw-r--r--tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs10
-rw-r--r--tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs13
-rw-r--r--tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs15
-rw-r--r--tests/ui/type-alias-impl-trait/escaping-bound-var.rs22
-rw-r--r--tests/ui/type-alias-impl-trait/escaping-bound-var.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/fallback.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/future.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/generic_different_defining_uses.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs7
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr20
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs18
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr52
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/generic_lifetime_param.rs5
-rw-r--r--tests/ui/type-alias-impl-trait/generic_nondefining_use.rs9
-rw-r--r--tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr44
-rw-r--r--tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs12
-rw-r--r--tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr25
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained.stderr27
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained2.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr56
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs28
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr20
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs30
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs26
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs57
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params.rs28
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params2.rs35
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr15
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params3.rs36
-rw-r--r--tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr28
-rw-r--r--tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs28
-rw-r--r--tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr20
-rw-r--r--tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs14
-rw-r--r--tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr11
-rw-r--r--tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/implied_bounds.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/implied_bounds_closure.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs20
-rw-r--r--tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/incomplete-inference.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs29
-rw-r--r--tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr27
-rw-r--r--tests/ui/type-alias-impl-trait/inference-cycle.rs13
-rw-r--r--tests/ui/type-alias-impl-trait/inference-cycle.stderr36
-rw-r--r--tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs8
-rw-r--r--tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/issue-104817.stock.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-109054.rs22
-rw-r--r--tests/ui/type-alias-impl-trait/issue-109054.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-52843.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092-2.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53092.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53096.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53598.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs22
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs19
-rw-r--r--tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/issue-57700.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-57961.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/issue-57961.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs39
-rw-r--r--tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs39
-rw-r--r--tests/ui/type-alias-impl-trait/issue-58662-simplified.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-60407.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-60564.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/issue-60564.stderr16
-rw-r--r--tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs5
-rw-r--r--tests/ui/type-alias-impl-trait/issue-63279.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/issue-63279.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/issue-65384.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs7
-rw-r--r--tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr16
-rw-r--r--tests/ui/type-alias-impl-trait/issue-70121.rs3
-rw-r--r--tests/ui/type-alias-impl-trait/issue-70121.stderr15
-rw-r--r--tests/ui/type-alias-impl-trait/issue-74244.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-74280.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-77179.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-77179.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-78450.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-89686.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-89686.stderr4
-rw-r--r--tests/ui/type-alias-impl-trait/issue-90400-1.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-90400-2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-94429.rs12
-rw-r--r--tests/ui/type-alias-impl-trait/issue-94429.stderr8
-rw-r--r--tests/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs29
-rw-r--r--tests/ui/type-alias-impl-trait/issue-98604.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/issue-98608.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs5
-rw-r--r--tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr11
-rw-r--r--tests/ui/type-alias-impl-trait/multi-error.rs23
-rw-r--r--tests/ui/type-alias-impl-trait/multi-error.stderr15
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs6
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr4
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs6
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs1
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr11
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs40
-rw-r--r--tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr5
-rw-r--r--tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.rs9
-rw-r--r--tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr47
-rw-r--r--tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs49
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs15
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr23
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-inference.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr4
-rw-r--r--tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/nested.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs44
-rw-r--r--tests/ui/type-alias-impl-trait/nested_in_closure.rs17
-rw-r--r--tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr10
-rw-r--r--tests/ui/type-alias-impl-trait/non-defining-method.rs21
-rw-r--r--tests/ui/type-alias-impl-trait/non-defining-method.stderr15
-rw-r--r--tests/ui/type-alias-impl-trait/normalize-alias-type.rs32
-rw-r--r--tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr55
-rw-r--r--tests/ui/type-alias-impl-trait/normalize-hidden-types.rs60
-rw-r--r--tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs33
-rw-r--r--tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr22
-rw-r--r--tests/ui/type-alias-impl-trait/not_well_formed.fixed19
-rw-r--r--tests/ui/type-alias-impl-trait/not_well_formed.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/not_well_formed.stderr11
-rw-r--r--tests/ui/type-alias-impl-trait/obligation_ice.rs17
-rw-r--r--tests/ui/type-alias-impl-trait/privacy.rs10
-rw-r--r--tests/ui/type-alias-impl-trait/privacy.stderr15
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-fn-tait.rs17
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs21
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs34
-rw-r--r--tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr14
-rw-r--r--tests/ui/type-alias-impl-trait/reveal_local.rs9
-rw-r--r--tests/ui/type-alias-impl-trait/reveal_local.stderr56
-rw-r--r--tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr29
-rw-r--r--tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs32
-rw-r--r--tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs18
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential-2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential-3.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential-3.stderr15
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential-4.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential-4.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/self-referential.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/self_implication.rs4
-rw-r--r--tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/structural-match.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/tait-normalize.rs14
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr4
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs8
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/type_of_a_let.rs8
-rw-r--r--tests/ui/type-alias-impl-trait/type_of_a_let.stderr6
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs14
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr17
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs25
-rw-r--r--tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/under-binder.rs9
-rw-r--r--tests/ui/type-alias-impl-trait/under-binder.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/underconstrained_generic.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/underconstrained_lifetime.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/variance.rs44
-rw-r--r--tests/ui/type-alias-impl-trait/variance.stderr68
-rw-r--r--tests/ui/type-alias-impl-trait/wf-check-fn-def.stderr2
-rw-r--r--tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs19
-rw-r--r--tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr12
-rw-r--r--tests/ui/type-alias-impl-trait/wf-in-associated-type.rs6
-rw-r--r--tests/ui/type-alias-impl-trait/wf-nested.fail.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr9
-rw-r--r--tests/ui/type-alias-impl-trait/wf_check_closures.stderr2
245 files changed, 2562 insertions, 465 deletions
diff --git a/tests/ui/type-alias-impl-trait/assoc-type-const.rs b/tests/ui/type-alias-impl-trait/assoc-type-const.rs
index 62f66914e..e385fe045 100644
--- a/tests/ui/type-alias-impl-trait/assoc-type-const.rs
+++ b/tests/ui/type-alias-impl-trait/assoc-type-const.rs
@@ -1,7 +1,9 @@
// Tests that we properly detect defining usages when using
// const generics in an associated opaque type
-// check-pass
+// check-pass
+// revisions: current next
+//[next] compile-flags: -Znext-solver
#![feature(impl_trait_in_assoc_type)]
trait UnwrapItemsExt<'a, const C: usize> {
diff --git a/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr b/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr
index e594dc577..089c3e4fd 100644
--- a/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr
+++ b/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.stderr
@@ -4,6 +4,6 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
LL | impl<'a, I> UnwrapItemsExt for I {
| ^^ unconstrained lifetime 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/type-alias-impl-trait/auto-trait-leakage.rs b/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs
index a1584581e..d9f7c7809 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage.rs
@@ -4,9 +4,9 @@
#![allow(dead_code)]
mod m {
- type Foo = impl std::fmt::Debug;
+ pub(crate) type Foo = impl std::fmt::Debug;
- pub fn foo() -> Foo {
+ pub(crate) fn foo() -> Foo {
22_u32
}
}
diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage2.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
index d7247302d..2ed918eca 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
@@ -21,6 +21,6 @@ note: required by a bound in `is_send`
LL | fn is_send<T: Send>(_: T) {}
| ^^^^ required by this bound in `is_send`
-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/type-alias-impl-trait/auto-trait-leakage3.rs b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs
index 5fb7a9473..cad75cffe 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.rs
@@ -4,15 +4,14 @@
// FIXME This should compile, but it currently doesn't
mod m {
- type Foo = impl std::fmt::Debug;
- //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
-
+ pub type Foo = impl std::fmt::Debug;
pub fn foo() -> Foo {
22_u32
}
pub fn bar() {
is_send(foo());
+ //~^ ERROR: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}
}
fn is_send<T: Send>(_: T) {}
diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
index 1e9a45aac..f6f754557 100644
--- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
+++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
@@ -1,22 +1,26 @@
-error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
- --> $DIR/auto-trait-leakage3.rs:7:16
+error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits
+ --> $DIR/auto-trait-leakage3.rs:13:17
|
-LL | type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
+LL | is_send(foo());
+ | ------- ^^^^^
+ | |
+ | required by a bound introduced by this call
|
-note: ...which requires type-checking `m::bar`...
- --> $DIR/auto-trait-leakage3.rs:15:9
+note: opaque type is declared here
+ --> $DIR/auto-trait-leakage3.rs:7:20
|
-LL | is_send(foo());
- | ^^^^^^^
- = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
- = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in module `m`
- --> $DIR/auto-trait-leakage3.rs:6:1
+LL | pub type Foo = impl std::fmt::Debug;
+ | ^^^^^^^^^^^^^^^^^^^^
+note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
+ --> $DIR/auto-trait-leakage3.rs:12:12
+ |
+LL | pub fn bar() {
+ | ^^^
+note: required by a bound in `is_send`
+ --> $DIR/auto-trait-leakage3.rs:17:19
|
-LL | mod m {
- | ^^^^^
+LL | fn is_send<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `is_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/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs b/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs
new file mode 100644
index 000000000..54a225100
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/auxiliary/drop-shim-relates-opaque-aux.rs
@@ -0,0 +1,21 @@
+// crate foo
+
+#![feature(type_alias_impl_trait)]
+
+type Tait = impl Sized;
+fn _constrain() -> Tait {}
+
+struct WrapperWithDrop<T>(T);
+impl<T> Drop for WrapperWithDrop<T> {
+ fn drop(&mut self) {}
+}
+
+pub struct Foo(WrapperWithDrop<Tait>);
+
+trait Id {
+ type Id: ?Sized;
+}
+impl<T: ?Sized> Id for T {
+ type Id = T;
+}
+pub struct Bar(WrapperWithDrop<<Tait as Id>::Id>);
diff --git a/tests/ui/type-alias-impl-trait/bound_reduction2.rs b/tests/ui/type-alias-impl-trait/bound_reduction2.rs
index 0bcc9e002..4e9f65d88 100644
--- a/tests/ui/type-alias-impl-trait/bound_reduction2.rs
+++ b/tests/ui/type-alias-impl-trait/bound_reduction2.rs
@@ -13,6 +13,7 @@ trait Trait<U> {}
impl<W> Trait<W> for () {}
fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
+ //~^ ERROR non-defining opaque type use
()
//~^ ERROR expected generic type parameter, found `<T as TraitWithAssoc>::Assoc`
}
diff --git a/tests/ui/type-alias-impl-trait/bound_reduction2.stderr b/tests/ui/type-alias-impl-trait/bound_reduction2.stderr
index 3c259bd9e..14f9dbbdb 100644
--- a/tests/ui/type-alias-impl-trait/bound_reduction2.stderr
+++ b/tests/ui/type-alias-impl-trait/bound_reduction2.stderr
@@ -1,5 +1,17 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/bound_reduction2.rs:15:46
+ |
+LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> {
+ | ^^^^^^^^^^^^^ argument `<T as TraitWithAssoc>::Assoc` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/bound_reduction2.rs:9:15
+ |
+LL | type Foo<V> = impl Trait<V>;
+ | ^^^^^^^^^^^^^
+
error[E0792]: expected generic type parameter, found `<T as TraitWithAssoc>::Assoc`
- --> $DIR/bound_reduction2.rs:16:5
+ --> $DIR/bound_reduction2.rs:17:5
|
LL | type Foo<V> = impl Trait<V>;
| - this generic parameter must be used with a generic type parameter
@@ -7,6 +19,6 @@ LL | type Foo<V> = impl Trait<V>;
LL | ()
| ^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked-2.stderr b/tests/ui/type-alias-impl-trait/bounds-are-checked-2.stderr
index 8678e9b33..20e478160 100644
--- a/tests/ui/type-alias-impl-trait/bounds-are-checked-2.stderr
+++ b/tests/ui/type-alias-impl-trait/bounds-are-checked-2.stderr
@@ -9,6 +9,6 @@ help: consider restricting type parameter `T`
LL | type X<T: std::clone::Clone> = impl Clone;
| +++++++++++++++++++
-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/type-alias-impl-trait/bounds-are-checked.stderr b/tests/ui/type-alias-impl-trait/bounds-are-checked.stderr
index 962dedde0..ad1b9f19d 100644
--- a/tests/ui/type-alias-impl-trait/bounds-are-checked.stderr
+++ b/tests/ui/type-alias-impl-trait/bounds-are-checked.stderr
@@ -7,6 +7,6 @@ LL | type X<'a> = impl Into<&'static str> + From<&'a str>;
LL | t
| ^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs b/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs
new file mode 100644
index 000000000..5a9e87c09
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.rs
@@ -0,0 +1,16 @@
+#![feature(type_alias_impl_trait)]
+
+use std::fmt::{Debug, Display};
+
+struct Struct<V: Display>(Option<V>);
+
+// Make sure that, in contrast to type aliases without opaque types,
+// we actually do a wf check for the aliased type.
+type Foo<T: Debug> = (impl Debug, Struct<T>);
+//~^ ERROR: `T` doesn't implement `std::fmt::Display`
+
+fn foo<U: Debug + Display>() -> Foo<U> {
+ (Vec::<U>::new(), Struct(None))
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr
new file mode 100644
index 000000000..bca88b5fa
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr
@@ -0,0 +1,20 @@
+error[E0277]: `T` doesn't implement `std::fmt::Display`
+ --> $DIR/bounds-are-checked3.rs:9:35
+ |
+LL | type Foo<T: Debug> = (impl Debug, Struct<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 `Struct`
+ --> $DIR/bounds-are-checked3.rs:5:18
+ |
+LL | struct Struct<V: Display>(Option<V>);
+ | ^^^^^^^ required by this bound in `Struct`
+help: consider further restricting this bound
+ |
+LL | type Foo<T: Debug + std::fmt::Display> = (impl Debug, Struct<T>);
+ | +++++++++++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/bounds.rs b/tests/ui/type-alias-impl-trait/bounds.rs
new file mode 100644
index 000000000..dc05b70c5
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/bounds.rs
@@ -0,0 +1,16 @@
+#![feature(type_alias_impl_trait)]
+
+// check-pass
+
+use std::fmt::Debug;
+
+// No need to report the `type_alias_bounds` lint, as
+// the moment an opaque type is mentioned, we actually do check
+// type alias bounds.
+type Foo<T: Debug> = (impl Debug, usize);
+
+fn foo<U: Debug>() -> Foo<U> {
+ (Vec::<U>::new(), 1234)
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/broken_mir.rs b/tests/ui/type-alias-impl-trait/broken_mir.rs
new file mode 100644
index 000000000..b68e798fb
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/broken_mir.rs
@@ -0,0 +1,16 @@
+//! ICE: https://github.com/rust-lang/rust/issues/114121
+//! This test checks that MIR validation never constrains
+//! new hidden types that *differ* from the actual hidden types.
+//! This test used to ICE because oli-obk assumed mir validation
+//! was only ever run after opaque types were revealed in MIR.
+
+// compile-flags: -Zvalidate-mir
+// check-pass
+
+fn main() {
+ let _ = Some(()).into_iter().flat_map(|_| Some(()).into_iter().flat_map(func));
+}
+
+fn func(_: ()) -> impl Iterator<Item = ()> {
+ Some(()).into_iter().flat_map(|_| vec![])
+}
diff --git a/tests/ui/type-alias-impl-trait/closure_args.rs b/tests/ui/type-alias-impl-trait/closure_args.rs
index c5e7af81d..243f9cd6d 100644
--- a/tests/ui/type-alias-impl-trait/closure_args.rs
+++ b/tests/ui/type-alias-impl-trait/closure_args.rs
@@ -11,6 +11,13 @@ fn run<F: FnOnce(Input) -> ()>(f: F, i: Input) {
f(i);
}
-fn main() {
- run(|x: u32| {println!("{x}");}, 0);
+fn bop(_: Input) {
+ run(
+ |x: u32| {
+ println!("{x}");
+ },
+ 0,
+ );
}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/closure_args2.rs b/tests/ui/type-alias-impl-trait/closure_args2.rs
index 82386c280..1dd5c3e40 100644
--- a/tests/ui/type-alias-impl-trait/closure_args2.rs
+++ b/tests/ui/type-alias-impl-trait/closure_args2.rs
@@ -1,10 +1,12 @@
-// run-pass
+// check-pass
#![feature(type_alias_impl_trait)]
trait Foo {
// This was reachable in https://github.com/rust-lang/rust/issues/100800
- fn foo(&self) { unreachable!() }
+ fn foo(&self) {
+ unreachable!()
+ }
}
impl<T> Foo for T {}
@@ -14,10 +16,17 @@ impl B {
}
type Input = impl Foo;
-fn run1<F: FnOnce(Input)>(f: F, i: Input) {f(i)}
-fn run2<F: FnOnce(B)>(f: F, i: B) {f(i)}
+fn run1<F: FnOnce(Input)>(f: F, i: Input) {
+ f(i)
+}
+fn run2<F: FnOnce(B)>(f: F, i: B) {
+ f(i)
+}
-fn main() {
- run1(|x: B| {x.foo()}, B);
- run2(|x: B| {x.foo()}, B);
+fn bop() -> Input {
+ run1(|x: B| x.foo(), B);
+ run2(|x: B| x.foo(), B);
+ panic!()
}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs
index 3ff20d99a..7d8193b26 100644
--- a/tests/ui/type-alias-impl-trait/closure_parent_substs.rs
+++ b/tests/ui/type-alias-impl-trait/closure_parent_substs.rs
@@ -1,5 +1,5 @@
// When WF checking the hidden type in the ParamEnv of the opaque type,
-// one complication arises when the hidden type is a closure/generator:
+// one complication arises when the hidden type is a closure/coroutine:
// the "parent_substs" of the type may reference lifetime parameters
// not present in the opaque type.
// These region parameters are not really useful in this check.
diff --git a/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr b/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr
index ae6462bb6..3484485e3 100644
--- a/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr
+++ b/tests/ui/type-alias-impl-trait/closure_wf_outlives.stderr
@@ -46,14 +46,17 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/closure_wf_outlives.rs:54:22
|
LL | type Opaque<T> = impl Sized;
- | ^^^^^^^^^^ ...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...
|
note: ...that is required by this bound
--> $DIR/closure_wf_outlives.rs:59:12
|
LL | T: 'static,
| ^^^^^^^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | type Opaque<T: 'static> = impl Sized;
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/coherence.rs b/tests/ui/type-alias-impl-trait/coherence.rs
index 077a31494..1700c800e 100644
--- a/tests/ui/type-alias-impl-trait/coherence.rs
+++ b/tests/ui/type-alias-impl-trait/coherence.rs
@@ -11,7 +11,7 @@ fn use_alias<T>(val: T) -> AliasOfForeignType<T> {
foreign_crate::ForeignType(val)
}
-impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
+impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/coherence.stderr b/tests/ui/type-alias-impl-trait/coherence.stderr
index 00b0dbbb5..4462b70f7 100644
--- a/tests/ui/type-alias-impl-trait/coherence.stderr
+++ b/tests/ui/type-alias-impl-trait/coherence.stderr
@@ -1,14 +1,14 @@
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence.rs:14:1
|
-LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------
- | | |
- | | type alias impl trait is treated as if it were foreign, because its hidden type could be from a foreign crate
+LL | impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------
+ | | |
+ | | `AliasOfForeignType<()>` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0117`.
diff --git a/tests/ui/type-alias-impl-trait/coherence_cross_crate.stderr b/tests/ui/type-alias-impl-trait/coherence_cross_crate.stderr
index 63a3ce29c..893a27fac 100644
--- a/tests/ui/type-alias-impl-trait/coherence_cross_crate.stderr
+++ b/tests/ui/type-alias-impl-trait/coherence_cross_crate.stderr
@@ -8,6 +8,6 @@ LL | impl OtherTrait for i32 {}
|
= note: upstream crates may add a new impl of trait `coherence_cross_crate_trait_decl::SomeTrait` for type `i32` 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/type-alias-impl-trait/coherence_different_hidden_ty.rs b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs
new file mode 100644
index 000000000..39b3d535a
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.rs
@@ -0,0 +1,25 @@
+// When checking whether these two impls overlap, we could detect that we
+// would require the hidden type of `TAIT` to be equal to both `u32` and `i32`
+// and therefore accept them as disjoint. That is annoying to implement with
+// the current system because we would have to add the following to each
+// returning branch in coherence.
+//
+// let _ = infcx.take_opaque_types();
+//
+// @lcnr: Because of this I decided to not bother and cause this to fail instead.
+// In the future we can definitely modify the compiler to accept this
+// again.
+#![feature(type_alias_impl_trait)]
+
+trait Trait {}
+
+type TAIT = impl Sized;
+
+impl Trait for (TAIT, TAIT) {}
+
+impl Trait for (u32, i32) {}
+//~^ ERROR conflicting implementations of trait `Trait` for type `(TAIT, TAIT)`
+
+fn define() -> TAIT {}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr
new file mode 100644
index 000000000..ef170101b
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/coherence_different_hidden_ty.stderr
@@ -0,0 +1,12 @@
+error[E0119]: conflicting implementations of trait `Trait` for type `(TAIT, TAIT)`
+ --> $DIR/coherence_different_hidden_ty.rs:20:1
+ |
+LL | impl Trait for (TAIT, TAIT) {}
+ | --------------------------- first implementation here
+LL |
+LL | impl Trait for (u32, i32) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(TAIT, TAIT)`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/tests/ui/type-alias-impl-trait/coherence_generalization.rs b/tests/ui/type-alias-impl-trait/coherence_generalization.rs
index 5c9ad9498..1ec8877ea 100644
--- a/tests/ui/type-alias-impl-trait/coherence_generalization.rs
+++ b/tests/ui/type-alias-impl-trait/coherence_generalization.rs
@@ -1,5 +1,8 @@
// check-pass
+// FIXME(type_alias_impl_trait): What does this test? This needs a comment
+// explaining what we're worried about here.
+
#![feature(type_alias_impl_trait)]
trait Trait {}
type Opaque<T> = impl Sized;
@@ -7,7 +10,7 @@ fn foo<T>() -> Opaque<T> {
()
}
-impl<T, V> Trait for (T, V, V, u32) {}
-impl<U, V> Trait for (Opaque<U>, V, i32, V) {}
+impl<T, U, V> Trait for (T, U, V, V, u32) {}
+impl<U, V> Trait for (Opaque<U>, U, V, i32, V) {}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr b/tests/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr
index d5fc46cb1..948bd6dea 100644
--- a/tests/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr
+++ b/tests/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr
@@ -4,6 +4,6 @@ error[E0582]: binding for associated type `Output` references lifetime `'a`, whi
LL | type MalformedTy = dyn for<'a> Callable<Gal<&'a ()>, Output = &'a str>;
| ^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0582`.
diff --git a/tests/ui/type-alias-impl-trait/cross_inference.rs b/tests/ui/type-alias-impl-trait/cross_inference.rs
index dafaf40a6..c5ef75fee 100644
--- a/tests/ui/type-alias-impl-trait/cross_inference.rs
+++ b/tests/ui/type-alias-impl-trait/cross_inference.rs
@@ -1,10 +1,12 @@
+// revisions: current next
+//[next] compile-flags: -Znext-solver
// check-pass
#![feature(type_alias_impl_trait)]
fn main() {
- type T = impl Copy;
- let foo: T = (1u32, 2u32);
+ type Tait = impl Copy;
+ let foo: Tait = (1u32, 2u32);
let x: (_, _) = foo;
println!("{:?}", x);
}
diff --git a/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs b/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs
index 9a50c0f98..31fea42fa 100644
--- a/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs
+++ b/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs
@@ -1,5 +1,5 @@
// compile-flags: --edition=2021
-// check-pass
+// build-pass
#![feature(type_alias_impl_trait)]
fn main() {
diff --git a/tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs b/tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs
new file mode 100644
index 000000000..44158349f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs
@@ -0,0 +1,12 @@
+// compile-flags: --crate-type=lib -Cdebuginfo=2
+// build-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Debuggable = impl core::fmt::Debug;
+
+static mut TEST: Option<Debuggable> = None;
+
+fn foo() -> Debuggable {
+ 0u32
+}
diff --git a/tests/ui/type-alias-impl-trait/declared_but_never_defined.stderr b/tests/ui/type-alias-impl-trait/declared_but_never_defined.stderr
index 60bc24320..772f487d9 100644
--- a/tests/ui/type-alias-impl-trait/declared_but_never_defined.stderr
+++ b/tests/ui/type-alias-impl-trait/declared_but_never_defined.stderr
@@ -6,5 +6,5 @@ LL | type Bar = impl std::fmt::Debug;
|
= note: `Bar` must be used in combination with a concrete type within the same module
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr b/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr
index fbfa0ccf1..d60f1ffbc 100644
--- a/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr
+++ b/tests/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr
@@ -19,6 +19,11 @@ LL | ""
|
= note: expected opaque type `Boo`
found reference `&'static str`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/declared_but_not_defined_in_scope.rs:10:4
+ |
+LL | fn bomp() -> boo::Boo {
+ | ^^^^
error: aborting due to 2 previous errors
diff --git a/tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs b/tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs
new file mode 100644
index 000000000..5a421ea1d
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/defined-by-user-annotation.rs
@@ -0,0 +1,19 @@
+// User type annotation in fn bodies is a a valid defining site for opaque types.
+// check-pass
+#![feature(type_alias_impl_trait)]
+
+trait Equate { type Proj; }
+impl<T> Equate for T { type Proj = T; }
+
+trait Indirect { type Ty; }
+impl<A, B: Equate<Proj = A>> Indirect for (A, B) { type Ty = (); }
+
+type Opq = impl Sized;
+fn define_1(_: Opq) {
+ let _ = None::<<(Opq, u8) as Indirect>::Ty>;
+}
+fn define_2() -> Opq {
+ 0u8
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/defining-use-submodule.rs b/tests/ui/type-alias-impl-trait/defining-use-submodule.rs
index 8b51f5571..4d84b2cbb 100644
--- a/tests/ui/type-alias-impl-trait/defining-use-submodule.rs
+++ b/tests/ui/type-alias-impl-trait/defining-use-submodule.rs
@@ -11,12 +11,12 @@ type Foo = impl std::fmt::Display;
type Bar = impl std::fmt::Display;
mod foo {
- pub fn foo() -> super::Foo {
+ pub(crate) fn foo() -> super::Foo {
"foo"
}
- pub mod bar {
- pub fn bar() -> crate::Bar {
+ pub(crate) mod bar {
+ pub(crate) fn bar() -> crate::Bar {
1
}
}
diff --git a/tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs b/tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs
new file mode 100644
index 000000000..7c2d68cce
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs
@@ -0,0 +1,19 @@
+// build-pass
+// edition: 2021
+
+#![feature(type_alias_impl_trait)]
+
+pub struct Foo {
+ /// This type must have nontrivial drop glue
+ field: String,
+}
+
+pub type Tait = impl Sized;
+
+pub async fn ice_cold(beverage: Tait) {
+ // Must destructure at least one field of `Foo`
+ let Foo { field } = beverage;
+ _ = field;
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs b/tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs
new file mode 100644
index 000000000..8568b26be
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs
@@ -0,0 +1,23 @@
+// build-pass
+// edition: 2021
+
+#![feature(type_alias_impl_trait)]
+
+fn foo<T>(x: T) {
+ type Opaque<T> = impl Sized;
+ let foo: Opaque<T> = (x,);
+ let (a,): (T,) = foo;
+}
+
+const fn bar<T: Copy>(x: T) {
+ type Opaque<T: Copy> = impl Copy;
+ let foo: Opaque<T> = (x, 2u32);
+ let (a, b): (T, u32) = foo;
+}
+
+fn main() {
+ foo::<u32>(1);
+ bar::<u32>(1);
+ const CONST: () = bar::<u32>(42u32);
+ CONST
+}
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses.stderr
index a8b4cd7af..9e6169b2a 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses.stderr
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses.stderr
@@ -10,5 +10,5 @@ note: previous use here
LL | ""
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs
index e5bfbfdae..b2842df15 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.rs
@@ -2,7 +2,7 @@
type Tait<'a> = impl Sized + 'a;
-fn foo<'a, 'b>() {
+fn foo<'a, 'b>() -> Tait<'a> {
if false {
if { return } {
let y: Tait<'b> = 1i32;
@@ -10,6 +10,7 @@ fn foo<'a, 'b>() {
}
}
let x: Tait<'a> = ();
+ x
}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr
index f2eb7bc4d..e5cee49cf 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-2.stderr
@@ -5,10 +5,10 @@ LL | let y: Tait<'b> = 1i32;
| ^^^^ expected `()`, got `i32`
|
note: previous use here
- --> $DIR/different_defining_uses_never_type-2.rs:12:23
+ --> $DIR/different_defining_uses_never_type-2.rs:7:14
|
-LL | let x: Tait<'a> = ();
- | ^^
+LL | if { return } {
+ | ^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs
index 2b30a9cd5..a4ac27378 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.rs
@@ -2,7 +2,7 @@
type Tait<T> = impl Sized;
-fn foo<T, U>() {
+fn foo<T, U>() -> Tait<T> {
if false {
if { return } {
let y: Tait<U> = 1i32;
@@ -10,6 +10,7 @@ fn foo<T, U>() {
}
}
let x: Tait<T> = ();
+ x
}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr
index 8fc2e2284..0fdcb81f6 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type-3.stderr
@@ -10,5 +10,5 @@ note: previous use here
LL | let x: Tait<T> = ();
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
index 09dadb0af..2a77eb4c4 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
@@ -10,5 +10,5 @@ note: previous use here
LL | ""
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr
index 146a57cbb..abf4a0d24 100644
--- a/tests/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr
+++ b/tests/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr
@@ -10,5 +10,5 @@ note: previous use here
LL | fn one() -> Tait { One }
| ^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs
index 5f75fdc71..4f424b8c6 100644
--- a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs
+++ b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs
@@ -1,11 +1,7 @@
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]
-pub trait Captures<'a> {}
-
-impl<'a, T: ?Sized> Captures<'a> for T {}
-
-type OneLifetime<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
+type OneLifetime<'a, 'b> = impl std::fmt::Debug;
fn foo<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> {
a
diff --git a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr
index 546598e8a..07ba17ad2 100644
--- a/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr
+++ b/tests/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr
@@ -1,14 +1,14 @@
error: concrete type differs from previous defining opaque type use
- --> $DIR/different_lifetimes_defining_uses.rs:15:5
+ --> $DIR/different_lifetimes_defining_uses.rs:11:5
|
LL | b
| ^ expected `&'a u32`, got `&'b u32`
|
note: previous use here
- --> $DIR/different_lifetimes_defining_uses.rs:11:5
+ --> $DIR/different_lifetimes_defining_uses.rs:7:5
|
LL | a
| ^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs b/tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs
new file mode 100644
index 000000000..51d287049
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/drop-shim-relates-opaque-issue-114375.rs
@@ -0,0 +1,10 @@
+// aux-build:drop-shim-relates-opaque-aux.rs
+// compile-flags: -Zvalidate-mir --crate-type=lib
+// build-pass
+
+extern crate drop_shim_relates_opaque_aux;
+
+pub fn drop_foo(_: drop_shim_relates_opaque_aux::Foo) {}
+pub fn drop_bar(_: drop_shim_relates_opaque_aux::Bar) {}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs
new file mode 100644
index 000000000..4c56fe2d1
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs
@@ -0,0 +1,13 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Opaque<'lt> = impl Sized + 'lt;
+
+fn test<'a>(
+ arg: impl Iterator<Item = &'a u8>,
+) -> impl Iterator<Item = Opaque<'a>> {
+ arg
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs
new file mode 100644
index 000000000..97f8c799f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs
@@ -0,0 +1,15 @@
+// check-pass
+// edition: 2021
+
+#![feature(type_alias_impl_trait)]
+
+struct Foo<'a>(&'a ());
+
+impl<'a> Foo<'a> {
+ async fn new() -> () {
+ type T = impl Sized;
+ let _: T = ();
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/escaping-bound-var.rs b/tests/ui/type-alias-impl-trait/escaping-bound-var.rs
new file mode 100644
index 000000000..bf27e76db
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/escaping-bound-var.rs
@@ -0,0 +1,22 @@
+#![feature(type_alias_impl_trait)]
+
+pub trait Trait<'a> {
+ type Assoc;
+}
+
+trait Test<'a> {}
+
+pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
+//~^ ERROR cannot capture late-bound lifetime in type alias impl trait
+
+impl Trait<'_> for () {
+ type Assoc = ();
+}
+
+impl Test<'_> for () {}
+
+fn constrain() -> Foo {
+ ()
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr b/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr
new file mode 100644
index 000000000..7dce067d3
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr
@@ -0,0 +1,8 @@
+error: cannot capture late-bound lifetime in type alias impl trait
+ --> $DIR/escaping-bound-var.rs:9:57
+ |
+LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
+ | -- lifetime defined here ^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/fallback.stderr b/tests/ui/type-alias-impl-trait/fallback.stderr
index e767bfdb0..5250252a0 100644
--- a/tests/ui/type-alias-impl-trait/fallback.stderr
+++ b/tests/ui/type-alias-impl-trait/fallback.stderr
@@ -12,6 +12,6 @@ help: consider specifying the generic argument
LL | Wrapper::<T>::Second
| +++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/type-alias-impl-trait/future.stderr b/tests/ui/type-alias-impl-trait/future.stderr
index 7e76c120a..b20073fcd 100644
--- a/tests/ui/type-alias-impl-trait/future.stderr
+++ b/tests/ui/type-alias-impl-trait/future.stderr
@@ -14,6 +14,6 @@ help: consider restricting type parameter `B`
LL | type FooFuture<B: Bar> = impl Future<Output = ()>;
| +++++
-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/type-alias-impl-trait/generic_different_defining_uses.stderr b/tests/ui/type-alias-impl-trait/generic_different_defining_uses.stderr
index 47ac33462..72271d158 100644
--- a/tests/ui/type-alias-impl-trait/generic_different_defining_uses.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_different_defining_uses.stderr
@@ -10,5 +10,5 @@ note: previous use here
LL | std::iter::once(t)
| ^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs
index 9d938a616..169d4f8d5 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs
@@ -2,13 +2,10 @@
fn main() {}
-pub trait Captures<'a> {}
-
-impl<'a, T: ?Sized> Captures<'a> for T {}
-
-type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
+type Two<'a, 'b> = impl std::fmt::Debug;
fn one<'a>(t: &'a ()) -> Two<'a, 'a> {
+ //~^ ERROR non-defining opaque type use
t
//~^ ERROR non-defining opaque type use
}
diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr
index 72e1ef4b4..b03bf2466 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr
@@ -1,14 +1,26 @@
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_lifetime_param.rs:12:5
+ --> $DIR/generic_duplicate_lifetime_param.rs:7:26
+ |
+LL | fn one<'a>(t: &'a ()) -> Two<'a, 'a> {
+ | ^^^^^^^^^^^ generic argument `'a` used twice
+ |
+note: for this opaque type
+ --> $DIR/generic_duplicate_lifetime_param.rs:5:20
+ |
+LL | type Two<'a, 'b> = impl std::fmt::Debug;
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error: non-defining opaque type use in defining scope
+ --> $DIR/generic_duplicate_lifetime_param.rs:9:5
|
LL | t
| ^
|
note: lifetime used multiple times
- --> $DIR/generic_duplicate_lifetime_param.rs:9:10
+ --> $DIR/generic_duplicate_lifetime_param.rs:5:10
|
-LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
+LL | type Two<'a, 'b> = impl std::fmt::Debug;
| ^^ ^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
index 80462f8ac..e3c6f4d87 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
@@ -1,5 +1,12 @@
#![feature(type_alias_impl_trait)]
+//! This test checks various cases where we are using the same
+//! generic parameter twice in the parameter list of a TAIT.
+//! Within defining scopes that is not legal, because the hidden type
+//! is not fully defined then. This could cause us to have a TAIT
+//! that doesn't have a hidden type for all possible combinations of generic
+//! parameters passed to it.
+
use std::fmt::Debug;
fn main() {}
@@ -7,27 +14,24 @@ fn main() {}
// test that unused generic parameters are ok
type TwoTys<T, U> = impl Debug;
-
-pub trait Captures<'a> {}
-
-impl<'a, T: ?Sized> Captures<'a> for T {}
-
-type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>;
+type TwoLifetimes<'a, 'b> = impl Debug;
type TwoConsts<const X: usize, const Y: usize> = impl Debug;
-
fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> {
+ //~^ ERROR non-defining opaque type use in defining scope
t
//~^ ERROR non-defining opaque type use in defining scope
}
fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> {
+ //~^ ERROR non-defining opaque type use in defining scope
t
//~^ ERROR non-defining opaque type use in defining scope
}
fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> {
+ //~^ ERROR non-defining opaque type use in defining scope
t
//~^ ERROR non-defining opaque type use in defining scope
}
diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
index 98e4bfea1..495308a6c 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
@@ -1,38 +1,74 @@
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:21:5
+ --> $DIR/generic_duplicate_param_use.rs:21:30
+ |
+LL | fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> {
+ | ^^^^^^^^^^^^ generic argument `T` used twice
+ |
+note: for this opaque type
+ --> $DIR/generic_duplicate_param_use.rs:15:21
+ |
+LL | type TwoTys<T, U> = impl Debug;
+ | ^^^^^^^^^^
+
+error: non-defining opaque type use in defining scope
+ --> $DIR/generic_duplicate_param_use.rs:23:5
|
LL | t
| ^
|
note: type used multiple times
- --> $DIR/generic_duplicate_param_use.rs:8:13
+ --> $DIR/generic_duplicate_param_use.rs:15:13
|
LL | type TwoTys<T, U> = impl Debug;
| ^ ^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:26:5
+ --> $DIR/generic_duplicate_param_use.rs:27:36
+ |
+LL | fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> {
+ | ^^^^^^^^^^^^^^^^^^^^ generic argument `'a` used twice
+ |
+note: for this opaque type
+ --> $DIR/generic_duplicate_param_use.rs:17:29
+ |
+LL | type TwoLifetimes<'a, 'b> = impl Debug;
+ | ^^^^^^^^^^
+
+error: non-defining opaque type use in defining scope
+ --> $DIR/generic_duplicate_param_use.rs:29:5
|
LL | t
| ^
|
note: lifetime used multiple times
- --> $DIR/generic_duplicate_param_use.rs:15:19
+ --> $DIR/generic_duplicate_param_use.rs:17:19
|
-LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>;
+LL | type TwoLifetimes<'a, 'b> = impl Debug;
| ^^ ^^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:31:5
+ --> $DIR/generic_duplicate_param_use.rs:33:50
+ |
+LL | fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> {
+ | ^^^^^^^^^^^^^^^ generic argument `N` used twice
+ |
+note: for this opaque type
+ --> $DIR/generic_duplicate_param_use.rs:19:50
+ |
+LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug;
+ | ^^^^^^^^^^
+
+error: non-defining opaque type use in defining scope
+ --> $DIR/generic_duplicate_param_use.rs:35:5
|
LL | t
| ^
|
note: constant used multiple times
- --> $DIR/generic_duplicate_param_use.rs:17:16
+ --> $DIR/generic_duplicate_param_use.rs:19:16
|
LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug;
| ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
-error: aborting due to 3 previous errors
+error: aborting due to 6 previous errors
diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr
index 3dbfff745..d2d6380b6 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr
@@ -9,6 +9,6 @@ help: consider restricting type parameter `T`
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
| +++++++++++++++++
-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/type-alias-impl-trait/generic_duplicate_param_use4.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr
index 21a5369d9..2338dbd52 100644
--- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr
@@ -9,6 +9,6 @@ help: consider restricting type parameter `U`
LL | type Two<T, U: std::fmt::Debug> = impl Debug;
| +++++++++++++++++
-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/type-alias-impl-trait/generic_lifetime_param.rs b/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs
index 106efefba..e109c38c9 100644
--- a/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs
+++ b/tests/ui/type-alias-impl-trait/generic_lifetime_param.rs
@@ -1,11 +1,10 @@
-// check-pass
+// build-pass (FIXME(62277): could be check-pass?)
#![feature(type_alias_impl_trait)]
fn main() {}
-type Region<'a> = impl std::fmt::Debug + 'a;
-
+type Region<'a> = impl std::fmt::Debug;
fn region<'b>(a: &'b ()) -> Region<'b> {
a
diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs b/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs
index e7b8567b9..68f4c6923 100644
--- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs
+++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs
@@ -13,16 +13,19 @@ type OneConst<const X: usize> = impl Debug;
// Not defining uses, because they doesn't define *all* possible generics.
fn concrete_ty() -> OneTy<u32> {
+ //~^ ERROR: non-defining opaque type use in defining scope
5u32
- //~^ ERROR expected generic type parameter, found `u32`
+ //~^ ERROR: expected generic type parameter, found `u32`
}
fn concrete_lifetime() -> OneLifetime<'static> {
+ //~^ ERROR: non-defining opaque type use in defining scope
6u32
- //~^ ERROR expected generic lifetime parameter, found `'static`
+ //~^ ERROR: expected generic lifetime parameter, found `'static`
}
fn concrete_const() -> OneConst<{ 123 }> {
+ //~^ ERROR: non-defining opaque type use in defining scope
7u32
- //~^ ERROR expected generic constant parameter, found `123`
+ //~^ ERROR: expected generic constant parameter, found `123`
}
diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
index 966fe823f..e3b7b1a76 100644
--- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr
@@ -1,5 +1,17 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/generic_nondefining_use.rs:15:21
+ |
+LL | fn concrete_ty() -> OneTy<u32> {
+ | ^^^^^^^^^^ argument `u32` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/generic_nondefining_use.rs:7:17
+ |
+LL | type OneTy<T> = impl Debug;
+ | ^^^^^^^^^^
+
error[E0792]: expected generic type parameter, found `u32`
- --> $DIR/generic_nondefining_use.rs:16:5
+ --> $DIR/generic_nondefining_use.rs:17:5
|
LL | type OneTy<T> = impl Debug;
| - this generic parameter must be used with a generic type parameter
@@ -7,8 +19,20 @@ LL | type OneTy<T> = impl Debug;
LL | 5u32
| ^^^^
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/generic_nondefining_use.rs:21:27
+ |
+LL | fn concrete_lifetime() -> OneLifetime<'static> {
+ | ^^^^^^^^^^^^^^^^^^^^ argument `'static` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/generic_nondefining_use.rs:9:24
+ |
+LL | type OneLifetime<'a> = impl Debug;
+ | ^^^^^^^^^^
+
error[E0792]: expected generic lifetime parameter, found `'static`
- --> $DIR/generic_nondefining_use.rs:21:5
+ --> $DIR/generic_nondefining_use.rs:23:5
|
LL | type OneLifetime<'a> = impl Debug;
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
@@ -16,8 +40,20 @@ LL | type OneLifetime<'a> = impl Debug;
LL | 6u32
| ^^^^
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/generic_nondefining_use.rs:27:24
+ |
+LL | fn concrete_const() -> OneConst<{ 123 }> {
+ | ^^^^^^^^^^^^^^^^^ argument `123` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/generic_nondefining_use.rs:11:33
+ |
+LL | type OneConst<const X: usize> = impl Debug;
+ | ^^^^^^^^^^
+
error[E0792]: expected generic constant parameter, found `123`
- --> $DIR/generic_nondefining_use.rs:26:5
+ --> $DIR/generic_nondefining_use.rs:29:5
|
LL | type OneConst<const X: usize> = impl Debug;
| -------------- this generic parameter must be used with a generic constant parameter
@@ -25,6 +61,6 @@ LL | type OneConst<const X: usize> = impl Debug;
LL | 7u32
| ^^^^
-error: aborting due to 3 previous errors
+error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs
index cdd8f6f19..c60f5c11c 100644
--- a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs
+++ b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs
@@ -5,12 +5,12 @@ fn main() {
let x = wrong_generic(&y);
let z: i32 = x;
//~^ ERROR expected generic type parameter, found `&i32`
-}
-type WrongGeneric<T> = impl 'static;
-//~^ ERROR: at least one trait must be specified
+ type WrongGeneric<T> = impl 'static;
+ //~^ ERROR: at least one trait must be specified
-fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
- t
- //~^ ERROR the parameter type `T` may not live long enough
+ fn wrong_generic<T>(t: T) -> WrongGeneric<T> {
+ t
+ //~^ ERROR the parameter type `T` may not live long enough
+ }
}
diff --git a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
index fa79e51e9..c352a33fb 100644
--- a/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
@@ -1,8 +1,8 @@
error: at least one trait must be specified
- --> $DIR/generic_type_does_not_live_long_enough.rs:10:24
+ --> $DIR/generic_type_does_not_live_long_enough.rs:9:28
|
-LL | type WrongGeneric<T> = impl 'static;
- | ^^^^^^^^^^^^
+LL | type WrongGeneric<T> = impl 'static;
+ | ^^^^^^^^^^^^
error[E0792]: expected generic type parameter, found `&i32`
--> $DIR/generic_type_does_not_live_long_enough.rs:6:18
@@ -10,19 +10,22 @@ error[E0792]: expected generic type parameter, found `&i32`
LL | let z: i32 = x;
| ^
...
-LL | type WrongGeneric<T> = impl 'static;
- | - this generic parameter must be used with a generic type parameter
+LL | type WrongGeneric<T> = impl 'static;
+ | - this generic parameter must be used with a generic type parameter
error[E0310]: the parameter type `T` may not live long enough
- --> $DIR/generic_type_does_not_live_long_enough.rs:14:5
+ --> $DIR/generic_type_does_not_live_long_enough.rs:13:9
|
-LL | t
- | ^ ...so that the type `T` will meet its required lifetime bounds
+LL | t
+ | ^
+ | |
+ | 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 wrong_generic<T: 'static>(t: T) -> WrongGeneric<T> {
- | +++++++++
+LL | fn wrong_generic<T: 'static>(t: T) -> WrongGeneric<T> {
+ | +++++++++
error: aborting due to 3 previous errors
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.rs b/tests/ui/type-alias-impl-trait/generic_underconstrained.rs
index d87a25aad..1acacc778 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained.rs
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.rs
@@ -8,5 +8,6 @@ type Underconstrained<T: Trait> = impl Send;
// no `Trait` bound
fn underconstrain<T>(_: T) -> Underconstrained<T> {
//~^ ERROR the trait bound `T: Trait`
+ //~| ERROR the trait bound `T: Trait`
unimplemented!()
}
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr
index c73288329..88529b370 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained.stderr
@@ -4,16 +4,37 @@ error[E0277]: the trait bound `T: Trait` is not satisfied
LL | fn underconstrain<T>(_: T) -> Underconstrained<T> {
| ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
|
-note: required by a bound in `Underconstrained`
+note: required by a bound on the type alias `Underconstrained`
--> $DIR/generic_underconstrained.rs:6:26
|
LL | type Underconstrained<T: Trait> = impl Send;
- | ^^^^^ required by this bound in `Underconstrained`
+ | ^^^^^ required by this bound
help: consider restricting type parameter `T`
|
LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
| +++++++
-error: aborting due to previous error
+error[E0277]: the trait bound `T: Trait` is not satisfied
+ --> $DIR/generic_underconstrained.rs:9:51
+ |
+LL | fn underconstrain<T>(_: T) -> Underconstrained<T> {
+ | ___________________________________________________^
+LL | |
+LL | |
+LL | | unimplemented!()
+LL | | }
+ | |_^ the trait `Trait` is not implemented for `T`
+ |
+note: required by a bound on the type alias `Underconstrained`
+ --> $DIR/generic_underconstrained.rs:6:26
+ |
+LL | type Underconstrained<T: Trait> = impl Send;
+ | ^^^^^ required by this bound
+help: consider restricting type parameter `T`
+ |
+LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
+ | +++++++
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs b/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs
index 8adc0bf32..1e1bece9a 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.rs
@@ -7,6 +7,7 @@ type Underconstrained<T: std::fmt::Debug> = impl Send;
// not a defining use, because it doesn't define *all* possible generics
fn underconstrained<U>(_: U) -> Underconstrained<U> {
//~^ ERROR `U` doesn't implement `Debug`
+ //~| ERROR `U` doesn't implement `Debug`
5u32
}
@@ -15,5 +16,6 @@ type Underconstrained2<T: std::fmt::Debug> = impl Send;
// not a defining use, because it doesn't define *all* possible generics
fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
//~^ ERROR `V` doesn't implement `Debug`
+ //~| ERROR `V` doesn't implement `Debug`
5u32
}
diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr
index d77d978aa..b3b9cbca9 100644
--- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr
+++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr
@@ -4,32 +4,74 @@ error[E0277]: `U` doesn't implement `Debug`
LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
| ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
-note: required by a bound in `Underconstrained`
+note: required by a bound on the type alias `Underconstrained`
--> $DIR/generic_underconstrained2.rs:5:26
|
LL | type Underconstrained<T: std::fmt::Debug> = impl Send;
- | ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained`
+ | ^^^^^^^^^^^^^^^ required by this bound
help: consider restricting type parameter `U`
|
LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
| +++++++++++++++++
error[E0277]: `V` doesn't implement `Debug`
- --> $DIR/generic_underconstrained2.rs:16:43
+ --> $DIR/generic_underconstrained2.rs:17:43
|
LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
| ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
-note: required by a bound in `Underconstrained2`
- --> $DIR/generic_underconstrained2.rs:13:27
+note: required by a bound on the type alias `Underconstrained2`
+ --> $DIR/generic_underconstrained2.rs:14:27
|
LL | type Underconstrained2<T: std::fmt::Debug> = impl Send;
- | ^^^^^^^^^^^^^^^ required by this bound in `Underconstrained2`
+ | ^^^^^^^^^^^^^^^ required by this bound
help: consider restricting type parameter `V`
|
LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
| +++++++++++++++++
-error: aborting due to 2 previous errors
+error[E0277]: `U` doesn't implement `Debug`
+ --> $DIR/generic_underconstrained2.rs:8:53
+ |
+LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
+ | _____________________________________________________^
+LL | |
+LL | |
+LL | | 5u32
+LL | | }
+ | |_^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ |
+note: required by a bound on the type alias `Underconstrained`
+ --> $DIR/generic_underconstrained2.rs:5:26
+ |
+LL | type Underconstrained<T: std::fmt::Debug> = impl Send;
+ | ^^^^^^^^^^^^^^^ required by this bound
+help: consider restricting type parameter `U`
+ |
+LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
+ | +++++++++++++++++
+
+error[E0277]: `V` doesn't implement `Debug`
+ --> $DIR/generic_underconstrained2.rs:17:64
+ |
+LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
+ | ________________________________________________________________^
+LL | |
+LL | |
+LL | | 5u32
+LL | | }
+ | |_^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
+ |
+note: required by a bound on the type alias `Underconstrained2`
+ --> $DIR/generic_underconstrained2.rs:14:27
+ |
+LL | type Underconstrained2<T: std::fmt::Debug> = impl Send;
+ | ^^^^^^^^^^^^^^^ required by this bound
+help: consider restricting type parameter `V`
+ |
+LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
+ | +++++++++++++++++
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs
new file mode 100644
index 000000000..eb19b49c7
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.rs
@@ -0,0 +1,28 @@
+//! This test shows that a field type that is a projection that resolves to an opaque,
+//! is not a defining use. While we could substitute the struct generics, that would
+//! mean we would have to walk all substitutions of an `Foo`, which can quickly
+//! degenerate into looking at an exponential number of types depending on the complexity
+//! of a program.
+
+#![feature(impl_trait_in_assoc_type)]
+
+struct Bar;
+
+trait Trait: Sized {
+ type Assoc;
+ fn foo() -> Foo<Self>;
+}
+
+impl Trait for Bar {
+ type Assoc = impl std::fmt::Debug;
+ fn foo() -> Foo<Bar> {
+ Foo { field: () }
+ //~^ ERROR: mismatched types
+ }
+}
+
+struct Foo<T: Trait> {
+ field: <T as Trait>::Assoc,
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr
new file mode 100644
index 000000000..00aedfae4
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_behind_projection_behind_struct_field.stderr
@@ -0,0 +1,20 @@
+error[E0308]: mismatched types
+ --> $DIR/hidden_behind_projection_behind_struct_field.rs:19:22
+ |
+LL | type Assoc = impl std::fmt::Debug;
+ | -------------------- the expected opaque type
+LL | fn foo() -> Foo<Bar> {
+LL | Foo { field: () }
+ | ^^ expected opaque type, found `()`
+ |
+ = note: expected opaque type `<Bar as Trait>::Assoc`
+ found unit type `()`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/hidden_behind_projection_behind_struct_field.rs:18:8
+ |
+LL | fn foo() -> Foo<Bar> {
+ | ^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs
new file mode 100644
index 000000000..58778702d
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field.rs
@@ -0,0 +1,30 @@
+//! This test shows that the appearance of an opaque type
+//! in the substs of a struct are enough to make it count
+//! for making the function a defining use. It doesn't matter
+//! if the opaque type is actually used in the field.
+
+#![feature(impl_trait_in_assoc_type)]
+// check-pass
+
+use std::marker::PhantomData;
+
+struct Bar;
+
+trait Trait: Sized {
+ type Assoc;
+ fn foo() -> Foo<Self::Assoc>;
+}
+
+impl Trait for Bar {
+ type Assoc = impl std::fmt::Debug;
+ fn foo() -> Foo<Self::Assoc> {
+ let foo: Foo<()> = Foo { field: PhantomData };
+ foo
+ }
+}
+
+struct Foo<T> {
+ field: PhantomData<T>,
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs
new file mode 100644
index 000000000..e440dce5e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs
@@ -0,0 +1,26 @@
+//! This test shows that we can even follow projections
+//! into associated types of the same impl if they are
+//! indirectly mentioned in a struct field.
+
+#![feature(impl_trait_in_assoc_type)]
+// check-pass
+
+struct Bar;
+
+trait Trait: Sized {
+ type Assoc;
+ fn foo() -> Foo;
+}
+
+impl Trait for Bar {
+ type Assoc = impl std::fmt::Debug;
+ fn foo() -> Foo {
+ Foo { field: () }
+ }
+}
+
+struct Foo {
+ field: <Bar as Trait>::Assoc,
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
new file mode 100644
index 000000000..12ce6b14e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs
@@ -0,0 +1,57 @@
+//! This test checks that we don't lose hidden types
+//! for *other* opaque types that we register and use
+//! to prove bounds while checking that a hidden type
+//! satisfies its opaque type's bounds.
+
+#![feature(trivial_bounds, type_alias_impl_trait)]
+#![allow(trivial_bounds)]
+
+mod sus {
+ use super::*;
+ pub type Sep = impl Sized + std::fmt::Display;
+ //~^ ERROR: concrete type differs from previous defining opaque type use
+ pub fn mk_sep() -> Sep {
+ String::from("hello")
+ }
+
+ pub trait Proj {
+ type Assoc;
+ }
+ impl Proj for () {
+ type Assoc = sus::Sep;
+ }
+
+ pub struct Bar<T: Proj> {
+ pub inner: <T as Proj>::Assoc,
+ pub _marker: T,
+ }
+ impl<T: Proj> Clone for Bar<T> {
+ fn clone(&self) -> Self {
+ todo!()
+ }
+ }
+ impl<T: Proj<Assoc = i32> + Copy> Copy for Bar<T> {}
+ // This allows producing `Tait`s via `From`, even though
+ // `define_tait` is not actually callable, and thus assumed
+ // `Bar<()>: Copy` even though it isn't.
+ pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>;
+ pub fn define_tait() -> Tait
+ where
+ // this proves `Bar<()>: Copy`, but `define_tait` is
+ // now uncallable
+ (): Proj<Assoc = i32>,
+ {
+ Bar { inner: 1i32, _marker: () }
+ }
+}
+
+fn copy_tait(x: sus::Tait) -> (sus::Tait, sus::Tait) {
+ (x, x)
+}
+
+fn main() {
+ let bar = sus::Bar { inner: sus::mk_sep(), _marker: () };
+ let (y, z) = copy_tait(bar.into()); // copy a string
+ drop(y.into()); // drop one instance
+ println!("{}", z.into().inner); // print the other
+}
diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
new file mode 100644
index 000000000..5a6998f41
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/hidden_type_mismatch.rs:11:20
+ |
+LL | pub type Sep = impl Sized + std::fmt::Display;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `String`
+ |
+note: previous use here
+ --> $DIR/hidden_type_mismatch.rs:37:21
+ |
+LL | pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params.rs
new file mode 100644
index 000000000..db1a3a1c7
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params.rs
@@ -0,0 +1,28 @@
+//! This test checks that walking into binders
+//! during opaque type collection does not ICE or raise errors.
+
+// edition: 2021
+
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+trait B {
+ type C;
+}
+
+struct A;
+
+impl<'a> B for &'a A {
+ type C = ();
+}
+
+struct Terminator;
+
+type Successors<'a> = impl std::fmt::Debug + 'a;
+
+impl Terminator {
+ fn successors(&self, _: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {}
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs
new file mode 100644
index 000000000..f011e5b21
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params2.rs
@@ -0,0 +1,35 @@
+//! This test checks the behaviour of walking into binders
+//! and normalizing something behind them actually works.
+
+// edition: 2021
+
+#![feature(type_alias_impl_trait)]
+
+trait B {
+ type C;
+}
+
+struct A;
+
+impl<'a> B for &'a A {
+ type C = Tait;
+}
+
+type Tait = impl std::fmt::Debug;
+
+struct Terminator;
+
+type Successors<'a> = impl std::fmt::Debug + 'a;
+
+impl Terminator {
+ fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
+ f = g;
+ //~^ ERROR item constrains opaque type that is not in its signature
+ }
+}
+
+fn g(_: &()) -> String {
+ String::new()
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr
new file mode 100644
index 000000000..e037dede2
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params2.stderr
@@ -0,0 +1,15 @@
+error: item constrains opaque type that is not in its signature
+ --> $DIR/higher_kinded_params2.rs:26:13
+ |
+LL | f = g;
+ | ^
+ |
+ = note: this item must mention the opaque type in its signature in order to be able to register hidden types
+note: this item must mention the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/higher_kinded_params2.rs:25:8
+ |
+LL | fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
+ | ^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs
new file mode 100644
index 000000000..6edfccaf7
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.rs
@@ -0,0 +1,36 @@
+//! This test checks that we can't actually have an opaque type behind
+//! a binder that references variables from that binder.
+
+// edition: 2021
+
+#![feature(type_alias_impl_trait)]
+
+trait B {
+ type C;
+}
+
+struct A;
+
+impl<'a> B for &'a A {
+ type C = Tait<'a>;
+}
+
+type Tait<'a> = impl std::fmt::Debug + 'a;
+
+struct Terminator;
+
+type Successors<'a> = impl std::fmt::Debug + 'a;
+
+impl Terminator {
+ fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
+ f = g;
+ //~^ ERROR mismatched types
+ //~| ERROR item constrains opaque type that is not in its signature
+ }
+}
+
+fn g(x: &()) -> &() {
+ x
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr
new file mode 100644
index 000000000..14372d8f3
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/higher_kinded_params3.stderr
@@ -0,0 +1,28 @@
+error: item constrains opaque type that is not in its signature
+ --> $DIR/higher_kinded_params3.rs:26:13
+ |
+LL | f = g;
+ | ^
+ |
+ = note: this item must mention the opaque type in its signature in order to be able to register hidden types
+note: this item must mention the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/higher_kinded_params3.rs:25:8
+ |
+LL | fn successors(&self, mut f: for<'x> fn(&'x ()) -> <&'x A as B>::C) -> Successors<'_> {
+ | ^^^^^^^^^^
+
+error[E0308]: mismatched types
+ --> $DIR/higher_kinded_params3.rs:26:9
+ |
+LL | type Tait<'a> = impl std::fmt::Debug + 'a;
+ | ------------------------- the expected opaque type
+...
+LL | f = g;
+ | ^^^^^ one type is more general than the other
+ |
+ = note: expected fn pointer `for<'x> fn(&'x ()) -> Tait<'x>`
+ found fn pointer `for<'a> fn(&'a ()) -> &'a ()`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs
new file mode 100644
index 000000000..a3f65146f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.rs
@@ -0,0 +1,28 @@
+#![feature(impl_trait_in_assoc_type)]
+
+// We weren't checking that the trait and impl generics line up in the
+// normalization-shortcut code in `OpaqueTypeCollector`.
+
+use std::ops::Deref;
+
+trait Foo {
+ type Bar<'a>;
+
+ type Baz<'a>;
+
+ fn test<'a>() -> Self::Bar<'a>;
+}
+
+impl Foo for () {
+ type Bar<'a> = impl Deref<Target = Self::Baz<'a>>;
+
+ type Baz<T> = impl Sized;
+ //~^ ERROR type `Baz` has 1 type parameter but its trait declaration has 0 type parameters
+ //~| ERROR unconstrained opaque type
+
+ fn test<'a>() -> Self::Bar<'a> {
+ &()
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr
new file mode 100644
index 000000000..13f5d8b8e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/impl-trait-in-type-alias-with-bad-substs.stderr
@@ -0,0 +1,20 @@
+error[E0049]: type `Baz` has 1 type parameter but its trait declaration has 0 type parameters
+ --> $DIR/impl-trait-in-type-alias-with-bad-substs.rs:19:14
+ |
+LL | type Baz<'a>;
+ | -- expected 0 type parameters
+...
+LL | type Baz<T> = impl Sized;
+ | ^ found 1 type parameter
+
+error: unconstrained opaque type
+ --> $DIR/impl-trait-in-type-alias-with-bad-substs.rs:19:19
+ |
+LL | type Baz<T> = impl Sized;
+ | ^^^^^^^^^^
+ |
+ = note: `Baz` must be used in combination with a concrete type within the same impl
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0049`.
diff --git a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr
index 8cf8fb1d1..137a4db81 100644
--- a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr
+++ b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.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/type-alias-impl-trait/impl_for_weak_alias.rs b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs
new file mode 100644
index 000000000..00d1a1a22
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.rs
@@ -0,0 +1,14 @@
+#![feature(type_alias_impl_trait)]
+#![feature(auto_traits)]
+
+type Alias = (impl Sized, u8);
+
+auto trait Trait {}
+impl Trait for Alias {}
+//~^ ERROR traits with a default impl, like `Trait`, cannot be implemented for type alias `Alias`
+
+fn _def() -> Alias {
+ (42, 42)
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr
new file mode 100644
index 000000000..a13e9eaab
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/impl_for_weak_alias.stderr
@@ -0,0 +1,11 @@
+error[E0321]: traits with a default impl, like `Trait`, cannot be implemented for type alias `Alias`
+ --> $DIR/impl_for_weak_alias.rs:7:1
+ |
+LL | impl Trait for Alias {}
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: a trait object implements `Trait` if and only if `Trait` is one of the trait object's trait bounds
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0321`.
diff --git a/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr b/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr
index aaf75cc3d..e35913be8 100644
--- a/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr
+++ b/tests/ui/type-alias-impl-trait/impl_trait_for_same_tait.stderr
@@ -15,6 +15,8 @@ LL | impl Bop for Bar<()> {}
...
LL | impl Bop for Barr {}
| ^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>`
+ |
+ = note: upstream crates may add a new impl of trait `std::marker::FnPtr` for type `Barr` in future versions
error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>`
--> $DIR/impl_trait_for_same_tait.rs:30:1
diff --git a/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr b/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr
index 1c83105a1..9840bcef7 100644
--- a/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr
+++ b/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound.stderr
@@ -11,6 +11,6 @@ note: required by a bound in `is_yay`
LL | fn is_yay<T: Yay>() { }
| ^^^ required by this bound in `is_yay`
-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/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr b/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr
index a6440f02c..2259aa7bb 100644
--- a/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr
+++ b/tests/ui/type-alias-impl-trait/impl_trait_for_tait_bound2.stderr
@@ -11,6 +11,6 @@ note: required by a bound in `is_yay`
LL | fn is_yay<T: Yay>() { }
| ^^^ required by this bound in `is_yay`
-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/type-alias-impl-trait/implied_bounds.stderr b/tests/ui/type-alias-impl-trait/implied_bounds.stderr
index 6f11b6663..64a203fe4 100644
--- a/tests/ui/type-alias-impl-trait/implied_bounds.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_bounds.stderr
@@ -12,5 +12,5 @@ LL | x
|
= 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/type-alias-impl-trait/implied_bounds_closure.stderr b/tests/ui/type-alias-impl-trait/implied_bounds_closure.stderr
index 151564c3b..f3f9962f1 100644
--- a/tests/ui/type-alias-impl-trait/implied_bounds_closure.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_bounds_closure.stderr
@@ -7,5 +7,5 @@ LL | let t = into_impl(x);
LL | helper(|_| t)
| ^ returning this value requires that `'a` must outlive `'static`
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr b/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
index cbc5e6073..5967a9468 100644
--- a/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
@@ -12,5 +12,5 @@ LL | x
|
= 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/type-alias-impl-trait/implied_lifetime_wf_check3.rs b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
index 6f9434255..469a493b0 100644
--- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
+++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
@@ -1,7 +1,7 @@
#![feature(type_alias_impl_trait)]
mod test_lifetime_param {
- type Ty<'a> = impl Sized + 'a;
+ type Ty<'a> = impl Sized;
fn defining(a: &str) -> Ty<'_> { a }
fn assert_static<'a: 'static>() {}
fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
@@ -9,7 +9,7 @@ mod test_lifetime_param {
}
mod test_higher_kinded_lifetime_param {
- type Ty<'a> = impl Sized + 'a;
+ type Ty<'a> = impl Sized;
fn defining(a: &str) -> Ty<'_> { a }
fn assert_static<'a: 'static>() {}
fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
index 399775641..d6dd20739 100644
--- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
@@ -22,9 +22,12 @@ error[E0310]: the parameter type `A` may not live long enough
--> $DIR/implied_lifetime_wf_check3.rs:29:41
|
LL | fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
- | ^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ | ^^^^^^^^^^^^^^^^^^
+ | |
+ | the parameter type `A` must be valid for the static lifetime...
+ | ...so that the type `A` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() }
| +++++++++
diff --git a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
index 47bc31e78..ff11aee40 100644
--- a/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
+++ b/tests/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
@@ -2,13 +2,16 @@ error[E0310]: the parameter type `A` may not live long enough
--> $DIR/implied_lifetime_wf_check4_static.rs:4:18
|
LL | type Ty<A> = impl Sized + 'static;
- | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ | ^^^^^^^^^^^^^^^^^^^^
+ | |
+ | the parameter type `A` must be valid for the static lifetime...
+ | ...so that the type `A` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | type Ty<A: 'static> = impl Sized + '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/type-alias-impl-trait/imply_bounds_from_bounds.rs b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs
index 4f99236f4..06c119287 100644
--- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs
+++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs
@@ -1,16 +1,20 @@
// check-pass
-#![feature(impl_trait_in_assoc_type)]
+#![feature(impl_trait_in_assoc_type, type_alias_impl_trait)]
-trait Callable {
- type Output;
- fn call() -> Self::Output;
-}
+mod foo {
+ pub trait Callable {
+ type Output;
+ fn call() -> Self::Output;
+ }
-impl<'a> Callable for &'a () {
- type Output = impl Sized;
- fn call() -> Self::Output {}
+ pub type OutputHelper = impl Sized;
+ impl<'a> Callable for &'a () {
+ type Output = OutputHelper;
+ fn call() -> Self::Output {}
+ }
}
+use foo::*;
fn test<'a>() -> impl Sized {
<&'a () as Callable>::call()
diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr
index 66e478315..9bffa94fd 100644
--- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr
+++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr
@@ -13,6 +13,6 @@ help: to declare that `impl PlusOne` captures `'a`, you can add an explicit `'a`
LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + 'a {
| ++++
-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/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr b/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr
index b93ea955c..f0cf681d8 100644
--- a/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr
+++ b/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.stderr
@@ -7,6 +7,6 @@ LL | impl<F> FnOnce<()> for &F {
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0210`.
diff --git a/tests/ui/type-alias-impl-trait/incomplete-inference.stderr b/tests/ui/type-alias-impl-trait/incomplete-inference.stderr
index 9a0e71b4e..3976a43a8 100644
--- a/tests/ui/type-alias-impl-trait/incomplete-inference.stderr
+++ b/tests/ui/type-alias-impl-trait/incomplete-inference.stderr
@@ -9,6 +9,6 @@ help: consider specifying the generic argument
LL | None::<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/type-alias-impl-trait/indirect-recursion-issue-112047.rs b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs
new file mode 100644
index 000000000..6a2ee761e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs
@@ -0,0 +1,29 @@
+// edition: 2021
+// build-fail
+
+#![feature(impl_trait_in_assoc_type)]
+
+use core::future::Future;
+
+trait Recur {
+ type Recur: Future<Output = ()>;
+
+ fn recur(self) -> Self::Recur;
+}
+
+async fn recur(t: impl Recur) {
+ t.recur().await;
+}
+
+impl Recur for () {
+ type Recur = impl Future<Output = ()>;
+
+ fn recur(self) -> Self::Recur {
+ async move { recur(self).await; }
+ //~^ ERROR cycle detected when computing layout of
+ }
+}
+
+fn main() {
+ recur(());
+}
diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr
new file mode 100644
index 000000000..11d9cd0af
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr
@@ -0,0 +1,27 @@
+error[E0391]: cycle detected when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}`
+ --> $DIR/indirect-recursion-issue-112047.rs:22:22
+ |
+LL | async move { recur(self).await; }
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:14:31: 16:2}>`...
+ = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:14:31: 16:2}>`...
+note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:14:31: 16:2}`...
+ --> $DIR/indirect-recursion-issue-112047.rs:15:5
+ |
+LL | t.recur().await;
+ | ^^^^^^^^^^^^^^^
+ = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<<() as Recur>::Recur>`...
+ = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}>`...
+ = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}>`...
+ = note: ...which again requires computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:22:9: 22:42}`, completing the cycle
+note: cycle used when elaborating drops for `<impl at $DIR/indirect-recursion-issue-112047.rs:18:1: 18:18>::recur`
+ --> $DIR/indirect-recursion-issue-112047.rs:21:5
+ |
+LL | fn recur(self) -> Self::Recur {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.rs b/tests/ui/type-alias-impl-trait/inference-cycle.rs
index 79caddf79..6e4507ed4 100644
--- a/tests/ui/type-alias-impl-trait/inference-cycle.rs
+++ b/tests/ui/type-alias-impl-trait/inference-cycle.rs
@@ -2,21 +2,20 @@
#![allow(dead_code)]
mod m {
- type Foo = impl std::fmt::Debug;
- //~^ ERROR cycle detected
-
- // Cycle: error today, but it'd be nice if it eventually worked
+ pub type Foo = impl std::fmt::Debug;
pub fn foo() -> Foo {
is_send(bar())
}
pub fn bar() {
- is_send(foo()); // Today: error
+ // Cycle: error today, but it'd be nice if it eventually worked
+ is_send(foo());
+ //~^ ERROR: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits
}
- fn baz() {
- let f: Foo = 22_u32;
+ fn baz() -> Foo {
+ ()
}
fn is_send<T: Send>(_: T) {}
diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
index b9d646b92..fd7488fa2 100644
--- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr
+++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr
@@ -1,22 +1,26 @@
-error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
- --> $DIR/inference-cycle.rs:5:16
+error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits
+ --> $DIR/inference-cycle.rs:13:17
|
-LL | type Foo = impl std::fmt::Debug;
- | ^^^^^^^^^^^^^^^^^^^^
+LL | is_send(foo());
+ | ------- ^^^^^
+ | |
+ | required by a bound introduced by this call
|
-note: ...which requires type-checking `m::bar`...
- --> $DIR/inference-cycle.rs:15:9
+note: opaque type is declared here
+ --> $DIR/inference-cycle.rs:5:20
|
-LL | is_send(foo()); // Today: error
- | ^^^^^^^
- = note: ...which requires evaluating trait selection obligation `m::Foo: core::marker::Send`...
- = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in module `m`
- --> $DIR/inference-cycle.rs:4:1
+LL | pub type Foo = impl std::fmt::Debug;
+ | ^^^^^^^^^^^^^^^^^^^^
+note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
+ --> $DIR/inference-cycle.rs:11:12
|
-LL | mod m {
- | ^^^^^
+LL | pub fn bar() {
+ | ^^^
+note: required by a bound in `is_send`
+ --> $DIR/inference-cycle.rs:21:19
+ |
+LL | fn is_send<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `is_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/type-alias-impl-trait/infinite-cycle-involving-weak.rs b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs
new file mode 100644
index 000000000..6609d4eb5
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs
@@ -0,0 +1,8 @@
+#![feature(type_alias_impl_trait)]
+
+type T = impl Copy;
+//~^ ERROR cannot resolve opaque type
+
+static STATIC: T = None::<&'static T>;
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr
new file mode 100644
index 000000000..d820df472
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr
@@ -0,0 +1,9 @@
+error[E0720]: cannot resolve opaque type
+ --> $DIR/infinite-cycle-involving-weak.rs:3:10
+ |
+LL | type T = impl Copy;
+ | ^^^^^^^^^ cannot resolve opaque type
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0720`.
diff --git a/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr
index 2beed73cb..169d8e41d 100644
--- a/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr
+++ b/tests/ui/type-alias-impl-trait/invalid_impl_trait_in_assoc_ty.stderr
@@ -12,11 +12,11 @@ LL | let x: Self::Foo = ();
= note: expected opaque type `<() as Foo>::Foo`
found unit type `()`
note: this item must have the opaque type in its signature in order to be able to register hidden types
- --> $DIR/invalid_impl_trait_in_assoc_ty.rs:10:5
+ --> $DIR/invalid_impl_trait_in_assoc_ty.rs:10:8
|
LL | fn bar() {
- | ^^^^^^^^
+ | ^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/issue-104817.stock.stderr b/tests/ui/type-alias-impl-trait/issue-104817.stock.stderr
index 47bae8bd1..41c5206d9 100644
--- a/tests/ui/type-alias-impl-trait/issue-104817.stock.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-104817.stock.stderr
@@ -6,6 +6,6 @@ LL | impl<T: Send> AnotherTrait for T {}
LL | impl AnotherTrait for OpaqueType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `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/type-alias-impl-trait/issue-109054.rs b/tests/ui/type-alias-impl-trait/issue-109054.rs
new file mode 100644
index 000000000..1fbec47b1
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-109054.rs
@@ -0,0 +1,22 @@
+// edition:2021
+
+#![feature(type_alias_impl_trait)]
+
+struct CallMe;
+
+type ReturnType<'a> = impl std::future::Future<Output = u32> + 'a;
+type FnType = impl Fn(&u32) -> ReturnType;
+
+impl std::ops::Deref for CallMe {
+ type Target = FnType;
+
+ fn deref(&self) -> &Self::Target {
+ fn inner(val: &u32) -> ReturnType {
+ async move { *val * 2 }
+ }
+
+ &inner //~ ERROR: expected generic lifetime parameter, found `'_`
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-109054.stderr b/tests/ui/type-alias-impl-trait/issue-109054.stderr
new file mode 100644
index 000000000..a099b7d8b
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-109054.stderr
@@ -0,0 +1,12 @@
+error[E0792]: expected generic lifetime parameter, found `'_`
+ --> $DIR/issue-109054.rs:18:9
+ |
+LL | type ReturnType<'a> = impl std::future::Future<Output = u32> + 'a;
+ | -- this generic parameter must be used with a generic lifetime parameter
+...
+LL | &inner
+ | ^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr b/tests/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr
index 4c5fd2255..4570ce8e4 100644
--- a/tests/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-52843-closure-constrain.stderr
@@ -10,5 +10,5 @@ note: previous use here
LL | fn _unused() -> Opaque { String::new() }
| ^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/issue-52843.stderr b/tests/ui/type-alias-impl-trait/issue-52843.stderr
index acd40f980..ea4c5297a 100644
--- a/tests/ui/type-alias-impl-trait/issue-52843.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-52843.stderr
@@ -9,6 +9,6 @@ help: consider restricting type parameter `T`
LL | type Foo<T: std::default::Default> = impl Default;
| +++++++++++++++++++++++
-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/type-alias-impl-trait/issue-53092-2.stderr b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
index 2565a28b4..e4054e14a 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr
@@ -4,6 +4,11 @@ error[E0391]: cycle detected when computing type of `Bug::{opaque#0}`
LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
| ^^^^^^^^^^^^^^^^^^^^^^
|
+note: ...which requires computing type of opaque `Bug::{opaque#0}`...
+ --> $DIR/issue-53092-2.rs:4:18
+ |
+LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
+ | ^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `CONST_BUG`...
--> $DIR/issue-53092-2.rs:6:1
|
@@ -23,6 +28,7 @@ LL | | type Bug<T, U> = impl Fn(T) -> U + Copy;
LL | | CONST_BUG(0);
LL | | }
| |_^
+ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error[E0277]: the trait bound `U: From<T>` is not satisfied
--> $DIR/issue-53092-2.rs:9:5
diff --git a/tests/ui/type-alias-impl-trait/issue-53092.stderr b/tests/ui/type-alias-impl-trait/issue-53092.stderr
index 2109cf8a7..8605a0981 100644
--- a/tests/ui/type-alias-impl-trait/issue-53092.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53092.stderr
@@ -14,6 +14,6 @@ help: consider restricting type parameter `U`
LL | type Bug<T, U: std::convert::From<T>> = impl Fn(T) -> U + Copy;
| +++++++++++++++++++++++
-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/type-alias-impl-trait/issue-53096.stderr b/tests/ui/type-alias-impl-trait/issue-53096.stderr
index 0af3a75f8..fba1802ef 100644
--- a/tests/ui/type-alias-impl-trait/issue-53096.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53096.stderr
@@ -4,5 +4,5 @@ error: fatal error triggered by #[rustc_error]
LL | fn main() {}
| ^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs
index 4a11bb502..b89c3e459 100644
--- a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs
+++ b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs
@@ -1,9 +1,10 @@
#![feature(type_alias_impl_trait)]
+// check-pass
+
type Foo = impl Fn() -> Foo;
fn foo() -> Foo {
-//~^ ERROR: overflow evaluating the requirement
foo
}
diff --git a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr
deleted file mode 100644
index 0a34e8486..000000000
--- a/tests/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0275]: overflow evaluating the requirement `Foo: Sized`
- --> $DIR/issue-53398-cyclic-types.rs:5:13
- |
-LL | fn foo() -> Foo {
- | ^^^
- |
- = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)
- = note: required because it appears within the type `fn() -> Foo {foo}`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/type-alias-impl-trait/issue-53598.stderr b/tests/ui/type-alias-impl-trait/issue-53598.stderr
index f8b8201e2..a31aabedb 100644
--- a/tests/ui/type-alias-impl-trait/issue-53598.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-53598.stderr
@@ -4,5 +4,5 @@ error: type parameter `T` is part of concrete type but not used in parameter lis
LL | S::<T>(Default::default())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs
new file mode 100644
index 000000000..ad1ede9c3
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-53678-coroutine-and-const-fn.rs
@@ -0,0 +1,22 @@
+#![feature(coroutines, coroutine_trait, rustc_attrs)]
+#![feature(type_alias_impl_trait)]
+
+// check-pass
+
+mod gen {
+ use std::ops::Coroutine;
+
+ pub type CoroOnce<Y, R> = impl Coroutine<Yield = Y, Return = R>;
+
+ pub const fn const_coroutine<Y, R>(yielding: Y, returning: R) -> CoroOnce<Y, R> {
+ move || {
+ yield yielding;
+
+ return returning;
+ }
+ }
+}
+
+const FOO: gen::CoroOnce<usize, usize> = gen::const_coroutine(10, 100);
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs
deleted file mode 100644
index a3f126d56..000000000
--- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#![feature(generators, generator_trait, rustc_attrs)]
-#![feature(type_alias_impl_trait)]
-
-use std::ops::Generator;
-
-type GenOnce<Y, R> = impl Generator<Yield = Y, Return = R>;
-
-const fn const_generator<Y, R>(yielding: Y, returning: R) -> GenOnce<Y, R> {
- move || {
- yield yielding;
-
- return returning;
- }
-}
-
-const FOO: GenOnce<usize, usize> = const_generator(10, 100);
-
-#[rustc_error]
-fn main() {} //~ ERROR
diff --git a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr b/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr
deleted file mode 100644
index eb1c9603a..000000000
--- a/tests/ui/type-alias-impl-trait/issue-53678-generator-and-const-fn.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: fatal error triggered by #[rustc_error]
- --> $DIR/issue-53678-generator-and-const-fn.rs:19:1
- |
-LL | fn main() {}
- | ^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/type-alias-impl-trait/issue-57700.stderr b/tests/ui/type-alias-impl-trait/issue-57700.stderr
index 31b6df5d4..7efb05f40 100644
--- a/tests/ui/type-alias-impl-trait/issue-57700.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-57700.stderr
@@ -4,5 +4,5 @@ error: type parameter `impl Deref<Target = Self>` is part of concrete type but n
LL | self
| ^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/issue-57961.rs b/tests/ui/type-alias-impl-trait/issue-57961.rs
index 4aa5966ff..61af7a0f6 100644
--- a/tests/ui/type-alias-impl-trait/issue-57961.rs
+++ b/tests/ui/type-alias-impl-trait/issue-57961.rs
@@ -11,8 +11,8 @@ impl Foo for () {
//~^ ERROR expected `IntoIter<u32>` to be an iterator that yields `X`, but it yields `u32`
}
-fn incoherent() {
- let f: X = 22_i32;
+fn incoherent() -> X {
+ 22_i32
}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-57961.stderr b/tests/ui/type-alias-impl-trait/issue-57961.stderr
index 8d11b4888..314296b5b 100644
--- a/tests/ui/type-alias-impl-trait/issue-57961.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-57961.stderr
@@ -15,6 +15,6 @@ note: required by a bound in `Foo::Bar`
LL | type Bar: Iterator<Item = X>;
| ^^^^^^^^ required by this bound in `Foo::Bar`
-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/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs
new file mode 100644
index 000000000..bc6a34392
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-58662-coroutine-with-lifetime.rs
@@ -0,0 +1,39 @@
+// check-pass
+
+#![feature(coroutines, coroutine_trait)]
+#![feature(type_alias_impl_trait)]
+
+use std::ops::{Coroutine, CoroutineState};
+use std::pin::Pin;
+
+type RandCoroutine<'a> = impl Coroutine<Return = (), Yield = u64> + 'a;
+fn rand_coroutine<'a>(rng: &'a ()) -> RandCoroutine<'a> {
+ move || {
+ let _rng = rng;
+ loop {
+ yield 0;
+ }
+ }
+}
+
+pub type RandCoroutineWithIndirection<'c> = impl Coroutine<Return = (), Yield = u64> + 'c;
+pub fn rand_coroutine_with_indirection<'a>(rng: &'a ()) -> RandCoroutineWithIndirection<'a> {
+ fn helper<'b>(rng: &'b ()) -> impl 'b + Coroutine<Return = (), Yield = u64> {
+ move || {
+ let _rng = rng;
+ loop {
+ yield 0;
+ }
+ }
+ }
+
+ helper(rng)
+}
+
+fn main() {
+ let mut gen = rand_coroutine(&());
+ match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) {
+ CoroutineState::Yielded(_) => {}
+ CoroutineState::Complete(_) => {}
+ };
+}
diff --git a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs b/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
deleted file mode 100644
index 477b61390..000000000
--- a/tests/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-// check-pass
-
-#![feature(generators, generator_trait)]
-#![feature(type_alias_impl_trait)]
-
-use std::ops::{Generator, GeneratorState};
-use std::pin::Pin;
-
-type RandGenerator<'a> = impl Generator<Return = (), Yield = u64> + 'a;
-fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> {
- move || {
- let _rng = rng;
- loop {
- yield 0;
- }
- }
-}
-
-pub type RandGeneratorWithIndirection<'c> = impl Generator<Return = (), Yield = u64> + 'c;
-pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> {
- fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> {
- move || {
- let _rng = rng;
- loop {
- yield 0;
- }
- }
- }
-
- helper(rng)
-}
-
-fn main() {
- let mut gen = rand_generator(&());
- match unsafe { Pin::new_unchecked(&mut gen) }.resume(()) {
- GeneratorState::Yielded(_) => {}
- GeneratorState::Complete(_) => {}
- };
-}
diff --git a/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs b/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
index 27ca7d0fd..a1cf23dab 100644
--- a/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
+++ b/tests/ui/type-alias-impl-trait/issue-58662-simplified.rs
@@ -1,6 +1,6 @@
// check-pass
-#![feature(generators, generator_trait)]
+#![feature(coroutines, coroutine_trait)]
#![feature(type_alias_impl_trait)]
trait Trait {}
diff --git a/tests/ui/type-alias-impl-trait/issue-60407.stderr b/tests/ui/type-alias-impl-trait/issue-60407.stderr
index fecee2779..583156b9f 100644
--- a/tests/ui/type-alias-impl-trait/issue-60407.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-60407.stderr
@@ -4,5 +4,5 @@ error: fatal error triggered by #[rustc_error]
LL | fn main() {
| ^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/issue-60564.rs b/tests/ui/type-alias-impl-trait/issue-60564.rs
index c2f4c3708..48bd70bcc 100644
--- a/tests/ui/type-alias-impl-trait/issue-60564.rs
+++ b/tests/ui/type-alias-impl-trait/issue-60564.rs
@@ -17,6 +17,7 @@ where
{
type BitsIter = IterBitsIter<T, E, u8>;
fn iter_bits(self, n: u8) -> Self::BitsIter {
+ //~^ ERROR non-defining opaque type use
(0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap())
//~^ ERROR expected generic type parameter, found `u8`
}
diff --git a/tests/ui/type-alias-impl-trait/issue-60564.stderr b/tests/ui/type-alias-impl-trait/issue-60564.stderr
index f8fdb004d..d42495e93 100644
--- a/tests/ui/type-alias-impl-trait/issue-60564.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-60564.stderr
@@ -1,5 +1,17 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/issue-60564.rs:19:34
+ |
+LL | fn iter_bits(self, n: u8) -> Self::BitsIter {
+ | ^^^^^^^^^^^^^^ argument `u8` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/issue-60564.rs:8:30
+ |
+LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
error[E0792]: expected generic type parameter, found `u8`
- --> $DIR/issue-60564.rs:20:9
+ --> $DIR/issue-60564.rs:21:9
|
LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>;
| - this generic parameter must be used with a generic type parameter
@@ -7,6 +19,6 @@ LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>;
LL | (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs b/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs
index 7414611a7..ddea7aeb6 100644
--- a/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs
+++ b/tests/ui/type-alias-impl-trait/issue-63263-closure-return.rs
@@ -8,6 +8,9 @@
pub type Closure = impl FnOnce();
-fn main() {
+fn bop() -> Closure {
|| -> Closure { || () };
+ panic!()
}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-63279.rs b/tests/ui/type-alias-impl-trait/issue-63279.rs
index 0e46745c6..02f211146 100644
--- a/tests/ui/type-alias-impl-trait/issue-63279.rs
+++ b/tests/ui/type-alias-impl-trait/issue-63279.rs
@@ -3,11 +3,11 @@
type Closure = impl FnOnce();
fn c() -> Closure {
- //~^ ERROR: expected a `FnOnce<()>` closure, found `()`
+ //~^ ERROR: expected a `FnOnce()` closure, found `()`
|| -> Closure { || () }
//~^ ERROR: mismatched types
//~| ERROR: mismatched types
- //~| ERROR: expected a `FnOnce<()>` closure, found `()`
+ //~| ERROR: expected a `FnOnce()` closure, found `()`
}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-63279.stderr b/tests/ui/type-alias-impl-trait/issue-63279.stderr
index a4f6359b9..58cafd21c 100644
--- a/tests/ui/type-alias-impl-trait/issue-63279.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-63279.stderr
@@ -1,17 +1,17 @@
-error[E0277]: expected a `FnOnce<()>` closure, found `()`
+error[E0277]: expected a `FnOnce()` closure, found `()`
--> $DIR/issue-63279.rs:5:11
|
LL | fn c() -> Closure {
- | ^^^^^^^ expected an `FnOnce<()>` closure, found `()`
+ | ^^^^^^^ expected an `FnOnce()` closure, found `()`
|
= help: the trait `FnOnce<()>` is not implemented for `()`
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
-error[E0277]: expected a `FnOnce<()>` closure, found `()`
+error[E0277]: expected a `FnOnce()` closure, found `()`
--> $DIR/issue-63279.rs:7:11
|
LL | || -> Closure { || () }
- | ^^^^^^^ expected an `FnOnce<()>` closure, found `()`
+ | ^^^^^^^ expected an `FnOnce()` closure, found `()`
|
= help: the trait `FnOnce<()>` is not implemented for `()`
= note: wrap the `()` in a closure with no arguments: `|| { /* code */ }`
@@ -23,7 +23,7 @@ LL | || -> Closure { || () }
| ^^^^^ expected `()`, found closure
|
= note: expected unit type `()`
- found closure `[closure@$DIR/issue-63279.rs:7:21: 7:23]`
+ found closure `{closure@$DIR/issue-63279.rs:7:21: 7:23}`
help: use parentheses to call this closure
|
LL | || -> Closure { (|| ())() }
@@ -36,7 +36,7 @@ LL | || -> Closure { || () }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
= note: expected unit type `()`
- found closure `[closure@$DIR/issue-63279.rs:7:5: 7:18]`
+ found closure `{closure@$DIR/issue-63279.rs:7:5: 7:18}`
help: use parentheses to call this closure
|
LL | (|| -> Closure { || () })()
diff --git a/tests/ui/type-alias-impl-trait/issue-65384.stderr b/tests/ui/type-alias-impl-trait/issue-65384.stderr
index f6692ae32..6accd45ba 100644
--- a/tests/ui/type-alias-impl-trait/issue-65384.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-65384.stderr
@@ -7,6 +7,6 @@ LL | impl MyTrait for () {}
LL | impl MyTrait for Bar {}
| ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
-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/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs b/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
index b91cbce37..7b3e9e124 100644
--- a/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
+++ b/tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
@@ -11,7 +11,9 @@ type T = impl Sized;
fn take(_: fn() -> T) {}
-fn main() {
+fn bop(_: T) {
take(|| {});
take(|| {});
}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs
index 5e0a82a72..9dcdb5785 100644
--- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs
+++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs
@@ -7,7 +7,8 @@ trait Trait<T> {}
type Alias<'a, U> = impl Trait<U>;
fn f<'a>() -> Alias<'a, ()> {}
-//~^ ERROR expected generic type parameter, found `()`
+//~^ ERROR non-defining opaque type use
+//~| ERROR expected generic type parameter, found `()`
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr
index 271743a40..085bffe90 100644
--- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr
@@ -1,3 +1,15 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/issue-68368-non-defining-use-2.rs:9:15
+ |
+LL | fn f<'a>() -> Alias<'a, ()> {}
+ | ^^^^^^^^^^^^^ argument `()` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/issue-68368-non-defining-use-2.rs:7:21
+ |
+LL | type Alias<'a, U> = impl Trait<U>;
+ | ^^^^^^^^^^^^^
+
error[E0792]: expected generic type parameter, found `()`
--> $DIR/issue-68368-non-defining-use-2.rs:9:29
|
@@ -7,6 +19,6 @@ LL |
LL | fn f<'a>() -> Alias<'a, ()> {}
| ^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
index 3b32260c9..dfe2ee820 100644
--- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
+++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs
@@ -8,6 +8,7 @@ type Alias<'a, U> = impl Trait<U>;
fn f<'a>() -> Alias<'a, ()> {}
//~^ ERROR expected generic type parameter, found `()`
+//~| ERROR non-defining opaque type use
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
index 4d9a8d6ee..ea704ffff 100644
--- a/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr
@@ -1,3 +1,15 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/issue-68368-non-defining-use.rs:9:15
+ |
+LL | fn f<'a>() -> Alias<'a, ()> {}
+ | ^^^^^^^^^^^^^ argument `()` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/issue-68368-non-defining-use.rs:7:21
+ |
+LL | type Alias<'a, U> = impl Trait<U>;
+ | ^^^^^^^^^^^^^
+
error[E0792]: expected generic type parameter, found `()`
--> $DIR/issue-68368-non-defining-use.rs:9:29
|
@@ -7,6 +19,6 @@ LL |
LL | fn f<'a>() -> Alias<'a, ()> {}
| ^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs
index 7657fe2fb..a0f8e48e2 100644
--- a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs
+++ b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.rs
@@ -1,4 +1,6 @@
-// Regression test for #69136
+//! Regression test for #69136
+//! This test checks that the unknown lifetime `'a` doesn't cause
+//! ICEs after emitting the error.
#![feature(type_alias_impl_trait)]
@@ -17,7 +19,6 @@ impl<T> WithAssoc<T> for () {
type Return<A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
//~^ ERROR use of undeclared lifetime name `'a`
-fn my_fun() -> Return<()> {}
-//~^ ERROR expected generic type parameter, found `()`
+fn my_fun<T>() -> Return<T> {}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr
index d1250786d..aa7bcbf6a 100644
--- a/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-69136-inner-lifetime-resolve-error.stderr
@@ -1,5 +1,5 @@
error[E0261]: use of undeclared lifetime name `'a`
- --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:17:65
+ --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:19:65
|
LL | type Return<A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
| ^^ undeclared lifetime
@@ -14,16 +14,6 @@ help: consider introducing lifetime `'a` here
LL | type Return<'a, A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
| +++
-error[E0792]: expected generic type parameter, found `()`
- --> $DIR/issue-69136-inner-lifetime-resolve-error.rs:20:27
- |
-LL | type Return<A> = impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
- | - this generic parameter must be used with a generic type parameter
-...
-LL | fn my_fun() -> Return<()> {}
- | ^^
-
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
-Some errors have detailed explanations: E0261, E0792.
-For more information about an error, try `rustc --explain E0261`.
+For more information about this error, try `rustc --explain E0261`.
diff --git a/tests/ui/type-alias-impl-trait/issue-70121.rs b/tests/ui/type-alias-impl-trait/issue-70121.rs
index dff0d89d4..bfd8d8872 100644
--- a/tests/ui/type-alias-impl-trait/issue-70121.rs
+++ b/tests/ui/type-alias-impl-trait/issue-70121.rs
@@ -1,5 +1,3 @@
-// check-pass
-
#![feature(type_alias_impl_trait)]
pub type Successors<'a> = impl Iterator<Item = &'a ()>;
@@ -17,6 +15,7 @@ impl<'a> Tr for &'a () {
}
pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
+ //~^ ERROR item constrains opaque type that is not in its signature
None.into_iter()
}
diff --git a/tests/ui/type-alias-impl-trait/issue-70121.stderr b/tests/ui/type-alias-impl-trait/issue-70121.stderr
new file mode 100644
index 000000000..d6ab26e30
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/issue-70121.stderr
@@ -0,0 +1,15 @@
+error: item constrains opaque type that is not in its signature
+ --> $DIR/issue-70121.rs:17:24
+ |
+LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: this item must mention the opaque type in its signature in order to be able to register hidden types
+note: this item must mention the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/issue-70121.rs:17:8
+ |
+LL | pub fn kazusa<'a>() -> <&'a () as Tr>::Item {
+ | ^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/issue-74244.stderr b/tests/ui/type-alias-impl-trait/issue-74244.stderr
index ff6bacd27..f5ca56bac 100644
--- a/tests/ui/type-alias-impl-trait/issue-74244.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-74244.stderr
@@ -4,6 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self
LL | impl<T> Allocator for DefaultAllocator {
| ^ 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/type-alias-impl-trait/issue-74280.stderr b/tests/ui/type-alias-impl-trait/issue-74280.stderr
index 66886db6e..c09efbe4e 100644
--- a/tests/ui/type-alias-impl-trait/issue-74280.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-74280.stderr
@@ -7,6 +7,6 @@ LL | let y = || -> Test { () };
LL | 7
| ^ expected `()`, 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/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs
index b97e444c6..af1c18bbb 100644
--- a/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs
+++ b/tests/ui/type-alias-impl-trait/issue-76202-trait-impl-for-tait.rs
@@ -1,6 +1,8 @@
// Regression test for issue #76202
// Tests that we don't ICE when we have a trait impl on a TAIT.
+// revisions: current next
+//[next] compile-flags: -Znext-solver
// check-pass
#![feature(type_alias_impl_trait)]
diff --git a/tests/ui/type-alias-impl-trait/issue-77179.rs b/tests/ui/type-alias-impl-trait/issue-77179.rs
index 8d818d4a3..e7b04a489 100644
--- a/tests/ui/type-alias-impl-trait/issue-77179.rs
+++ b/tests/ui/type-alias-impl-trait/issue-77179.rs
@@ -2,7 +2,7 @@
#![feature(type_alias_impl_trait)]
-type Pointer<T> = impl std::ops::Deref<Target=T>;
+type Pointer<T> = impl std::ops::Deref<Target = T>;
fn test() -> Pointer<_> {
//~^ ERROR: the placeholder `_` is not allowed within types
diff --git a/tests/ui/type-alias-impl-trait/issue-77179.stderr b/tests/ui/type-alias-impl-trait/issue-77179.stderr
index 053546e4b..68dd6570d 100644
--- a/tests/ui/type-alias-impl-trait/issue-77179.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-77179.stderr
@@ -7,6 +7,6 @@ LL | fn test() -> Pointer<_> {
| | not allowed in type signatures
| help: replace with the correct return type: `Pointer<i32>`
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0121`.
diff --git a/tests/ui/type-alias-impl-trait/issue-78450.rs b/tests/ui/type-alias-impl-trait/issue-78450.rs
index 2a984c1ed..c51dfb678 100644
--- a/tests/ui/type-alias-impl-trait/issue-78450.rs
+++ b/tests/ui/type-alias-impl-trait/issue-78450.rs
@@ -1,4 +1,6 @@
// check-pass
+// revisions: current next
+//[next] compile-flags: -Znext-solver
#![feature(impl_trait_in_assoc_type)]
diff --git a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr
index 6a75e1bd2..461da20f3 100644
--- a/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-84660-unsoundness.stderr
@@ -7,6 +7,6 @@ LL | impl<In, Out> Trait<Bar, In> for Out {
LL | impl<In, Out> Trait<(), In> for Out {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
-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/type-alias-impl-trait/issue-89686.rs b/tests/ui/type-alias-impl-trait/issue-89686.rs
index 058417bdb..de070fc9d 100644
--- a/tests/ui/type-alias-impl-trait/issue-89686.rs
+++ b/tests/ui/type-alias-impl-trait/issue-89686.rs
@@ -4,7 +4,7 @@
use std::future::Future;
-type G<'a, T> = impl Future<Output = ()> + 'a;
+type G<'a, T> = impl Future<Output = ()>;
trait Trait {
type F: Future<Output = ()>;
diff --git a/tests/ui/type-alias-impl-trait/issue-89686.stderr b/tests/ui/type-alias-impl-trait/issue-89686.stderr
index 3b95a575a..91d71339a 100644
--- a/tests/ui/type-alias-impl-trait/issue-89686.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-89686.stderr
@@ -6,9 +6,9 @@ LL | async move { self.f().await }
|
help: consider restricting type parameter `T`
|
-LL | type G<'a, T: Trait> = impl Future<Output = ()> + 'a;
+LL | type G<'a, T: Trait> = impl Future<Output = ()>;
| +++++++
-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/type-alias-impl-trait/issue-90400-1.stderr b/tests/ui/type-alias-impl-trait/issue-90400-1.stderr
index ead28769f..bc233a532 100644
--- a/tests/ui/type-alias-impl-trait/issue-90400-1.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-90400-1.stderr
@@ -14,6 +14,6 @@ help: consider restricting type parameter `B`
LL | type FooFn<B: Bar> = impl FnOnce();
| +++++
-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/type-alias-impl-trait/issue-90400-2.stderr b/tests/ui/type-alias-impl-trait/issue-90400-2.stderr
index 0c45046f5..37abb3fe0 100644
--- a/tests/ui/type-alias-impl-trait/issue-90400-2.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-90400-2.stderr
@@ -16,6 +16,6 @@ help: consider restricting type parameter `B`
LL | type FooFn<B: Bar> = impl Baz;
| +++++
-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/type-alias-impl-trait/issue-94429.rs b/tests/ui/type-alias-impl-trait/issue-94429.rs
index d764545f9..306e73003 100644
--- a/tests/ui/type-alias-impl-trait/issue-94429.rs
+++ b/tests/ui/type-alias-impl-trait/issue-94429.rs
@@ -1,18 +1,18 @@
-#![feature(impl_trait_in_assoc_type, generator_trait, generators)]
-use std::ops::Generator;
+#![feature(impl_trait_in_assoc_type, coroutine_trait, coroutines)]
+use std::ops::Coroutine;
trait Runnable {
- type Gen: Generator<Yield = (), Return = ()>;
+ type Coro: Coroutine<Yield = (), Return = ()>;
- fn run(&mut self) -> Self::Gen;
+ fn run(&mut self) -> Self::Coro;
}
struct Implementor {}
impl Runnable for Implementor {
- type Gen = impl Generator<Yield = (), Return = ()>;
+ type Coro = impl Coroutine<Yield = (), Return = ()>;
- fn run(&mut self) -> Self::Gen {
+ fn run(&mut self) -> Self::Coro {
//~^ ERROR: type mismatch resolving
move || {
yield 1;
diff --git a/tests/ui/type-alias-impl-trait/issue-94429.stderr b/tests/ui/type-alias-impl-trait/issue-94429.stderr
index 8d7f7a07b..5d081e6b1 100644
--- a/tests/ui/type-alias-impl-trait/issue-94429.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-94429.stderr
@@ -1,9 +1,9 @@
-error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:17:9: 17:16] as Generator>::Yield == ()`
+error[E0271]: type mismatch resolving `<{coroutine@$DIR/issue-94429.rs:17:9: 17:16} as Coroutine>::Yield == ()`
--> $DIR/issue-94429.rs:15:26
|
-LL | fn run(&mut self) -> Self::Gen {
- | ^^^^^^^^^ expected integer, found `()`
+LL | fn run(&mut self) -> Self::Coro {
+ | ^^^^^^^^^^ expected integer, found `()`
-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/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr
index 728244a18..4f4ca1041 100644
--- a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr
@@ -10,6 +10,6 @@ LL | Some((a, b, c)) => (),
= note: expected tuple `(u32, u32)`
found tuple `(_, _, _)`
-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/type-alias-impl-trait/issue-96572-unconstrained.rs b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
index 2c740ccc1..5bd854be8 100644
--- a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
+++ b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
@@ -1,5 +1,7 @@
#![feature(type_alias_impl_trait)]
// check-pass
+// revisions: default edition2021
+//[edition2021] compile-flags: --edition 2021
fn main() {
type T = impl Copy;
@@ -24,11 +26,9 @@ fn upvar() {
fn enum_upvar() {
type T = impl Copy;
let foo: T = Some((1u32, 2u32));
- let x = move || {
- match foo {
- None => (),
- Some((a, b)) => (),
- }
+ let x = move || match foo {
+ None => (),
+ Some((a, b)) => (),
};
}
@@ -61,6 +61,19 @@ mod only_pattern {
None => {}
}
}
+
+ type V = impl Copy;
+
+ fn baz(baz: Option<V>) {
+ match baz {
+ _ => {}
+ Some((mut x, mut y)) => {
+ x = 42;
+ y = "foo";
+ }
+ None => {}
+ }
+ }
}
mod only_pattern_rpit {
@@ -69,11 +82,7 @@ mod only_pattern_rpit {
let (mut x, mut y) = foo(false);
x = 42;
y = "foo";
- if b {
- panic!()
- } else {
- foo(true)
- }
+ if b { panic!() } else { foo(true) }
}
fn bar(b: bool) -> Option<impl Copy> {
diff --git a/tests/ui/type-alias-impl-trait/issue-98604.stderr b/tests/ui/type-alias-impl-trait/issue-98604.stderr
index af758d809..2390b7253 100644
--- a/tests/ui/type-alias-impl-trait/issue-98604.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-98604.stderr
@@ -6,6 +6,6 @@ LL | Box::new(test) as AsyncFnPtr;
|
= note: required for the cast from `Box<fn() -> impl Future<Output = ()> {test}>` to `Box<(dyn Fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> + 'static)>`
-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/type-alias-impl-trait/issue-98608.stderr b/tests/ui/type-alias-impl-trait/issue-98608.stderr
index 9b6510083..d5c56636f 100644
--- a/tests/ui/type-alias-impl-trait/issue-98608.stderr
+++ b/tests/ui/type-alias-impl-trait/issue-98608.stderr
@@ -11,6 +11,6 @@ LL | let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
found opaque type `impl Sized`
= note: required for the cast from `Box<fn() -> impl Sized {hi}>` to `Box<dyn Fn() -> Box<u8>>`
-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/type-alias-impl-trait/missing_lifetime_bound.rs b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs
index 01d1f5db1..c584a58cb 100644
--- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs
+++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.rs
@@ -1,7 +1,8 @@
#![feature(type_alias_impl_trait)]
-type Opaque<'a, T> = impl Sized;
+type Opaque2<T> = impl Sized;
+type Opaque<'a, T> = Opaque2<T>;
fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
-//~^ ERROR: hidden type for `Opaque<'a, T>` captures lifetime that does not appear in bounds
+//~^ ERROR: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
index d666e668d..03cc943d5 100644
--- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
+++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
@@ -1,13 +1,14 @@
-error[E0700]: hidden type for `Opaque<'a, T>` captures lifetime that does not appear in bounds
- --> $DIR/missing_lifetime_bound.rs:4:47
+error[E0700]: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds
+ --> $DIR/missing_lifetime_bound.rs:5:47
|
-LL | type Opaque<'a, T> = impl Sized;
- | ---------- opaque type defined here
+LL | type Opaque2<T> = impl Sized;
+ | ---------- opaque type defined here
+LL | type Opaque<'a, T> = Opaque2<T>;
LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
| -- ^
| |
| hidden type `&'a i32` captures the lifetime `'a` 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/type-alias-impl-trait/multi-error.rs b/tests/ui/type-alias-impl-trait/multi-error.rs
new file mode 100644
index 000000000..b5ff06572
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/multi-error.rs
@@ -0,0 +1,23 @@
+//! This test checks that we don't follow up
+//! with type mismatch errors of opaque types
+//! with their hidden types if we failed the
+//! defining scope check at the signature level.
+
+#![feature(impl_trait_in_assoc_type)]
+
+trait Foo {
+ type Bar<T>;
+ type Baz;
+ fn foo() -> (Self::Bar<u32>, Self::Baz);
+}
+
+impl Foo for () {
+ type Bar<T> = impl Sized;
+ type Baz = impl Sized;
+ fn foo() -> (Self::Bar<u32>, Self::Baz) {
+ //~^ ERROR non-defining opaque type use
+ ((), ())
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/multi-error.stderr b/tests/ui/type-alias-impl-trait/multi-error.stderr
new file mode 100644
index 000000000..b0e6d13b0
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/multi-error.stderr
@@ -0,0 +1,15 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/multi-error.rs:17:17
+ |
+LL | fn foo() -> (Self::Bar<u32>, Self::Baz) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument `u32` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/multi-error.rs:15:19
+ |
+LL | type Bar<T> = impl Sized;
+ | ^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr
index 278117009..b050b08a8 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr
@@ -7,5 +7,5 @@ LL | (42_i64, 60)
| expected `i64`, got `i32`
| 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/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs
index 65eb2952e..3f122f106 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs
@@ -1,10 +1,6 @@
#![feature(type_alias_impl_trait)]
-pub trait Captures<'a> {}
-
-impl<'a, T: ?Sized> Captures<'a> for T {}
-
-type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
+type Foo<'a, 'b> = impl std::fmt::Debug;
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
(i, i) //~ ERROR concrete type differs from previous
diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
index d7676b8e9..552cf3fda 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
@@ -1,5 +1,5 @@
error: concrete type differs from previous defining opaque type use
- --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:10:5
+ --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5
|
LL | (i, i)
| ^^^^^^
@@ -7,5 +7,5 @@ LL | (i, i)
| expected `&'a i32`, got `&'b i32`
| 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/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs
index 21fca047a..83fd9a1da 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs
@@ -7,11 +7,7 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>)
(a.clone(), a)
}
-pub trait Captures<'a> {}
-
-impl<'a, T: ?Sized> Captures<'a> for T {}
-
-type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
+type Foo<'a, 'b> = impl std::fmt::Debug;
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
(i, j)
diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs
index 9ae2c34b9..da845e861 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs
@@ -8,7 +8,6 @@ type X<A, B> = impl Into<&'static A>;
fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) {
//~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied
- //~| ERROR concrete type differs from previous defining opaque type use
(a, a)
}
diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr
index 0d24d42ba..b5f380746 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr
@@ -10,15 +10,6 @@ help: consider introducing a `where` clause, but there might be an alternative b
LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) where &'static B: From<&A> {
| ++++++++++++++++++++++++++
-error: concrete type differs from previous defining opaque type use
- --> $DIR/multiple-def-uses-in-one-fn.rs:9:45
- |
-LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) {
- | ^^^^^^^^^^^^^^^^^^
- | |
- | expected `&B`, got `&A`
- | this expression supplies two conflicting concrete types for the same opaque type
-
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn2.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn2.stderr
index 0f752212a..c7a4b2115 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn2.stderr
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn2.stderr
@@ -7,5 +7,5 @@ LL | (a.clone(), a)
| expected `A`, got `B`
| 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/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr
index bbe709dcc..c3128ea6f 100644
--- a/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr
+++ b/tests/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr
@@ -13,6 +13,6 @@ LL | (a, b)
= 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/type-alias-impl-trait/mututally-recursive-overflow.rs b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs
new file mode 100644
index 000000000..1ccd1b0cb
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs
@@ -0,0 +1,40 @@
+// edition: 2021
+// build-fail
+//~^^ ERROR overflow evaluating the requirement `<() as B>::Assoc == _`
+
+#![feature(rustc_attrs)]
+#![feature(impl_trait_in_assoc_type)]
+
+#[rustc_coinductive]
+trait A {
+ type Assoc;
+
+ fn test() -> Self::Assoc;
+}
+
+#[rustc_coinductive]
+trait B {
+ type Assoc;
+
+ fn test() -> Self::Assoc;
+}
+
+impl<T: A> B for T {
+ type Assoc = impl Sized;
+
+ fn test() -> <Self as B>::Assoc {
+ <T as A>::test()
+ }
+}
+
+fn main() {
+ <() as A>::test();
+}
+
+impl<T: B> A for T {
+ type Assoc = impl Sized;
+
+ fn test() -> <Self as A>::Assoc {
+ <T as B>::test()
+ }
+}
diff --git a/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr
new file mode 100644
index 000000000..cf6e42bc7
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr
@@ -0,0 +1,5 @@
+error[E0275]: overflow evaluating the requirement `<() as B>::Assoc == _`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.rs b/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.rs
new file mode 100644
index 000000000..fec0fdc46
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.rs
@@ -0,0 +1,9 @@
+#![feature(type_alias_impl_trait)]
+
+pub type Tait = impl Iterator<Item = (&'db Key, impl Iterator)>;
+//~^ ERROR use of undeclared lifetime name `'db`
+//~| ERROR cannot find type `Key` in this scope
+//~| ERROR unconstrained opaque type
+//~| ERROR unconstrained opaque type
+
+pub fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr b/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr
new file mode 100644
index 000000000..d4aeace4a
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-impl-trait-in-tait.stderr
@@ -0,0 +1,47 @@
+error[E0261]: use of undeclared lifetime name `'db`
+ --> $DIR/nested-impl-trait-in-tait.rs:3:40
+ |
+LL | pub type Tait = impl Iterator<Item = (&'db Key, impl Iterator)>;
+ | ^^^ undeclared lifetime
+ |
+ = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
+help: consider making the bound lifetime-generic with a new `'db` lifetime
+ |
+LL | pub type Tait = impl for<'db> Iterator<Item = (&'db Key, impl Iterator)>;
+ | ++++++++
+help: consider introducing lifetime `'db` here
+ |
+LL | pub type Tait<'db> = impl Iterator<Item = (&'db Key, impl Iterator)>;
+ | +++++
+
+error[E0412]: cannot find type `Key` in this scope
+ --> $DIR/nested-impl-trait-in-tait.rs:3:44
+ |
+LL | pub type Tait = impl Iterator<Item = (&'db Key, impl Iterator)>;
+ | ^^^ not found in this scope
+ |
+help: consider importing this struct
+ |
+LL + use std::thread::local_impl::Key;
+ |
+
+error: unconstrained opaque type
+ --> $DIR/nested-impl-trait-in-tait.rs:3:17
+ |
+LL | pub type Tait = impl Iterator<Item = (&'db Key, impl Iterator)>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `Tait` must be used in combination with a concrete type within the same module
+
+error: unconstrained opaque type
+ --> $DIR/nested-impl-trait-in-tait.rs:3:49
+ |
+LL | pub type Tait = impl Iterator<Item = (&'db Key, impl Iterator)>;
+ | ^^^^^^^^^^^^^
+ |
+ = note: `Tait` must be used in combination with a concrete type within the same module
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0261, E0412.
+For more information about an error, try `rustc --explain E0261`.
diff --git a/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs b/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs
new file mode 100644
index 000000000..11b659eec
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs
@@ -0,0 +1,49 @@
+// Regression test for issue #83190, triggering an ICE in borrowck.
+
+// check-pass
+
+pub trait Any {}
+impl<T> Any for T {}
+
+pub trait StreamOnce {
+ type Range;
+}
+
+pub trait Parser<Input>: Sized {
+ type Output;
+ type PartialState;
+ fn map(self) -> Map<Self> {
+ todo!()
+ }
+}
+
+pub struct Map<P>(P);
+impl<I, P: Parser<I, Output = ()>> Parser<I> for Map<P> {
+ type Output = ();
+ type PartialState = P::PartialState;
+}
+
+struct TakeWhile1<Input>(Input);
+impl<I: StreamOnce> Parser<I> for TakeWhile1<I> {
+ type Output = I::Range;
+ type PartialState = ();
+}
+impl<I> TakeWhile1<I> {
+ fn new() -> Self {
+ todo!()
+ }
+}
+
+impl<I, A: Parser<I>> Parser<I> for (A,) {
+ type Output = ();
+ type PartialState = Map<A::Output>;
+}
+
+pub fn metric_stream_parser<'a, I>() -> impl Parser<I, Output = (), PartialState = impl Any + 'a>
+where
+ I: StreamOnce<Range = &'a [()]>,
+{
+ (TakeWhile1::new(),).map()
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs
new file mode 100644
index 000000000..ba705d6f8
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs
@@ -0,0 +1,15 @@
+#![feature(type_alias_impl_trait)]
+
+trait Trait<'a> { type Assoc; }
+impl<'a> Trait<'a> for () { type Assoc = &'a str; }
+
+type WithoutLt = impl Sized;
+fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {}
+//~^ ERROR captures lifetime that does not appear in bounds
+
+type WithLt<'a> = impl Sized + 'a;
+
+fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {}
+//~^ ERROR expected generic lifetime parameter, found `'a`
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr
new file mode 100644
index 000000000..f20873055
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr
@@ -0,0 +1,23 @@
+error[E0700]: hidden type for `WithoutLt` captures lifetime that does not appear in bounds
+ --> $DIR/nested-tait-hrtb.rs:7:62
+ |
+LL | type WithoutLt = impl Sized;
+ | ---------- opaque type defined here
+LL | fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {}
+ | -- ^^
+ | |
+ | hidden type `&'a str` captures the lifetime `'a` as defined here
+
+error[E0792]: expected generic lifetime parameter, found `'a`
+ --> $DIR/nested-tait-hrtb.rs:12:60
+ |
+LL | type WithLt<'a> = impl Sized + 'a;
+ | -- this generic parameter must be used with a generic lifetime parameter
+LL |
+LL | fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {}
+ | ^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0700, E0792.
+For more information about an error, try `rustc --explain E0700`.
diff --git a/tests/ui/type-alias-impl-trait/nested-tait-inference.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference.stderr
index 62db019ed..172ecded7 100644
--- a/tests/ui/type-alias-impl-trait/nested-tait-inference.stderr
+++ b/tests/ui/type-alias-impl-trait/nested-tait-inference.stderr
@@ -9,6 +9,6 @@ LL | ()
|
= help: the trait `Foo<()>` is 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/type-alias-impl-trait/nested-tait-inference2.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr
index f4d96038d..c549ca5b2 100644
--- a/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr
+++ b/tests/ui/type-alias-impl-trait/nested-tait-inference2.stderr
@@ -8,9 +8,9 @@ LL | ()
| -- return type was inferred to be `()` here
|
= help: the following other types implement trait `Foo<A>`:
- <() as Foo<()>>
<() as Foo<u32>>
+ <() as Foo<()>>
-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/type-alias-impl-trait/nested-tait-inference3.stderr b/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr
index b1d947a9c..ce5d30370 100644
--- a/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr
+++ b/tests/ui/type-alias-impl-trait/nested-tait-inference3.stderr
@@ -6,5 +6,5 @@ LL | type FooX = impl Debug;
|
= note: `FooX` must be used in combination with a concrete type within the same module
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/nested.stderr b/tests/ui/type-alias-impl-trait/nested.stderr
index 732af5c0b..a19d4c4eb 100644
--- a/tests/ui/type-alias-impl-trait/nested.stderr
+++ b/tests/ui/type-alias-impl-trait/nested.stderr
@@ -7,6 +7,6 @@ LL | println!("{:?}", bar());
= help: the trait `Debug` is not implemented for `Bar`
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs b/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs
new file mode 100644
index 000000000..5f3dbaa17
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs
@@ -0,0 +1,44 @@
+//! This test checks that we do not walk types in async blocks for
+//! determining the opaque types that appear in a signature. async blocks,
+//! all other coroutines and closures are always private and not part of
+//! a signature. They become part of a signature via `dyn Trait` or `impl Trait`,
+//! which is something that we process abstractly without looking at its hidden
+//! types.
+// edition: 2021
+// check-pass
+
+#![feature(impl_trait_in_assoc_type)]
+
+use std::future::Future;
+
+pub struct MemtableLocalStateStore {
+ mem_table: MemTable,
+}
+
+impl LocalStateStore for MemtableLocalStateStore {
+ type IterStream<'a> = impl Sized + 'a where Self: 'a;
+
+ fn iter(&self) -> impl Future<Output = Self::IterStream<'_>> + '_ {
+ async move { merge_stream(self.mem_table.iter()) }
+ }
+}
+
+trait LocalStateStore {
+ type IterStream<'a>
+ where
+ Self: 'a;
+
+ fn iter(&self) -> impl Future<Output = Self::IterStream<'_>> + '_;
+}
+
+struct MemTable;
+
+impl MemTable {
+ fn iter<'a>(&'a self) -> impl Iterator<Item = &'a ()> {
+ std::iter::empty()
+ }
+}
+
+pub(crate) async fn merge_stream<'a>(mem_table_iter: impl Iterator<Item = &'a ()>) {}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/nested_in_closure.rs b/tests/ui/type-alias-impl-trait/nested_in_closure.rs
new file mode 100644
index 000000000..362f3d53e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/nested_in_closure.rs
@@ -0,0 +1,17 @@
+#![feature(type_alias_impl_trait)]
+// check-pass
+
+fn main() {
+ let x = || {
+ type Tait = impl Sized;
+ let y: Tait = ();
+ };
+
+ let y = || {
+ type Tait = impl std::fmt::Debug;
+ let y: Tait = ();
+ y
+ };
+ let mut z = y();
+ z = ();
+}
diff --git a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs
index 60b6e1aac..07607516c 100644
--- a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs
+++ b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs
@@ -10,11 +10,11 @@ mod my_mod {
5i32
}
- pub fn get_foot() -> Foot {
+ pub fn get_foot(_: Foo) -> Foot {
get_foo() //~ ERROR opaque type's hidden type cannot be another opaque type
}
}
fn main() {
- let _: my_mod::Foot = my_mod::get_foot();
+ let _: my_mod::Foot = my_mod::get_foot(my_mod::get_foo());
}
diff --git a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr
index fa6ecf68d..3e67a162f 100644
--- a/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr
+++ b/tests/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr
@@ -15,5 +15,5 @@ note: opaque type being used as hidden type
LL | pub type Foo = impl Debug;
| ^^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr b/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr
index f3e8ae9c7..fabc80c0a 100644
--- a/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr
+++ b/tests/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr
@@ -6,5 +6,5 @@ LL | pub type Foo = impl Copy;
|
= note: `Foo` must be used in combination with a concrete type within the same module
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr b/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr
index ae03a5b3e..863282a0f 100644
--- a/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr
+++ b/tests/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr
@@ -11,6 +11,11 @@ LL | let _: &str = bomp();
|
= note: expected reference `&str`
found opaque type `Boo`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/no_revealing_outside_defining_module.rs:14:4
+ |
+LL | fn bomp2() {
+ | ^^^^^
error[E0308]: mismatched types
--> $DIR/no_revealing_outside_defining_module.rs:19:5
@@ -25,6 +30,11 @@ LL | ""
|
= note: expected opaque type `Boo`
found reference `&'static str`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/no_revealing_outside_defining_module.rs:18:4
+ |
+LL | fn bomp() -> boo::Boo {
+ | ^^^^
error: aborting due to 2 previous errors
diff --git a/tests/ui/type-alias-impl-trait/non-defining-method.rs b/tests/ui/type-alias-impl-trait/non-defining-method.rs
new file mode 100644
index 000000000..2f4a7052f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/non-defining-method.rs
@@ -0,0 +1,21 @@
+//! This test checks that we don't follow up
+//! with type mismatch errors of opaque types
+//! with their hidden types if we failed the
+//! defining scope check at the signature level.
+
+#![feature(impl_trait_in_assoc_type)]
+
+trait Foo {
+ type Bar<T>;
+ fn foo() -> Self::Bar<u32>;
+ fn bar<T>() -> Self::Bar<T>;
+}
+
+impl Foo for () {
+ type Bar<T> = impl Sized;
+ fn foo() -> Self::Bar<u32> {}
+ //~^ ERROR non-defining opaque type use
+ fn bar<T>() -> Self::Bar<T> {}
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/non-defining-method.stderr b/tests/ui/type-alias-impl-trait/non-defining-method.stderr
new file mode 100644
index 000000000..2ba4c90a1
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/non-defining-method.stderr
@@ -0,0 +1,15 @@
+error[E0792]: non-defining opaque type use in defining scope
+ --> $DIR/non-defining-method.rs:16:17
+ |
+LL | fn foo() -> Self::Bar<u32> {}
+ | ^^^^^^^^^^^^^^ argument `u32` is not a generic parameter
+ |
+note: for this opaque type
+ --> $DIR/non-defining-method.rs:15:19
+ |
+LL | type Bar<T> = impl Sized;
+ | ^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/normalize-alias-type.rs b/tests/ui/type-alias-impl-trait/normalize-alias-type.rs
new file mode 100644
index 000000000..7c62002b9
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/normalize-alias-type.rs
@@ -0,0 +1,32 @@
+// check-pass
+// compile-flags: -Z mir-opt-level=3
+#![feature(type_alias_impl_trait)]
+#![crate_type = "lib"]
+pub trait Tr {
+ fn get(&self) -> u32;
+}
+
+impl Tr for (u32,) {
+ #[inline]
+ fn get(&self) -> u32 { self.0 }
+}
+
+pub fn tr1() -> impl Tr {
+ (32,)
+}
+
+pub fn tr2() -> impl Tr {
+ struct Inner {
+ x: X,
+ }
+ type X = impl Tr;
+ impl Tr for Inner {
+ fn get(&self) -> u32 {
+ self.x.get()
+ }
+ }
+
+ Inner {
+ x: tr1(),
+ }
+}
diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr
new file mode 100644
index 000000000..dd2737c70
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr
@@ -0,0 +1,55 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/normalize-hidden-types.rs:25:20
+ |
+LL | fn define() -> Opaque {
+ | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(<u8 as Trait>::Gat<'a>)`
+ |
+note: previous use here
+ --> $DIR/normalize-hidden-types.rs:27:9
+ |
+LL | dyn_hoops::<_>(0)
+ | ^^^^^^^^^^^^^^^^^
+
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/normalize-hidden-types.rs:34:22
+ |
+LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) }
+ | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(<u8 as Trait>::Gat<'a>)`
+ |
+note: previous use here
+ --> $DIR/normalize-hidden-types.rs:34:31
+ |
+LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) }
+ | ^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+ --> $DIR/normalize-hidden-types.rs:44:25
+ |
+LL | type Opaque = impl Sized;
+ | ---------- the expected opaque type
+...
+LL | let _: Opaque = dyn_hoops::<u8>(0);
+ | ------ ^^^^^^^^^^^^^^^^^^ expected opaque type, found `*const dyn FnOnce(())`
+ | |
+ | expected due to this
+ |
+ = note: expected opaque type `typeck::Opaque`
+ found raw pointer `*const (dyn FnOnce(()) + 'static)`
+ = help: consider constraining the associated type `<u8 as Trait>::Gat<'_>` to `()` or calling a method that returns `<u8 as Trait>::Gat<'_>`
+ = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
+
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/normalize-hidden-types.rs:54:25
+ |
+LL | let _: Opaque = dyn_hoops::<_>(0);
+ | ^^^^^^^^^^^^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(<u8 as Trait>::Gat<'a>)`
+ |
+note: previous use here
+ --> $DIR/normalize-hidden-types.rs:56:9
+ |
+LL | None
+ | ^^^^
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs
new file mode 100644
index 000000000..371cac6da
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs
@@ -0,0 +1,60 @@
+// Regression test for #112691
+//
+// revisions: current next
+// [next] compile-flags: -Znext-solver
+// [next] check-pass
+// [current]: known-bug: #112691
+
+#![feature(type_alias_impl_trait)]
+
+trait Trait {
+ type Gat<'lt>;
+}
+
+impl Trait for u8 {
+ type Gat<'lt> = ();
+}
+
+fn dyn_hoops<T: Trait>(_: T) -> *const dyn FnOnce(T::Gat<'_>) {
+ loop {}
+}
+
+mod typeof_1 {
+ use super::*;
+ type Opaque = impl Sized;
+ fn define() -> Opaque {
+ //[current]~^ ERROR concrete type differs
+ dyn_hoops::<_>(0)
+ }
+}
+
+mod typeof_2 {
+ use super::*;
+ type Opaque = impl Sized;
+ fn define_1() -> Opaque { dyn_hoops::<_>(0) }
+ //[current]~^ ERROR concrete type differs
+ fn define_2() -> Opaque { dyn_hoops::<u8>(0) }
+}
+
+mod typeck {
+ use super::*;
+ type Opaque = impl Sized;
+ fn define() -> Option<Opaque> {
+ let _: Opaque = dyn_hoops::<_>(0);
+ let _: Opaque = dyn_hoops::<u8>(0);
+ //[current]~^ ERROR mismatched types
+ None
+ }
+}
+
+mod borrowck {
+ use super::*;
+ type Opaque = impl Sized;
+ fn define() -> Option<Opaque> {
+ let _: Opaque = dyn_hoops::<_>(0);
+ //[current]~^ ERROR concrete type differs
+ None
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs
new file mode 100644
index 000000000..131f8d999
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.rs
@@ -0,0 +1,33 @@
+#![feature(impl_trait_in_assoc_type)]
+
+trait Foo<T> {
+ type Assoc;
+
+ fn test() -> u32;
+}
+
+struct DefinesOpaque;
+impl Foo<DefinesOpaque> for () {
+ type Assoc = impl Sized;
+
+ // This test's return type is `u32`, *not* the opaque that is defined above.
+ // Previously we were only checking that the self type of the assoc matched,
+ // but this doesn't account for other impls with different trait substs.
+ fn test() -> <() as Foo<NoOpaques>>::Assoc {
+ let _: <Self as Foo<DefinesOpaque>>::Assoc = "";
+ //~^ ERROR mismatched types
+
+ 1
+ }
+}
+
+struct NoOpaques;
+impl Foo<NoOpaques> for () {
+ type Assoc = u32;
+
+ fn test() -> u32 {
+ 1
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr
new file mode 100644
index 000000000..d4528fb76
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/not-matching-trait-refs-isnt-defining.stderr
@@ -0,0 +1,22 @@
+error[E0308]: mismatched types
+ --> $DIR/not-matching-trait-refs-isnt-defining.rs:17:54
+ |
+LL | type Assoc = impl Sized;
+ | ---------- the expected opaque type
+...
+LL | let _: <Self as Foo<DefinesOpaque>>::Assoc = "";
+ | ----------------------------------- ^^ expected opaque type, found `&str`
+ | |
+ | expected due to this
+ |
+ = note: expected opaque type `<() as Foo<DefinesOpaque>>::Assoc`
+ found reference `&'static str`
+note: this item must have the opaque type in its signature in order to be able to register hidden types
+ --> $DIR/not-matching-trait-refs-isnt-defining.rs:16:8
+ |
+LL | fn test() -> <() as Foo<NoOpaques>>::Assoc {
+ | ^^^^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.fixed b/tests/ui/type-alias-impl-trait/not_well_formed.fixed
new file mode 100644
index 000000000..d98e83ff6
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/not_well_formed.fixed
@@ -0,0 +1,19 @@
+// run-rustfix
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+fn main() {}
+
+trait TraitWithAssoc {
+ type Assoc;
+}
+
+type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>; //~ associated type `Assoc` not found for `V`
+
+trait Trait<U> {}
+
+impl<W> Trait<W> for () {}
+
+fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T> {
+ ()
+}
diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.rs b/tests/ui/type-alias-impl-trait/not_well_formed.rs
index fbb7a4d58..18f173a69 100644
--- a/tests/ui/type-alias-impl-trait/not_well_formed.rs
+++ b/tests/ui/type-alias-impl-trait/not_well_formed.rs
@@ -1,4 +1,6 @@
+// run-rustfix
#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.stderr b/tests/ui/type-alias-impl-trait/not_well_formed.stderr
index c36b95f47..dbd80ffa4 100644
--- a/tests/ui/type-alias-impl-trait/not_well_formed.stderr
+++ b/tests/ui/type-alias-impl-trait/not_well_formed.stderr
@@ -1,9 +1,14 @@
error[E0220]: associated type `Assoc` not found for `V`
- --> $DIR/not_well_formed.rs:9:29
+ --> $DIR/not_well_formed.rs:11:29
|
LL | type Foo<V> = impl Trait<V::Assoc>;
- | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc`
+ | ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc`
+ |
+help: consider restricting type parameter `V`
+ |
+LL | type Foo<V: TraitWithAssoc> = impl Trait<V::Assoc>;
+ | ++++++++++++++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0220`.
diff --git a/tests/ui/type-alias-impl-trait/obligation_ice.rs b/tests/ui/type-alias-impl-trait/obligation_ice.rs
new file mode 100644
index 000000000..5aef04ff1
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/obligation_ice.rs
@@ -0,0 +1,17 @@
+#![feature(type_alias_impl_trait)]
+// check-pass
+
+use std::iter::{once, Chain};
+
+trait Trait<'a, 'b: 'a> {}
+
+impl<'a, 'b: 'a, T> Trait<'a, 'b> for std::iter::Cloned<T> {}
+
+type I<'a, 'b: 'a, A: Trait<'a, 'b>> = Chain<A, impl Iterator<Item = &'static str>>;
+fn test2<'a, 'b, A: Trait<'a, 'b> + Iterator<Item = &'static str>>(x: A) -> I<'a, 'b, A> {
+ x.chain(once("5"))
+}
+
+fn main() {
+ assert_eq!(vec!["1", "3", "5"], test2(["1", "3"].iter().cloned()).collect::<Vec<_>>());
+}
diff --git a/tests/ui/type-alias-impl-trait/privacy.rs b/tests/ui/type-alias-impl-trait/privacy.rs
new file mode 100644
index 000000000..3efbfaf09
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/privacy.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Foo = (impl Sized, u8);
+pub fn foo() -> Foo {
+ //~^ WARNING type alias `Foo` is more private than the item `foo`
+ (42, 42)
+}
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/privacy.stderr b/tests/ui/type-alias-impl-trait/privacy.stderr
new file mode 100644
index 000000000..50870905c
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/privacy.stderr
@@ -0,0 +1,15 @@
+warning: type alias `Foo` is more private than the item `foo`
+ --> $DIR/privacy.rs:6:1
+ |
+LL | pub fn foo() -> Foo {
+ | ^^^^^^^^^^^^^^^^^^^ function `foo` is reachable at visibility `pub`
+ |
+note: but type alias `Foo` is only usable at visibility `pub(crate)`
+ --> $DIR/privacy.rs:5:1
+ |
+LL | type Foo = (impl Sized, u8);
+ | ^^^^^^^^
+ = note: `#[warn(private_interfaces)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs b/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs
new file mode 100644
index 000000000..3d1759097
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.rs
@@ -0,0 +1,17 @@
+// test for #113326
+#![feature(type_alias_impl_trait)]
+
+pub type Diff = impl Fn(usize) -> usize;
+
+pub fn lift() -> Diff {
+ |_: usize |loop {}
+}
+
+pub fn add(
+ n: Diff,
+ m: Diff,
+) -> Diff {
+ move |x: usize| m(n(x)) //~ ERROR: concrete type differs
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr
new file mode 100644
index 000000000..e8925b9b4
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-fn-tait.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/recursive-fn-tait.rs:14:5
+ |
+LL | move |x: usize| m(n(x))
+ | ^^^^^^^^^^^^^^^^^^^^^^^ expected `{closure@$DIR/recursive-fn-tait.rs:7:5: 7:16}`, got `{closure@$DIR/recursive-fn-tait.rs:14:5: 14:20}`
+ |
+note: previous use here
+ --> $DIR/recursive-fn-tait.rs:7:5
+ |
+LL | |_: usize |loop {}
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs
new file mode 100644
index 000000000..10588398c
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs
@@ -0,0 +1,21 @@
+// issue: 113314
+
+#![feature(type_alias_impl_trait)]
+
+type Op = impl std::fmt::Display;
+fn foo() -> Op { &"hello world" }
+
+fn transform<S>() -> impl std::fmt::Display {
+ &0usize
+}
+fn bad() -> Op {
+ transform::<Op>()
+ //~^ ERROR concrete type differs from previous defining opaque type use
+}
+
+fn main() {
+ let mut x = foo();
+ println!("{x}");
+ x = bad();
+ println!("{x}");
+}
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr
new file mode 100644
index 000000000..eec35548c
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/recursive-tait-conflicting-defn-2.rs:12:5
+ |
+LL | transform::<Op>()
+ | ^^^^^^^^^^^^^^^^^ expected `&'static &'static str`, got `impl std::fmt::Display`
+ |
+note: previous use here
+ --> $DIR/recursive-tait-conflicting-defn-2.rs:6:18
+ |
+LL | fn foo() -> Op { &"hello world" }
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs
new file mode 100644
index 000000000..e221f4f3f
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs
@@ -0,0 +1,34 @@
+// issue: 113596
+
+#![feature(type_alias_impl_trait)]
+
+trait Test {}
+
+struct A;
+
+impl Test for A {}
+
+struct B<T> {
+ inner: T,
+}
+
+impl<T: Test> Test for B<T> {}
+
+type TestImpl = impl Test;
+
+fn test() -> TestImpl {
+ A
+}
+
+fn make_option() -> Option<TestImpl> {
+ Some(test())
+}
+
+fn make_option2() -> Option<TestImpl> {
+ let inner = make_option().unwrap();
+
+ Some(B { inner })
+ //~^ ERROR concrete type differs from previous defining opaque type use
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr
new file mode 100644
index 000000000..05825e686
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/recursive-tait-conflicting-defn.rs:30:3
+ |
+LL | Some(B { inner })
+ | ^^^^^^^^^^^^^^^^^ expected `A`, got `B<TestImpl>`
+ |
+note: previous use here
+ --> $DIR/recursive-tait-conflicting-defn.rs:20:3
+ |
+LL | A
+ | ^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/type-alias-impl-trait/reveal_local.rs b/tests/ui/type-alias-impl-trait/reveal_local.rs
index 7ecb55353..07fd989b0 100644
--- a/tests/ui/type-alias-impl-trait/reveal_local.rs
+++ b/tests/ui/type-alias-impl-trait/reveal_local.rs
@@ -3,23 +3,26 @@
use std::fmt::Debug;
type Foo = impl Debug;
-//~^ ERROR cycle detected
-fn is_send<T: Send>() { }
+fn is_send<T: Send>() {}
fn not_good() {
// Error: this function does not constrain `Foo` to any particular
// hidden type, so it cannot rely on `Send` being true.
is_send::<Foo>();
+ //~^ ERROR: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
}
-fn not_gooder() {
+fn not_gooder() -> Foo {
// Constrain `Foo = u32`
let x: Foo = 22_u32;
// while we could know this from the hidden type, it would
// need extra roundabout logic to support it.
is_send::<Foo>();
+ //~^ ERROR: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
+
+ x
}
fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr
index 27fded333..796e2d011 100644
--- a/tests/ui/type-alias-impl-trait/reveal_local.stderr
+++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr
@@ -1,28 +1,46 @@
-error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
+error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
+ --> $DIR/reveal_local.rs:12:15
+ |
+LL | is_send::<Foo>();
+ | ^^^
+ |
+note: opaque type is declared here
--> $DIR/reveal_local.rs:5:12
|
LL | type Foo = impl Debug;
| ^^^^^^^^^^
+note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
+ --> $DIR/reveal_local.rs:9:4
|
-note: ...which requires type-checking `not_good`...
- --> $DIR/reveal_local.rs:13:5
+LL | fn not_good() {
+ | ^^^^^^^^
+note: required by a bound in `is_send`
+ --> $DIR/reveal_local.rs:7:15
+ |
+LL | fn is_send<T: Send>() {}
+ | ^^^^ required by this bound in `is_send`
+
+error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits
+ --> $DIR/reveal_local.rs:22:15
|
LL | is_send::<Foo>();
- | ^^^^^^^^^^^^^^
- = note: ...which requires evaluating trait selection obligation `Foo: core::marker::Send`...
- = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
-note: cycle used when checking item types in top-level module
- --> $DIR/reveal_local.rs:1:1
- |
-LL | / #![feature(type_alias_impl_trait)]
-LL | |
-LL | | use std::fmt::Debug;
-LL | |
-... |
-LL | |
-LL | | fn main() {}
- | |____________^
+ | ^^^
+ |
+note: opaque type is declared here
+ --> $DIR/reveal_local.rs:5:12
+ |
+LL | type Foo = impl Debug;
+ | ^^^^^^^^^^
+note: this item depends on auto traits of the hidden type, but may also be registering the hidden type. This is not supported right now. You can try moving the opaque type and the item that actually registers a hidden type into a new submodule
+ --> $DIR/reveal_local.rs:16:4
+ |
+LL | fn not_gooder() -> Foo {
+ | ^^^^^^^^^^
+note: required by a bound in `is_send`
+ --> $DIR/reveal_local.rs:7:15
+ |
+LL | fn is_send<T: Send>() {}
+ | ^^^^ required by this bound in `is_send`
-error: aborting due to previous error
+error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.stderr
new file mode 100644
index 000000000..d4e2f9535
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.current.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(get_rpit::{opaque#0}), args: [] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: no-location (#0), ty: Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{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(get_rpit), []), ()], def_id: DefId(ops::function::FnOnce::Output) }, Term::Ty(Alias(Opaque, AliasTy { args: [], def_id: DefId(Opaque::{opaque#0}) }))), bound_vars: [] } } }
+ --> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5
+ |
+LL | query(get_rpit);
+ | ^^^^^^^^^^^^^^^
+ |
+
+ --> $DIR/rpit_tait_equality_in_canonical_query.rs:28:5
+ |
+LL | query(get_rpit);
+ | ^^^^^^^^^^^^^^^
+
+
+
+
+
+
+
+query stack during panic:
+end of query stack
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs
new file mode 100644
index 000000000..222841f34
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs
@@ -0,0 +1,32 @@
+//! This tries to prove the APIT's bounds in a canonical query,
+//! which doesn't know anything about the defining scope of either
+//! opaque type and thus makes a random choice as to which opaque type
+//! becomes the hidden type of the other. When we leave the canonical
+//! query, we attempt to actually check the defining anchor, but now we
+//! have a situation where the RPIT gets constrained outside its anchor.
+
+// revisions: current next
+//[next] compile-flags: -Znext-solver
+//[next] check-pass
+
+//[current] known-bug: #108498
+//[current] failure-status: 101
+//[current] normalize-stderr-test: "DefId\(.*?\]::" -> "DefId("
+//[current] normalize-stderr-test: "(?m)note: .*$" -> ""
+//[current] normalize-stderr-test: "(?m)^ *\d+: .*\n" -> ""
+//[current] normalize-stderr-test: "(?m)^ *at .*\n" -> ""
+
+#![feature(type_alias_impl_trait)]
+
+type Opaque = impl Sized;
+
+fn get_rpit() -> impl Clone {}
+
+fn query(_: impl FnOnce() -> Opaque) {}
+
+fn test() -> Opaque {
+ query(get_rpit);
+ get_rpit()
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs
new file mode 100644
index 000000000..9d7e647dd
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query_2.rs
@@ -0,0 +1,18 @@
+// The canonical query `Projection(<get_rpit as FnOnce>::Output = Opaque)`
+// is the *only* site that defines `Opaque` in MIR typeck.
+//
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Opaque = impl Sized;
+
+fn get_rpit() -> impl Sized {}
+
+fn query(_: impl FnOnce() -> Opaque) {}
+
+fn test(_: Opaque) {
+ query(get_rpit);
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/self-referential-2.stderr b/tests/ui/type-alias-impl-trait/self-referential-2.stderr
index c2cf70687..ab57812ba 100644
--- a/tests/ui/type-alias-impl-trait/self-referential-2.stderr
+++ b/tests/ui/type-alias-impl-trait/self-referential-2.stderr
@@ -9,6 +9,6 @@ LL | 42_i32
= help: the trait `PartialEq<Foo>` is not implemented for `i32`
= help: the trait `PartialEq` is implemented for `i32`
-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/type-alias-impl-trait/self-referential-3.rs b/tests/ui/type-alias-impl-trait/self-referential-3.rs
index d40715717..922ac6620 100644
--- a/tests/ui/type-alias-impl-trait/self-referential-3.rs
+++ b/tests/ui/type-alias-impl-trait/self-referential-3.rs
@@ -1,9 +1,11 @@
-// run-pass
+// ignore-compare-mode-next-solver (hangs)
+
#![feature(type_alias_impl_trait)]
type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug;
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
+ //~^ ERROR can't compare `&i32` with `Bar<'a, 'b>`
i
}
diff --git a/tests/ui/type-alias-impl-trait/self-referential-3.stderr b/tests/ui/type-alias-impl-trait/self-referential-3.stderr
new file mode 100644
index 000000000..32eac622e
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/self-referential-3.stderr
@@ -0,0 +1,15 @@
+error[E0277]: can't compare `&i32` with `Bar<'a, 'b>`
+ --> $DIR/self-referential-3.rs:7:31
+ |
+LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
+ | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'a, 'b>`
+LL |
+LL | i
+ | - return type was inferred to be `&i32` here
+ |
+ = help: the trait `PartialEq<Bar<'a, 'b>>` is not implemented for `&i32`
+ = help: the trait `PartialEq` is implemented for `i32`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/type-alias-impl-trait/self-referential-4.rs b/tests/ui/type-alias-impl-trait/self-referential-4.rs
index 36742c8ad..caa9e33ba 100644
--- a/tests/ui/type-alias-impl-trait/self-referential-4.rs
+++ b/tests/ui/type-alias-impl-trait/self-referential-4.rs
@@ -1,3 +1,5 @@
+// ignore-compare-mode-next-solver (hangs)
+
#![feature(type_alias_impl_trait)]
type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'static>> + std::fmt::Debug;
diff --git a/tests/ui/type-alias-impl-trait/self-referential-4.stderr b/tests/ui/type-alias-impl-trait/self-referential-4.stderr
index 98c762e3d..e7f9e232a 100644
--- a/tests/ui/type-alias-impl-trait/self-referential-4.stderr
+++ b/tests/ui/type-alias-impl-trait/self-referential-4.stderr
@@ -1,5 +1,5 @@
error[E0277]: can't compare `&i32` with `Bar<'b, 'static>`
- --> $DIR/self-referential-4.rs:5:31
+ --> $DIR/self-referential-4.rs:7:31
|
LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
| ^^^^^^^^^^^ no implementation for `&i32 == Bar<'b, 'static>`
@@ -10,7 +10,7 @@ LL | i
= help: the trait `PartialEq` is implemented for `i32`
error[E0277]: can't compare `&i32` with `Foo<'static, 'b>`
- --> $DIR/self-referential-4.rs:11:31
+ --> $DIR/self-referential-4.rs:13:31
|
LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> {
| ^^^^^^^^^^^ no implementation for `&i32 == Foo<'static, 'b>`
@@ -21,7 +21,7 @@ LL | i
= help: the trait `PartialEq` is implemented for `i32`
error[E0277]: can't compare `&i32` with `Moo<'static, 'a>`
- --> $DIR/self-referential-4.rs:17:31
+ --> $DIR/self-referential-4.rs:19:31
|
LL | fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> {
| ^^^^^^^^^^^ no implementation for `&i32 == Moo<'static, 'a>`
diff --git a/tests/ui/type-alias-impl-trait/self-referential.rs b/tests/ui/type-alias-impl-trait/self-referential.rs
index 3ff5406a3..0900d7279 100644
--- a/tests/ui/type-alias-impl-trait/self-referential.rs
+++ b/tests/ui/type-alias-impl-trait/self-referential.rs
@@ -1,3 +1,5 @@
+// ignore-compare-mode-next-solver (hangs)
+
#![feature(type_alias_impl_trait)]
type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'a>> + std::fmt::Debug;
@@ -10,7 +12,7 @@ fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
type Foo<'a, 'b> = (i32, impl PartialEq<Foo<'a, 'b>> + std::fmt::Debug);
fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> {
- //~^ ERROR can't compare `&i32` with `(i32, &i32)`
+ //~^ ERROR can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})`
(42, i)
}
diff --git a/tests/ui/type-alias-impl-trait/self-referential.stderr b/tests/ui/type-alias-impl-trait/self-referential.stderr
index aff489d70..27506b8d0 100644
--- a/tests/ui/type-alias-impl-trait/self-referential.stderr
+++ b/tests/ui/type-alias-impl-trait/self-referential.stderr
@@ -1,5 +1,5 @@
error[E0277]: can't compare `&i32` with `Bar<'b, 'a>`
- --> $DIR/self-referential.rs:5:31
+ --> $DIR/self-referential.rs:7:31
|
LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
| ^^^^^^^^^^^ no implementation for `&i32 == Bar<'b, 'a>`
@@ -10,20 +10,20 @@ LL | i
= help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32`
= help: the trait `PartialEq` is implemented for `i32`
-error[E0277]: can't compare `&i32` with `(i32, &i32)`
- --> $DIR/self-referential.rs:12:31
+error[E0277]: can't compare `&i32` with `(i32, Foo<'a, 'b>::{opaque#0})`
+ --> $DIR/self-referential.rs:14:31
|
LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> {
- | ^^^^^^^^^^^ no implementation for `&i32 == (i32, &i32)`
+ | ^^^^^^^^^^^ no implementation for `&i32 == (i32, Foo<'a, 'b>::{opaque#0})`
LL |
LL | (42, i)
| ------- return type was inferred to be `(i32, &i32)` here
|
- = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32`
+ = help: the trait `PartialEq<(i32, Foo<'a, 'b>::{opaque#0})>` is not implemented for `&i32`
= help: the trait `PartialEq` is implemented for `i32`
error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
- --> $DIR/self-referential.rs:19:31
+ --> $DIR/self-referential.rs:21:31
|
LL | fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> {
| ^^^^^^^^^^^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})`
diff --git a/tests/ui/type-alias-impl-trait/self_implication.rs b/tests/ui/type-alias-impl-trait/self_implication.rs
index 4e805ee30..65659a0f3 100644
--- a/tests/ui/type-alias-impl-trait/self_implication.rs
+++ b/tests/ui/type-alias-impl-trait/self_implication.rs
@@ -22,9 +22,9 @@ fn bar() {
}
// desugared
- type FooX<'a> = impl Sized;
+ type FooX = impl Sized;
impl<'a> Foo<'a> {
- fn foo(&self) -> FooX<'a> {}
+ fn foo(&self) -> FooX {}
}
// use site
diff --git a/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr b/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr
index dbc183f54..b1ccd5cc4 100644
--- a/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr
+++ b/tests/ui/type-alias-impl-trait/structural-match-no-leak.stderr
@@ -4,5 +4,5 @@ error: `Bar` cannot be used in patterns
LL | LEAK_FREE => (),
| ^^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/structural-match.stderr b/tests/ui/type-alias-impl-trait/structural-match.stderr
index 61287f268..b0415db0e 100644
--- a/tests/ui/type-alias-impl-trait/structural-match.stderr
+++ b/tests/ui/type-alias-impl-trait/structural-match.stderr
@@ -4,5 +4,5 @@ error: `Foo` cannot be used in patterns
LL | VALUE => (),
| ^^^^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/tait-normalize.rs b/tests/ui/type-alias-impl-trait/tait-normalize.rs
new file mode 100644
index 000000000..26d94dbb4
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/tait-normalize.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+fn enum_upvar() {
+ type T = impl Copy;
+ let foo: T = Some((1u32, 2u32));
+ let x = move || match foo {
+ None => (),
+ Some((a, b)) => (),
+ };
+}
+
+fn main(){}
diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs
index 857066c78..9796823a7 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.rs
@@ -4,7 +4,7 @@
// FIXME: this is ruled out for now but should work
type Foo = fn() -> impl Send;
-//~^ 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 make_foo() -> Foo {
|| 15
diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr
index ff375b2ff..5641ff301 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fn-type.stderr
@@ -1,9 +1,9 @@
-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/type-alias-impl-trait-fn-type.rs:6:20
|
LL | type Foo = fn() -> impl Send;
| ^^^^^^^^^
-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/type-alias-impl-trait/type-alias-impl-trait-fns.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs
index 07c891f06..4e7388517 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-fns.rs
@@ -4,20 +4,20 @@
// Regression test for issue #61863
-pub trait MyTrait {}
+trait MyTrait {}
#[derive(Debug)]
-pub struct MyStruct {
+struct MyStruct {
v: u64,
}
impl MyTrait for MyStruct {}
-pub fn bla() -> TE {
+fn bla() -> TE {
return MyStruct { v: 1 };
}
-pub fn bla2() -> TE {
+fn bla2() -> TE {
bla()
}
diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr
index 8cdce2f8e..cff269530 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.stderr
@@ -4,6 +4,6 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait,
LL | impl<'a, I: Iterator<Item = i32>> Trait for (i32, I) {
| ^^ unconstrained lifetime 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/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr
index a770eeac3..3d43fbe0d 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr
@@ -6,5 +6,5 @@ LL | type Foo = impl Fn() -> Foo;
|
= note: `Foo` must be used in combination with a concrete type within the same module
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr
index 3f3699ce5..e2dc88798 100644
--- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr
+++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr
@@ -6,5 +6,5 @@ LL | type Foo = impl Bar<Foo, Item = Foo>;
|
= note: `Foo` must be used in combination with a concrete type within the same module
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.rs b/tests/ui/type-alias-impl-trait/type_of_a_let.rs
index 4e9d1788b..361611715 100644
--- a/tests/ui/type-alias-impl-trait/type_of_a_let.rs
+++ b/tests/ui/type-alias-impl-trait/type_of_a_let.rs
@@ -5,16 +5,16 @@ use std::fmt::Debug;
type Foo = impl Debug;
-fn foo1() -> u32 {
+fn foo1() -> (u32, Foo) {
let x: Foo = 22_u32;
- x
+ (x, todo!())
}
-fn foo2() -> u32 {
+fn foo2() -> (u32, Foo) {
let x: Foo = 22_u32;
let y: Foo = x;
same_type((x, y)); //~ ERROR use of moved value
- y //~ ERROR use of moved value
+ (y, todo!()) //~ ERROR use of moved value
}
fn same_type<T>(x: (T, T)) {}
diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.stderr b/tests/ui/type-alias-impl-trait/type_of_a_let.stderr
index 1dabe4586..7d7cad874 100644
--- a/tests/ui/type-alias-impl-trait/type_of_a_let.stderr
+++ b/tests/ui/type-alias-impl-trait/type_of_a_let.stderr
@@ -9,14 +9,14 @@ LL | same_type((x, y));
| ^ value used here after move
error[E0382]: use of moved value: `y`
- --> $DIR/type_of_a_let.rs:17:5
+ --> $DIR/type_of_a_let.rs:17:6
|
LL | let y: Foo = x;
| - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait
LL | same_type((x, y));
| - value moved here
-LL | y
- | ^ value used here after move
+LL | (y, todo!())
+ | ^ value used here after move
error: aborting due to 2 previous errors
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs
new file mode 100644
index 000000000..ae3d317ab
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs
@@ -0,0 +1,14 @@
+#![feature(type_alias_impl_trait)]
+
+type Tait = impl Copy;
+// Make sure that this TAIT isn't considered unconstrained...
+
+fn empty_opaque() -> Tait {
+ if false {
+ match empty_opaque() {}
+ //~^ ERROR non-empty
+ }
+ 0u8
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr
new file mode 100644
index 000000000..6d9c8eabf
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr
@@ -0,0 +1,17 @@
+error[E0004]: non-exhaustive patterns: type `Tait` is non-empty
+ --> $DIR/unconstrained-due-to-bad-pattern.rs:8:15
+ |
+LL | match empty_opaque() {}
+ | ^^^^^^^^^^^^^^
+ |
+ = note: the matched value is of type `Tait`
+help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
+ |
+LL ~ match empty_opaque() {
+LL + _ => todo!(),
+LL + }
+ |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs
new file mode 100644
index 000000000..b35100670
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs
@@ -0,0 +1,25 @@
+#![feature(type_alias_impl_trait)]
+
+use std::fmt::Display;
+
+type Opaque<X> = impl Sized + 'static;
+fn define<X>() -> Opaque<X> {}
+
+trait Trait {
+ type Assoc: Display;
+}
+impl<'a> Trait for Opaque<&'a str> {
+ //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ type Assoc = &'a str;
+}
+
+// ======= Exploit =======
+
+fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
+ Box::new(s)
+}
+
+fn main() {
+ let val = extend::<Opaque<&'_ str>>(&String::from("blah blah blah"));
+ println!("{}", val);
+}
diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr
new file mode 100644
index 000000000..6206f169c
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
+ --> $DIR/unconstrained-impl-param.rs:11:6
+ |
+LL | impl<'a> Trait for Opaque<&'a str> {
+ | ^^ 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/type-alias-impl-trait/under-binder.rs b/tests/ui/type-alias-impl-trait/under-binder.rs
new file mode 100644
index 000000000..caf21d640
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/under-binder.rs
@@ -0,0 +1,9 @@
+#![feature(type_alias_impl_trait)]
+
+type Opaque<'a> = impl Sized + 'a;
+
+fn test(f: fn(u8)) -> fn(Opaque<'_>) {
+ f //~ ERROR E0792
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/under-binder.stderr b/tests/ui/type-alias-impl-trait/under-binder.stderr
new file mode 100644
index 000000000..f4a121ce4
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/under-binder.stderr
@@ -0,0 +1,12 @@
+error[E0792]: expected generic lifetime parameter, found `'_`
+ --> $DIR/under-binder.rs:6:5
+ |
+LL | type Opaque<'a> = impl Sized + 'a;
+ | -- this generic parameter must be used with a generic lifetime parameter
+...
+LL | f
+ | ^
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/type-alias-impl-trait/underconstrained_generic.stderr b/tests/ui/type-alias-impl-trait/underconstrained_generic.stderr
index 103636b6c..e4de92459 100644
--- a/tests/ui/type-alias-impl-trait/underconstrained_generic.stderr
+++ b/tests/ui/type-alias-impl-trait/underconstrained_generic.stderr
@@ -16,6 +16,6 @@ help: consider restricting type parameter `T`
LL | type Converter<T: Trait> = impl ProofForConversion<T>;
| +++++++
-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/type-alias-impl-trait/underconstrained_lifetime.stderr b/tests/ui/type-alias-impl-trait/underconstrained_lifetime.stderr
index 12d85a49d..34b50fb1f 100644
--- a/tests/ui/type-alias-impl-trait/underconstrained_lifetime.stderr
+++ b/tests/ui/type-alias-impl-trait/underconstrained_lifetime.stderr
@@ -15,6 +15,6 @@ note: but the referenced data is only valid for the lifetime `'a` as defined her
LL | type Converter<'a, 'b> = impl ProofForConversion<'a, 'b>;
| ^^
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0491`.
diff --git a/tests/ui/type-alias-impl-trait/variance.rs b/tests/ui/type-alias-impl-trait/variance.rs
new file mode 100644
index 000000000..e92cf2513
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/variance.rs
@@ -0,0 +1,44 @@
+#![feature(rustc_attrs, type_alias_impl_trait, impl_trait_in_assoc_type)]
+#![allow(internal_features)]
+#![rustc_variance_of_opaques]
+
+trait Captures<'a> {}
+impl<T> Captures<'_> for T {}
+
+type NotCapturedEarly<'a> = impl Sized; //~ [o]
+
+type CapturedEarly<'a> = impl Sized + Captures<'a>; //~ [o]
+
+// TAIT does *not* capture `'b`
+type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>; //~ [o]
+
+// TAIT does *not* capture `'b`
+type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>; //~ [o]
+
+type Bar<'a, 'b: 'b, T> = impl Sized; //~ ERROR [o, o, o]
+
+trait Foo<'i> {
+ type ImplicitCapture<'a>;
+
+ type ExplicitCaptureFromHeader<'a>;
+
+ type ExplicitCaptureFromGat<'a>;
+}
+
+impl<'i> Foo<'i> for &'i () {
+ type ImplicitCapture<'a> = impl Sized; //~ [o, o]
+
+ type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; //~ [o, o]
+
+ type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; //~ [o, o]
+}
+
+impl<'i> Foo<'i> for () {
+ type ImplicitCapture<'a> = impl Sized; //~ [o, o]
+
+ type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; //~ [o, o]
+
+ type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; //~ [o, o]
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/variance.stderr b/tests/ui/type-alias-impl-trait/variance.stderr
new file mode 100644
index 000000000..1794447c8
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/variance.stderr
@@ -0,0 +1,68 @@
+error: [o]
+ --> $DIR/variance.rs:8:29
+ |
+LL | type NotCapturedEarly<'a> = impl Sized;
+ | ^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:10:26
+ |
+LL | type CapturedEarly<'a> = impl Sized + Captures<'a>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:13:56
+ |
+LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>;
+ | ^^^^^^^^^^
+
+error: [o]
+ --> $DIR/variance.rs:16:49
+ |
+LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o, o, o]
+ --> $DIR/variance.rs:18:27
+ |
+LL | type Bar<'a, 'b: 'b, T> = impl Sized;
+ | ^^^^^^^^^^
+
+error: [o, o]
+ --> $DIR/variance.rs:29:32
+ |
+LL | type ImplicitCapture<'a> = impl Sized;
+ | ^^^^^^^^^^
+
+error: [o, o]
+ --> $DIR/variance.rs:31:42
+ |
+LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o, o]
+ --> $DIR/variance.rs:33:39
+ |
+LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o, o]
+ --> $DIR/variance.rs:37:32
+ |
+LL | type ImplicitCapture<'a> = impl Sized;
+ | ^^^^^^^^^^
+
+error: [o, o]
+ --> $DIR/variance.rs:39:42
+ |
+LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: [o, o]
+ --> $DIR/variance.rs:41:39
+ |
+LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 11 previous errors
+
diff --git a/tests/ui/type-alias-impl-trait/wf-check-fn-def.stderr b/tests/ui/type-alias-impl-trait/wf-check-fn-def.stderr
index e0005489d..47bea7bbe 100644
--- a/tests/ui/type-alias-impl-trait/wf-check-fn-def.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-check-fn-def.stderr
@@ -14,6 +14,6 @@ help: consider restricting type parameter `B`
LL | type FooFn<B: Bar> = impl FnOnce(B);
| +++++
-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/type-alias-impl-trait/wf-check-rpit-lifetimes.rs b/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs
new file mode 100644
index 000000000..b92e15aad
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs
@@ -0,0 +1,19 @@
+//check-pass
+
+pub struct Key;
+#[derive(Clone)]
+pub struct Value;
+
+use std::collections::HashMap;
+
+pub struct DiagnosticBuilder<'db> {
+ inner: HashMap<&'db Key, Vec<&'db Value>>,
+}
+
+impl<'db> DiagnosticBuilder<'db> {
+ pub fn iter<'a>(&'a self) -> impl Iterator<Item = (&'db Key, impl Iterator<Item = &'a Value>)> {
+ self.inner.iter().map(|(key, values)| (*key, values.iter().map(|v| *v)))
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr b/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr
index 9e96323ab..c4ad8434e 100644
--- a/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-in-associated-type.fail.stderr
@@ -1,21 +1,25 @@
error[E0309]: the parameter type `T` may not live long enough
- --> $DIR/wf-in-associated-type.rs:36:23
+ --> $DIR/wf-in-associated-type.rs:38:23
|
+LL | impl<'a, T> Trait<'a, T> for () {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Opaque = impl Sized + 'a;
| ^^^^^^^^^^^^^^^ ...so that the type `&'a T` will meet its required lifetime bounds
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Trait<'a, T> for () {
| ++++
error[E0309]: the parameter type `T` may not live long enough
- --> $DIR/wf-in-associated-type.rs:36:23
+ --> $DIR/wf-in-associated-type.rs:38:23
|
+LL | impl<'a, T> Trait<'a, T> for () {
+ | -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
LL | type Opaque = impl Sized + 'a;
| ^^^^^^^^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at
|
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | impl<'a, T: 'a> Trait<'a, T> for () {
| ++++
diff --git a/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs b/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs
index 31fbef9f7..22e2b0efd 100644
--- a/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs
+++ b/tests/ui/type-alias-impl-trait/wf-in-associated-type.rs
@@ -1,14 +1,16 @@
// WF check for impl Trait in associated type position.
//
-// revisions: pass fail
+// revisions: pass pass_next fail
// [pass] check-pass
+// [pass_next] compile-flags: -Znext-solver
+// [pass_next] check-pass
// [fail] check-fail
#![feature(impl_trait_in_assoc_type)]
// The hidden type here (`&'a T`) requires proving `T: 'a`.
// We know it holds because of implied bounds from the impl header.
-#[cfg(pass)]
+#[cfg(any(pass, pass_next))]
mod pass {
trait Trait<Req> {
type Opaque1;
diff --git a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr
index 753a46e88..dcc4b8021 100644
--- a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr
@@ -2,18 +2,21 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-nested.rs:55:27
|
LL | type InnerOpaque<T> = impl Sized;
- | ^^^^^^^^^^ ...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...
|
note: ...that is required by this bound
--> $DIR/wf-nested.rs:12:20
|
LL | struct IsStatic<T: 'static>(T);
| ^^^^^^^
-help: consider adding an explicit lifetime bound...
+help: consider adding an explicit lifetime bound
|
LL | type InnerOpaque<T: 'static> = impl Sized;
| +++++++++
-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/type-alias-impl-trait/wf-nested.pass_sound.stderr b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr
index 9ab6685a7..121664bd9 100644
--- a/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr
+++ b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr
@@ -2,13 +2,16 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/wf-nested.rs:46:17
|
LL | let _ = outer.get();
- | ^^^^^^^^^^^ ...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 test<T: '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/type-alias-impl-trait/wf_check_closures.stderr b/tests/ui/type-alias-impl-trait/wf_check_closures.stderr
index 58ae8617b..09a42f734 100644
--- a/tests/ui/type-alias-impl-trait/wf_check_closures.stderr
+++ b/tests/ui/type-alias-impl-trait/wf_check_closures.stderr
@@ -14,6 +14,6 @@ help: consider restricting type parameter `B`
LL | type FooFn<B: Bar> = impl FnOnce();
| +++++
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.