]> git.lizzy.rs Git - rust.git/commitdiff
Organize trait test files
authorBram van den Heuvel <bram@vandenheuvel.online>
Mon, 8 Feb 2021 22:15:45 +0000 (23:15 +0100)
committerBram van den Heuvel <bram@vandenheuvel.online>
Tue, 9 Feb 2021 13:19:35 +0000 (14:19 +0100)
572 files changed:
src/test/ui/traits/alias/ambiguous.rs [new file with mode: 0644]
src/test/ui/traits/alias/ambiguous.stderr [new file with mode: 0644]
src/test/ui/traits/alias/auxiliary/greeter.rs [new file with mode: 0644]
src/test/ui/traits/alias/auxiliary/send_sync.rs [new file with mode: 0644]
src/test/ui/traits/alias/basic.rs [new file with mode: 0644]
src/test/ui/traits/alias/bounds.rs [new file with mode: 0644]
src/test/ui/traits/alias/cross-crate.rs [new file with mode: 0644]
src/test/ui/traits/alias/cross-crate.stderr [new file with mode: 0644]
src/test/ui/traits/alias/impl.rs [new file with mode: 0644]
src/test/ui/traits/alias/impl.stderr [new file with mode: 0644]
src/test/ui/traits/alias/import-cross-crate.rs [new file with mode: 0644]
src/test/ui/traits/alias/import.rs [new file with mode: 0644]
src/test/ui/traits/alias/issue-60021-assoc-method-resolve.rs [new file with mode: 0644]
src/test/ui/traits/alias/issue-72415-assoc-const-resolve.rs [new file with mode: 0644]
src/test/ui/traits/alias/issue-75983.rs [new file with mode: 0644]
src/test/ui/traits/alias/maybe-bound.rs [new file with mode: 0644]
src/test/ui/traits/alias/no-duplicates.rs [new file with mode: 0644]
src/test/ui/traits/alias/no-duplicates.stderr [new file with mode: 0644]
src/test/ui/traits/alias/no-extra-traits.rs [new file with mode: 0644]
src/test/ui/traits/alias/no-extra-traits.stderr [new file with mode: 0644]
src/test/ui/traits/alias/object-fail.rs [new file with mode: 0644]
src/test/ui/traits/alias/object-fail.stderr [new file with mode: 0644]
src/test/ui/traits/alias/object-wf.rs [new file with mode: 0644]
src/test/ui/traits/alias/object.rs [new file with mode: 0644]
src/test/ui/traits/alias/only-maybe-bound.rs [new file with mode: 0644]
src/test/ui/traits/alias/only-maybe-bound.stderr [new file with mode: 0644]
src/test/ui/traits/alias/syntax-fail.rs [new file with mode: 0644]
src/test/ui/traits/alias/syntax-fail.stderr [new file with mode: 0644]
src/test/ui/traits/alias/syntax.rs [new file with mode: 0644]
src/test/ui/traits/alias/wf.rs [new file with mode: 0644]
src/test/ui/traits/alias/wf.stderr [new file with mode: 0644]
src/test/ui/traits/anon-static-method.rs [new file with mode: 0644]
src/test/ui/traits/anon-trait-static-method.rs [deleted file]
src/test/ui/traits/as-struct-constructor.rs [new file with mode: 0644]
src/test/ui/traits/as-struct-constructor.stderr [new file with mode: 0644]
src/test/ui/traits/assoc-type-in-superbad.rs [new file with mode: 0644]
src/test/ui/traits/assoc-type-in-superbad.stderr [new file with mode: 0644]
src/test/ui/traits/assoc-type-in-supertrait.rs [new file with mode: 0644]
src/test/ui/traits/assoc_type_bound_with_struct.rs [deleted file]
src/test/ui/traits/assoc_type_bound_with_struct.stderr [deleted file]
src/test/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2-ok.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2.stderr [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.rs [new file with mode: 0644]
src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr [new file with mode: 0644]
src/test/ui/traits/astconv-cycle-between-and-type.rs [new file with mode: 0644]
src/test/ui/traits/astconv-cycle-between-trait-and-type.rs [deleted file]
src/test/ui/traits/auxiliary/crate_a1.rs [deleted file]
src/test/ui/traits/auxiliary/crate_a2.rs [deleted file]
src/test/ui/traits/auxiliary/trait_alias.rs [deleted file]
src/test/ui/traits/auxiliary/trait_bounds_on_structs_and_enums_xc.rs [deleted file]
src/test/ui/traits/auxiliary/trait_default_method_xc_aux.rs [deleted file]
src/test/ui/traits/auxiliary/trait_default_method_xc_aux_2.rs [deleted file]
src/test/ui/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs [deleted file]
src/test/ui/traits/auxiliary/trait_inheritance_auto_xc_aux.rs [deleted file]
src/test/ui/traits/auxiliary/trait_inheritance_overloading_xc.rs [deleted file]
src/test/ui/traits/auxiliary/trait_xc_call_aux.rs [deleted file]
src/test/ui/traits/bound/auxiliary/crate_a1.rs [new file with mode: 0644]
src/test/ui/traits/bound/auxiliary/crate_a2.rs [new file with mode: 0644]
src/test/ui/traits/bound/auxiliary/on_structs_and_enums_xc.rs [new file with mode: 0644]
src/test/ui/traits/bound/basic.rs [new file with mode: 0644]
src/test/ui/traits/bound/generic_trait.rs [new file with mode: 0644]
src/test/ui/traits/bound/impl-comparison-duplicates.rs [new file with mode: 0644]
src/test/ui/traits/bound/in-arc.rs [new file with mode: 0644]
src/test/ui/traits/bound/multiple.rs [new file with mode: 0644]
src/test/ui/traits/bound/not-on-bare-trait.rs [new file with mode: 0644]
src/test/ui/traits/bound/not-on-bare-trait.stderr [new file with mode: 0644]
src/test/ui/traits/bound/not-on-struct.rs [new file with mode: 0644]
src/test/ui/traits/bound/not-on-struct.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-in-fns.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-in-fns.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-in-impls.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-in-impls.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-locals.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-locals.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-rpass.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-static.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-static.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-xc.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-xc.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-xc1.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums-xc1.stderr [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums.rs [new file with mode: 0644]
src/test/ui/traits/bound/on-structs-and-enums.stderr [new file with mode: 0644]
src/test/ui/traits/bound/recursion.rs [new file with mode: 0644]
src/test/ui/traits/bound/same-crate-name.rs [new file with mode: 0644]
src/test/ui/traits/bound/same-crate-name.stderr [new file with mode: 0644]
src/test/ui/traits/bound/sugar.rs [new file with mode: 0644]
src/test/ui/traits/bound/sugar.stderr [new file with mode: 0644]
src/test/ui/traits/cache-issue-18209.rs [new file with mode: 0644]
src/test/ui/traits/check-trait-object-bounds-1.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-1.stderr [deleted file]
src/test/ui/traits/check-trait-object-bounds-2-ok.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-2.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-2.stderr [deleted file]
src/test/ui/traits/check-trait-object-bounds-3.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-3.stderr [deleted file]
src/test/ui/traits/check-trait-object-bounds-4.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-4.stderr [deleted file]
src/test/ui/traits/check-trait-object-bounds-5.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-5.stderr [deleted file]
src/test/ui/traits/check-trait-object-bounds-6.rs [deleted file]
src/test/ui/traits/check-trait-object-bounds-6.stderr [deleted file]
src/test/ui/traits/coercion-generic-bad.rs [new file with mode: 0644]
src/test/ui/traits/coercion-generic-bad.stderr [new file with mode: 0644]
src/test/ui/traits/coercion-generic-regions.rs [new file with mode: 0644]
src/test/ui/traits/coercion-generic-regions.stderr [new file with mode: 0644]
src/test/ui/traits/coercion-generic.rs [new file with mode: 0644]
src/test/ui/traits/coercion.rs [new file with mode: 0644]
src/test/ui/traits/composition-trivial.rs [new file with mode: 0644]
src/test/ui/traits/conditional-dispatch.rs [new file with mode: 0644]
src/test/ui/traits/conditional-model-fn.rs [new file with mode: 0644]
src/test/ui/traits/copy-guessing.rs [new file with mode: 0644]
src/test/ui/traits/cycle-trait-type-trait.rs [deleted file]
src/test/ui/traits/cycle-type-trait.rs [new file with mode: 0644]
src/test/ui/traits/default-method-supertrait-vtable.rs [deleted file]
src/test/ui/traits/default-method/auxiliary/xc.rs [new file with mode: 0644]
src/test/ui/traits/default-method/auxiliary/xc_2.rs [new file with mode: 0644]
src/test/ui/traits/default-method/bound-subst.rs [new file with mode: 0644]
src/test/ui/traits/default-method/bound-subst2.rs [new file with mode: 0644]
src/test/ui/traits/default-method/bound-subst3.rs [new file with mode: 0644]
src/test/ui/traits/default-method/bound-subst4.rs [new file with mode: 0644]
src/test/ui/traits/default-method/bound.rs [new file with mode: 0644]
src/test/ui/traits/default-method/macro.rs [new file with mode: 0644]
src/test/ui/traits/default-method/mut.rs [new file with mode: 0644]
src/test/ui/traits/default-method/self.rs [new file with mode: 0644]
src/test/ui/traits/default-method/supervtable.rs [new file with mode: 0644]
src/test/ui/traits/default-method/trivial.rs [new file with mode: 0644]
src/test/ui/traits/default-method/xc-2.rs [new file with mode: 0644]
src/test/ui/traits/default-method/xc.rs [new file with mode: 0644]
src/test/ui/traits/duplicate-methods.rs [new file with mode: 0644]
src/test/ui/traits/duplicate-methods.stderr [new file with mode: 0644]
src/test/ui/traits/elaborate-type-region.rs [new file with mode: 0644]
src/test/ui/traits/false-ambiguity-where-clause-builtin-bound.rs [new file with mode: 0644]
src/test/ui/traits/generic.rs [new file with mode: 0644]
src/test/ui/traits/impl-1.rs [new file with mode: 0644]
src/test/ui/traits/impl-1.stderr [new file with mode: 0644]
src/test/ui/traits/impl-2.rs [new file with mode: 0644]
src/test/ui/traits/impl-can-not-have-untraitful-items.rs [new file with mode: 0644]
src/test/ui/traits/impl-can-not-have-untraitful-items.stderr [new file with mode: 0644]
src/test/ui/traits/impl-different-num-params.rs [new file with mode: 0644]
src/test/ui/traits/impl-different-num-params.stderr [new file with mode: 0644]
src/test/ui/traits/impl-for-module.rs [new file with mode: 0644]
src/test/ui/traits/impl-for-module.stderr [new file with mode: 0644]
src/test/ui/traits/impl-method-mismatch.rs [new file with mode: 0644]
src/test/ui/traits/impl-method-mismatch.stderr [new file with mode: 0644]
src/test/ui/traits/impl-object-overlap-issue-23853.rs [new file with mode: 0644]
src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.rs [new file with mode: 0644]
src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr [new file with mode: 0644]
src/test/ui/traits/impl.rs [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/lifetime.rs [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/lifetime.stderr [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/simultaneous.rs [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/simultaneous.stderr [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/supertrait.rs [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/supertrait.stderr [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/two-traits.rs [new file with mode: 0644]
src/test/ui/traits/inductive-overflow/two-traits.stderr [new file with mode: 0644]
src/test/ui/traits/infer-from-object-issue-26952.rs [new file with mode: 0644]
src/test/ui/traits/infer-from-object-trait-issue-26952.rs [deleted file]
src/test/ui/traits/inherent-method-order.rs [new file with mode: 0644]
src/test/ui/traits/inherent-trait-method-order.rs [deleted file]
src/test/ui/traits/inheritance/auto-xc-2.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/auto-xc.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/auto.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/auxiliary/auto_xc.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/auxiliary/auto_xc_2.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/auxiliary/overloading_xc.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/auxiliary/xc_call.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/basic.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/call-bound-inherited.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/call-bound-inherited2.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/cast-without-call-to-supertrait.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/cast.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/cross-trait-call-xc.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/cross-trait-call.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/diamond.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/multiple-inheritors.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/multiple-params.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/num.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/num0.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/num1.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/num2.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/num3.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/num5.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/overloading-simple.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/overloading-xc-exe.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/overloading.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr [new file with mode: 0644]
src/test/ui/traits/inheritance/repeated-supertrait.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/self-in-supertype.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/self.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/simple.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/static.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/static2.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/subst.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/subst2.rs [new file with mode: 0644]
src/test/ui/traits/inheritance/visibility.rs [new file with mode: 0644]
src/test/ui/traits/issue-22019.rs [new file with mode: 0644]
src/test/ui/traits/issue-22110.rs [new file with mode: 0644]
src/test/ui/traits/issue-22655.rs [new file with mode: 0644]
src/test/ui/traits/issue-23003-overflow.rs [new file with mode: 0644]
src/test/ui/traits/issue-23003.rs [new file with mode: 0644]
src/test/ui/traits/issue-26339.rs [new file with mode: 0644]
src/test/ui/traits/issue-71136.rs [new file with mode: 0644]
src/test/ui/traits/issue-71136.stderr [new file with mode: 0644]
src/test/ui/traits/issue-9394-inherited-calls.rs [new file with mode: 0644]
src/test/ui/traits/issue-9394-inherited-trait-calls.rs [deleted file]
src/test/ui/traits/item-inside-macro.rs [new file with mode: 0644]
src/test/ui/traits/item-privacy.rs [new file with mode: 0644]
src/test/ui/traits/item-privacy.stderr [new file with mode: 0644]
src/test/ui/traits/kindck-owned-contains-1.rs [new file with mode: 0644]
src/test/ui/traits/kindck-owned-trait-contains-1.rs [deleted file]
src/test/ui/traits/matching-lifetimes.rs [new file with mode: 0644]
src/test/ui/traits/matching-lifetimes.stderr [new file with mode: 0644]
src/test/ui/traits/method-private.rs [new file with mode: 0644]
src/test/ui/traits/method-private.stderr [new file with mode: 0644]
src/test/ui/traits/multidispatch-bad.rs [new file with mode: 0644]
src/test/ui/traits/multidispatch-bad.stderr [new file with mode: 0644]
src/test/ui/traits/multidispatch-convert-ambig-dest.rs [new file with mode: 0644]
src/test/ui/traits/multidispatch-convert-ambig-dest.stderr [new file with mode: 0644]
src/test/ui/traits/multidispatch-infer-convert-target.rs [new file with mode: 0644]
src/test/ui/traits/multiple-trait-bounds.rs [deleted file]
src/test/ui/traits/object/auto-dedup-in-impl.rs [new file with mode: 0644]
src/test/ui/traits/object/auto-dedup-in-impl.stderr [new file with mode: 0644]
src/test/ui/traits/object/auto-dedup.rs [new file with mode: 0644]
src/test/ui/traits/object/bounds-cycle-1.rs [new file with mode: 0644]
src/test/ui/traits/object/bounds-cycle-2.rs [new file with mode: 0644]
src/test/ui/traits/object/bounds-cycle-3.rs [new file with mode: 0644]
src/test/ui/traits/object/bounds-cycle-4.rs [new file with mode: 0644]
src/test/ui/traits/object/exclusion.rs [new file with mode: 0644]
src/test/ui/traits/object/generics.rs [new file with mode: 0644]
src/test/ui/traits/object/lifetime-first.rs [new file with mode: 0644]
src/test/ui/traits/object/macro-matcher.rs [new file with mode: 0644]
src/test/ui/traits/object/macro-matcher.stderr [new file with mode: 0644]
src/test/ui/traits/object/safety.rs [new file with mode: 0644]
src/test/ui/traits/object/safety.stderr [new file with mode: 0644]
src/test/ui/traits/object/supertrait-lifetime-bound.rs [new file with mode: 0644]
src/test/ui/traits/object/vs-lifetime-2.rs [new file with mode: 0644]
src/test/ui/traits/object/vs-lifetime-2.stderr [new file with mode: 0644]
src/test/ui/traits/object/vs-lifetime.rs [new file with mode: 0644]
src/test/ui/traits/object/vs-lifetime.stderr [new file with mode: 0644]
src/test/ui/traits/object/with-lifetime-bound.rs [new file with mode: 0644]
src/test/ui/traits/object/with-self-in-projection-output-bad.rs [new file with mode: 0644]
src/test/ui/traits/object/with-self-in-projection-output-bad.stderr [new file with mode: 0644]
src/test/ui/traits/object/with-self-in-projection-output-good.rs [new file with mode: 0644]
src/test/ui/traits/object/with-self-in-projection-output-repeated-supertrait.rs [new file with mode: 0644]
src/test/ui/traits/param-without-lifetime-constraint.rs [new file with mode: 0644]
src/test/ui/traits/param-without-lifetime-constraint.stderr [new file with mode: 0644]
src/test/ui/traits/parameterized-trait-with-bounds.rs [deleted file]
src/test/ui/traits/parameterized-with-bounds.rs [new file with mode: 0644]
src/test/ui/traits/principal-less-objects.rs [new file with mode: 0644]
src/test/ui/traits/principal-less-trait-objects.rs [deleted file]
src/test/ui/traits/privacy.rs [new file with mode: 0644]
src/test/ui/traits/region-pointer-simple.rs [new file with mode: 0644]
src/test/ui/traits/reservation-impl/coherence-conflict.rs [new file with mode: 0644]
src/test/ui/traits/reservation-impl/coherence-conflict.stderr [new file with mode: 0644]
src/test/ui/traits/reservation-impl/no-use.rs [new file with mode: 0644]
src/test/ui/traits/reservation-impl/no-use.stderr [new file with mode: 0644]
src/test/ui/traits/reservation-impl/non-lattice-ok.rs [new file with mode: 0644]
src/test/ui/traits/reservation-impl/ok.rs [new file with mode: 0644]
src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs [deleted file]
src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr [deleted file]
src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs [deleted file]
src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr [deleted file]
src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs [deleted file]
src/test/ui/traits/reservation-impls/reservation-impl-ok.rs [deleted file]
src/test/ui/traits/resolution-in-overloaded-op.rs [new file with mode: 0644]
src/test/ui/traits/resolution-in-overloaded-op.stderr [new file with mode: 0644]
src/test/ui/traits/safety-fn-body.rs [new file with mode: 0644]
src/test/ui/traits/safety-fn-body.stderr [new file with mode: 0644]
src/test/ui/traits/safety-inherent-impl.rs [new file with mode: 0644]
src/test/ui/traits/safety-inherent-impl.stderr [new file with mode: 0644]
src/test/ui/traits/safety-ok-cc.rs [new file with mode: 0644]
src/test/ui/traits/safety-ok.rs [new file with mode: 0644]
src/test/ui/traits/safety-trait-impl-cc.rs [new file with mode: 0644]
src/test/ui/traits/safety-trait-impl-cc.stderr [new file with mode: 0644]
src/test/ui/traits/safety-trait-impl.rs [new file with mode: 0644]
src/test/ui/traits/safety-trait-impl.stderr [new file with mode: 0644]
src/test/ui/traits/static-method-generic-inference.rs [new file with mode: 0644]
src/test/ui/traits/static-method-generic-inference.stderr [new file with mode: 0644]
src/test/ui/traits/static-method-overwriting.rs [new file with mode: 0644]
src/test/ui/traits/static-outlives-a-where-clause.rs [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/issue-39029.fixed [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/issue-39029.rs [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/issue-39029.stderr [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/issue-62530.fixed [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/issue-62530.rs [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/issue-62530.stderr [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/multiple-0.fixed [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/multiple-0.rs [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/multiple-0.stderr [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/multiple-1.rs [new file with mode: 0644]
src/test/ui/traits/suggest-deferences/multiple-1.stderr [new file with mode: 0644]
src/test/ui/traits/suggest-where-clause.rs [new file with mode: 0644]
src/test/ui/traits/suggest-where-clause.stderr [new file with mode: 0644]
src/test/ui/traits/superdefault-generics.rs [new file with mode: 0644]
src/test/ui/traits/supertrait-default-generics.rs [deleted file]
src/test/ui/traits/syntax-polarity.rs [new file with mode: 0644]
src/test/ui/traits/syntax-trait-polarity.rs [deleted file]
src/test/ui/traits/test-2.rs [new file with mode: 0644]
src/test/ui/traits/test-2.stderr [new file with mode: 0644]
src/test/ui/traits/test.rs [new file with mode: 0644]
src/test/ui/traits/test.stderr [new file with mode: 0644]
src/test/ui/traits/to-str.rs [new file with mode: 0644]
src/test/ui/traits/trait-alias-ambiguous.rs [deleted file]
src/test/ui/traits/trait-alias-ambiguous.stderr [deleted file]
src/test/ui/traits/trait-alias-import-cross-crate.rs [deleted file]
src/test/ui/traits/trait-alias-import.rs [deleted file]
src/test/ui/traits/trait-alias/auxiliary/trait_alias.rs [deleted file]
src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs [deleted file]
src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs [deleted file]
src/test/ui/traits/trait-alias/issue-75983.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-bounds.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-cross-crate.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-impl.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-impl.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-object-fail.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-object-wf.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-object.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-only-maybe-bound.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-only-maybe-bound.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-syntax-fail.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-syntax-fail.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias-syntax.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-wf.rs [deleted file]
src/test/ui/traits/trait-alias/trait-alias-wf.stderr [deleted file]
src/test/ui/traits/trait-alias/trait-alias.rs [deleted file]
src/test/ui/traits/trait-as-struct-constructor.rs [deleted file]
src/test/ui/traits/trait-as-struct-constructor.stderr [deleted file]
src/test/ui/traits/trait-bounds-basic.rs [deleted file]
src/test/ui/traits/trait-bounds-impl-comparison-duplicates.rs [deleted file]
src/test/ui/traits/trait-bounds-in-arc.rs [deleted file]
src/test/ui/traits/trait-bounds-not-on-bare-trait.rs [deleted file]
src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr [deleted file]
src/test/ui/traits/trait-bounds-not-on-struct.rs [deleted file]
src/test/ui/traits/trait-bounds-not-on-struct.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-rpass.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-static.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums.rs [deleted file]
src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr [deleted file]
src/test/ui/traits/trait-bounds-recursion.rs [deleted file]
src/test/ui/traits/trait-bounds-same-crate-name.rs [deleted file]
src/test/ui/traits/trait-bounds-same-crate-name.stderr [deleted file]
src/test/ui/traits/trait-bounds-sugar.rs [deleted file]
src/test/ui/traits/trait-bounds-sugar.stderr [deleted file]
src/test/ui/traits/trait-bounds.rs [deleted file]
src/test/ui/traits/trait-cache-issue-18209.rs [deleted file]
src/test/ui/traits/trait-coercion-generic-bad.rs [deleted file]
src/test/ui/traits/trait-coercion-generic-bad.stderr [deleted file]
src/test/ui/traits/trait-coercion-generic-regions.rs [deleted file]
src/test/ui/traits/trait-coercion-generic-regions.stderr [deleted file]
src/test/ui/traits/trait-coercion-generic.rs [deleted file]
src/test/ui/traits/trait-coercion.rs [deleted file]
src/test/ui/traits/trait-composition-trivial.rs [deleted file]
src/test/ui/traits/trait-copy-guessing.rs [deleted file]
src/test/ui/traits/trait-default-method-bound-subst.rs [deleted file]
src/test/ui/traits/trait-default-method-bound-subst2.rs [deleted file]
src/test/ui/traits/trait-default-method-bound-subst3.rs [deleted file]
src/test/ui/traits/trait-default-method-bound-subst4.rs [deleted file]
src/test/ui/traits/trait-default-method-bound.rs [deleted file]
src/test/ui/traits/trait-default-method-xc-2.rs [deleted file]
src/test/ui/traits/trait-default-method-xc.rs [deleted file]
src/test/ui/traits/trait-duplicate-methods.rs [deleted file]
src/test/ui/traits/trait-duplicate-methods.stderr [deleted file]
src/test/ui/traits/trait-false-ambiguity-where-clause-builtin-bound.rs [deleted file]
src/test/ui/traits/trait-generic.rs [deleted file]
src/test/ui/traits/trait-impl-1.rs [deleted file]
src/test/ui/traits/trait-impl-1.stderr [deleted file]
src/test/ui/traits/trait-impl-2.rs [deleted file]
src/test/ui/traits/trait-impl-can-not-have-untraitful-items.rs [deleted file]
src/test/ui/traits/trait-impl-can-not-have-untraitful-items.stderr [deleted file]
src/test/ui/traits/trait-impl-different-num-params.rs [deleted file]
src/test/ui/traits/trait-impl-different-num-params.stderr [deleted file]
src/test/ui/traits/trait-impl-for-module.rs [deleted file]
src/test/ui/traits/trait-impl-for-module.stderr [deleted file]
src/test/ui/traits/trait-impl-method-mismatch.rs [deleted file]
src/test/ui/traits/trait-impl-method-mismatch.stderr [deleted file]
src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs [deleted file]
src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr [deleted file]
src/test/ui/traits/trait-impl.rs [deleted file]
src/test/ui/traits/trait-inheritance-auto-xc-2.rs [deleted file]
src/test/ui/traits/trait-inheritance-auto-xc.rs [deleted file]
src/test/ui/traits/trait-inheritance-auto.rs [deleted file]
src/test/ui/traits/trait-inheritance-call-bound-inherited.rs [deleted file]
src/test/ui/traits/trait-inheritance-call-bound-inherited2.rs [deleted file]
src/test/ui/traits/trait-inheritance-cast-without-call-to-supertrait.rs [deleted file]
src/test/ui/traits/trait-inheritance-cast.rs [deleted file]
src/test/ui/traits/trait-inheritance-cross-trait-call-xc.rs [deleted file]
src/test/ui/traits/trait-inheritance-cross-trait-call.rs [deleted file]
src/test/ui/traits/trait-inheritance-diamond.rs [deleted file]
src/test/ui/traits/trait-inheritance-multiple-inheritors.rs [deleted file]
src/test/ui/traits/trait-inheritance-multiple-params.rs [deleted file]
src/test/ui/traits/trait-inheritance-num.rs [deleted file]
src/test/ui/traits/trait-inheritance-num0.rs [deleted file]
src/test/ui/traits/trait-inheritance-num1.rs [deleted file]
src/test/ui/traits/trait-inheritance-num2.rs [deleted file]
src/test/ui/traits/trait-inheritance-num3.rs [deleted file]
src/test/ui/traits/trait-inheritance-num5.rs [deleted file]
src/test/ui/traits/trait-inheritance-overloading-simple.rs [deleted file]
src/test/ui/traits/trait-inheritance-overloading-xc-exe.rs [deleted file]
src/test/ui/traits/trait-inheritance-overloading.rs [deleted file]
src/test/ui/traits/trait-inheritance-self-in-supertype.rs [deleted file]
src/test/ui/traits/trait-inheritance-self.rs [deleted file]
src/test/ui/traits/trait-inheritance-simple.rs [deleted file]
src/test/ui/traits/trait-inheritance-static.rs [deleted file]
src/test/ui/traits/trait-inheritance-static2.rs [deleted file]
src/test/ui/traits/trait-inheritance-subst.rs [deleted file]
src/test/ui/traits/trait-inheritance-subst2.rs [deleted file]
src/test/ui/traits/trait-inheritance-visibility.rs [deleted file]
src/test/ui/traits/trait-inheritance2.rs [deleted file]
src/test/ui/traits/trait-item-inside-macro.rs [deleted file]
src/test/ui/traits/trait-item-privacy.rs [deleted file]
src/test/ui/traits/trait-item-privacy.stderr [deleted file]
src/test/ui/traits/trait-matching-lifetimes.rs [deleted file]
src/test/ui/traits/trait-matching-lifetimes.stderr [deleted file]
src/test/ui/traits/trait-method-private.rs [deleted file]
src/test/ui/traits/trait-method-private.stderr [deleted file]
src/test/ui/traits/trait-object-auto-dedup-in-impl.rs [deleted file]
src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr [deleted file]
src/test/ui/traits/trait-object-auto-dedup.rs [deleted file]
src/test/ui/traits/trait-object-bounds-cycle-1.rs [deleted file]
src/test/ui/traits/trait-object-bounds-cycle-2.rs [deleted file]
src/test/ui/traits/trait-object-bounds-cycle-3.rs [deleted file]
src/test/ui/traits/trait-object-bounds-cycle-4.rs [deleted file]
src/test/ui/traits/trait-object-exclusion.rs [deleted file]
src/test/ui/traits/trait-object-generics.rs [deleted file]
src/test/ui/traits/trait-object-lifetime-first.rs [deleted file]
src/test/ui/traits/trait-object-macro-matcher.rs [deleted file]
src/test/ui/traits/trait-object-macro-matcher.stderr [deleted file]
src/test/ui/traits/trait-object-safety.rs [deleted file]
src/test/ui/traits/trait-object-safety.stderr [deleted file]
src/test/ui/traits/trait-object-supertrait-lifetime-bound.rs [deleted file]
src/test/ui/traits/trait-object-vs-lifetime-2.rs [deleted file]
src/test/ui/traits/trait-object-vs-lifetime-2.stderr [deleted file]
src/test/ui/traits/trait-object-vs-lifetime.rs [deleted file]
src/test/ui/traits/trait-object-vs-lifetime.stderr [deleted file]
src/test/ui/traits/trait-object-with-lifetime-bound.rs [deleted file]
src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs [deleted file]
src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr [deleted file]
src/test/ui/traits/trait-object-with-self-in-projection-output-good.rs [deleted file]
src/test/ui/traits/trait-object-with-self-in-projection-output-repeated-supertrait.rs [deleted file]
src/test/ui/traits/trait-param-without-lifetime-constraint.rs [deleted file]
src/test/ui/traits/trait-param-without-lifetime-constraint.stderr [deleted file]
src/test/ui/traits/trait-privacy.rs [deleted file]
src/test/ui/traits/trait-region-pointer-simple.rs [deleted file]
src/test/ui/traits/trait-resolution-in-overloaded-op.rs [deleted file]
src/test/ui/traits/trait-resolution-in-overloaded-op.stderr [deleted file]
src/test/ui/traits/trait-safety-fn-body.rs [deleted file]
src/test/ui/traits/trait-safety-fn-body.stderr [deleted file]
src/test/ui/traits/trait-safety-inherent-impl.rs [deleted file]
src/test/ui/traits/trait-safety-inherent-impl.stderr [deleted file]
src/test/ui/traits/trait-safety-ok-cc.rs [deleted file]
src/test/ui/traits/trait-safety-ok.rs [deleted file]
src/test/ui/traits/trait-safety-trait-impl-cc.rs [deleted file]
src/test/ui/traits/trait-safety-trait-impl-cc.stderr [deleted file]
src/test/ui/traits/trait-safety-trait-impl.rs [deleted file]
src/test/ui/traits/trait-safety-trait-impl.stderr [deleted file]
src/test/ui/traits/trait-static-method-generic-inference.rs [deleted file]
src/test/ui/traits/trait-static-method-generic-inference.stderr [deleted file]
src/test/ui/traits/trait-static-method-overwriting.rs [deleted file]
src/test/ui/traits/trait-suggest-deferences-issue-39029.fixed [deleted file]
src/test/ui/traits/trait-suggest-deferences-issue-39029.rs [deleted file]
src/test/ui/traits/trait-suggest-deferences-issue-39029.stderr [deleted file]
src/test/ui/traits/trait-suggest-deferences-issue-62530.fixed [deleted file]
src/test/ui/traits/trait-suggest-deferences-issue-62530.rs [deleted file]
src/test/ui/traits/trait-suggest-deferences-issue-62530.stderr [deleted file]
src/test/ui/traits/trait-suggest-deferences-multiple-0.fixed [deleted file]
src/test/ui/traits/trait-suggest-deferences-multiple-0.rs [deleted file]
src/test/ui/traits/trait-suggest-deferences-multiple-0.stderr [deleted file]
src/test/ui/traits/trait-suggest-deferences-multiple-1.rs [deleted file]
src/test/ui/traits/trait-suggest-deferences-multiple-1.stderr [deleted file]
src/test/ui/traits/trait-suggest-where-clause.rs [deleted file]
src/test/ui/traits/trait-suggest-where-clause.stderr [deleted file]
src/test/ui/traits/trait-test-2.rs [deleted file]
src/test/ui/traits/trait-test-2.stderr [deleted file]
src/test/ui/traits/trait-test.rs [deleted file]
src/test/ui/traits/trait-test.stderr [deleted file]
src/test/ui/traits/trait-to-str.rs [deleted file]
src/test/ui/traits/trait-where-clause-vs-impl.rs [deleted file]
src/test/ui/traits/trait-with-bounds-default.rs [deleted file]
src/test/ui/traits/trait-with-dst.rs [deleted file]
src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs [deleted file]
src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr [deleted file]
src/test/ui/traits/traits-assoc-type-in-supertrait.rs [deleted file]
src/test/ui/traits/traits-conditional-dispatch.rs [deleted file]
src/test/ui/traits/traits-conditional-model-fn.rs [deleted file]
src/test/ui/traits/traits-default-method-macro.rs [deleted file]
src/test/ui/traits/traits-default-method-mut.rs [deleted file]
src/test/ui/traits/traits-default-method-self.rs [deleted file]
src/test/ui/traits/traits-default-method-trivial.rs [deleted file]
src/test/ui/traits/traits-elaborate-type-region.rs [deleted file]
src/test/ui/traits/traits-impl-object-overlap-issue-23853.rs [deleted file]
src/test/ui/traits/traits-inductive-overflow-lifetime.rs [deleted file]
src/test/ui/traits/traits-inductive-overflow-lifetime.stderr [deleted file]
src/test/ui/traits/traits-inductive-overflow-simultaneous.rs [deleted file]
src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr [deleted file]
src/test/ui/traits/traits-inductive-overflow-supertrait-auto-trait.rs [deleted file]
src/test/ui/traits/traits-inductive-overflow-supertrait-auto-trait.stderr [deleted file]
src/test/ui/traits/traits-inductive-overflow-supertrait.rs [deleted file]
src/test/ui/traits/traits-inductive-overflow-supertrait.stderr [deleted file]
src/test/ui/traits/traits-inductive-overflow-two-traits.rs [deleted file]
src/test/ui/traits/traits-inductive-overflow-two-traits.stderr [deleted file]
src/test/ui/traits/traits-issue-22019.rs [deleted file]
src/test/ui/traits/traits-issue-22110.rs [deleted file]
src/test/ui/traits/traits-issue-22655.rs [deleted file]
src/test/ui/traits/traits-issue-23003-overflow.rs [deleted file]
src/test/ui/traits/traits-issue-23003.rs [deleted file]
src/test/ui/traits/traits-issue-26339.rs [deleted file]
src/test/ui/traits/traits-issue-71136.rs [deleted file]
src/test/ui/traits/traits-issue-71136.stderr [deleted file]
src/test/ui/traits/traits-multidispatch-bad.rs [deleted file]
src/test/ui/traits/traits-multidispatch-bad.stderr [deleted file]
src/test/ui/traits/traits-multidispatch-convert-ambig-dest.rs [deleted file]
src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr [deleted file]
src/test/ui/traits/traits-multidispatch-infer-convert-target.rs [deleted file]
src/test/ui/traits/traits-repeated-supertrait-ambig.rs [deleted file]
src/test/ui/traits/traits-repeated-supertrait-ambig.stderr [deleted file]
src/test/ui/traits/traits-repeated-supertrait.rs [deleted file]
src/test/ui/traits/traits-static-outlives-a-where-clause.rs [deleted file]
src/test/ui/traits/ufcs-object.rs [new file with mode: 0644]
src/test/ui/traits/ufcs-trait-object.rs [deleted file]
src/test/ui/traits/use-before-def.rs [new file with mode: 0644]
src/test/ui/traits/use-trait-before-def.rs [deleted file]
src/test/ui/traits/wf-object/maybe-bound.rs [new file with mode: 0644]
src/test/ui/traits/wf-object/maybe-bound.stderr [new file with mode: 0644]
src/test/ui/traits/wf-object/no-duplicates.rs [new file with mode: 0644]
src/test/ui/traits/wf-object/no-duplicates.stderr [new file with mode: 0644]
src/test/ui/traits/wf-object/only-maybe-bound.rs [new file with mode: 0644]
src/test/ui/traits/wf-object/only-maybe-bound.stderr [new file with mode: 0644]
src/test/ui/traits/wf-object/reverse-order.rs [new file with mode: 0644]
src/test/ui/traits/wf-trait-object-maybe-bound.rs [deleted file]
src/test/ui/traits/wf-trait-object-maybe-bound.stderr [deleted file]
src/test/ui/traits/wf-trait-object-no-duplicates.rs [deleted file]
src/test/ui/traits/wf-trait-object-no-duplicates.stderr [deleted file]
src/test/ui/traits/wf-trait-object-only-maybe-bound.rs [deleted file]
src/test/ui/traits/wf-trait-object-only-maybe-bound.stderr [deleted file]
src/test/ui/traits/wf-trait-object-reverse-order.rs [deleted file]
src/test/ui/traits/where-clause-vs-impl.rs [new file with mode: 0644]
src/test/ui/traits/with-bounds-default.rs [new file with mode: 0644]
src/test/ui/traits/with-dst.rs [new file with mode: 0644]

diff --git a/src/test/ui/traits/alias/ambiguous.rs b/src/test/ui/traits/alias/ambiguous.rs
new file mode 100644 (file)
index 0000000..28409e0
--- /dev/null
@@ -0,0 +1,24 @@
+#![feature(trait_alias)]
+
+mod inner {
+    pub trait A { fn foo(&self); }
+    pub trait B { fn foo(&self); }
+
+    impl A for u8 {
+        fn foo(&self) {}
+    }
+    impl B for u8 {
+        fn foo(&self) {}
+    }
+
+    pub trait C = A + B;
+}
+
+use inner::C;
+
+fn main() {
+    let t = 1u8;
+    t.foo(); //~ ERROR E0034
+
+    inner::A::foo(&t); // ok
+}
diff --git a/src/test/ui/traits/alias/ambiguous.stderr b/src/test/ui/traits/alias/ambiguous.stderr
new file mode 100644 (file)
index 0000000..649ce72
--- /dev/null
@@ -0,0 +1,28 @@
+error[E0034]: multiple applicable items in scope
+  --> $DIR/ambiguous.rs:21:7
+   |
+LL |     t.foo();
+   |       ^^^ multiple `foo` found
+   |
+note: candidate #1 is defined in an impl of the trait `A` for the type `u8`
+  --> $DIR/ambiguous.rs:8:9
+   |
+LL |         fn foo(&self) {}
+   |         ^^^^^^^^^^^^^
+note: candidate #2 is defined in an impl of the trait `B` for the type `u8`
+  --> $DIR/ambiguous.rs:11:9
+   |
+LL |         fn foo(&self) {}
+   |         ^^^^^^^^^^^^^
+help: disambiguate the associated function for candidate #1
+   |
+LL |     A::foo(&t);
+   |     ^^^^^^^^^^
+help: disambiguate the associated function for candidate #2
+   |
+LL |     B::foo(&t);
+   |     ^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0034`.
diff --git a/src/test/ui/traits/alias/auxiliary/greeter.rs b/src/test/ui/traits/alias/auxiliary/greeter.rs
new file mode 100644 (file)
index 0000000..9e41221
--- /dev/null
@@ -0,0 +1,13 @@
+#![feature(trait_alias)]
+
+pub trait Hello {
+    fn hello(&self);
+}
+
+pub struct Hi;
+
+impl Hello for Hi {
+    fn hello(&self) {}
+}
+
+pub trait Greet = Hello;
diff --git a/src/test/ui/traits/alias/auxiliary/send_sync.rs b/src/test/ui/traits/alias/auxiliary/send_sync.rs
new file mode 100644 (file)
index 0000000..9e56b87
--- /dev/null
@@ -0,0 +1,3 @@
+#![feature(trait_alias)]
+
+pub trait SendSync = Send + Sync;
diff --git a/src/test/ui/traits/alias/basic.rs b/src/test/ui/traits/alias/basic.rs
new file mode 100644 (file)
index 0000000..d8168f2
--- /dev/null
@@ -0,0 +1,8 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+pub trait Foo {}
+pub trait FooAlias = Foo;
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/bounds.rs b/src/test/ui/traits/alias/bounds.rs
new file mode 100644 (file)
index 0000000..b97eb38
--- /dev/null
@@ -0,0 +1,57 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+use std::marker::PhantomData;
+
+trait Empty {}
+trait EmptyAlias = Empty;
+trait CloneDefault = Clone + Default;
+trait SendSyncAlias = Send + Sync;
+trait WhereSendAlias = where Self: Send;
+trait SendEqAlias<T> = Send where T: PartialEq<Self>;
+trait I32Iterator = Iterator<Item = i32>;
+
+#[allow(dead_code)]
+struct Foo<T: SendSyncAlias>(PhantomData<T>);
+#[allow(dead_code)]
+struct Bar<T>(PhantomData<T>) where T: SendSyncAlias;
+
+impl dyn EmptyAlias {}
+
+impl<T: SendSyncAlias> Empty for T {}
+
+fn a<T: CloneDefault>() -> (T, T) {
+    let one = T::default();
+    let two = one.clone();
+    (one, two)
+}
+
+fn b(x: &impl SendEqAlias<i32>) -> bool {
+    22_i32 == *x
+}
+
+fn c<T: I32Iterator>(x: &mut T) -> Option<i32> {
+    x.next()
+}
+
+fn d<T: SendSyncAlias>() {
+    is_send_and_sync::<T>();
+}
+
+fn is_send_and_sync<T: Send + Sync>() {}
+
+fn main() {
+    let both = a::<i32>();
+    assert_eq!(both.0, 0);
+    assert_eq!(both.1, 0);
+    let both: (i32, i32) = a();
+    assert_eq!(both.0, 0);
+    assert_eq!(both.1, 0);
+
+    assert!(b(&22));
+
+    assert_eq!(c(&mut vec![22].into_iter()), Some(22));
+
+    d::<i32>();
+}
diff --git a/src/test/ui/traits/alias/cross-crate.rs b/src/test/ui/traits/alias/cross-crate.rs
new file mode 100644 (file)
index 0000000..8919c64
--- /dev/null
@@ -0,0 +1,17 @@
+// aux-build:send_sync.rs
+
+#![feature(trait_alias)]
+
+extern crate send_sync;
+
+use std::rc::Rc;
+use send_sync::SendSync;
+
+fn use_alias<T: SendSync>() {}
+
+fn main() {
+    use_alias::<u32>();
+    use_alias::<Rc<u32>>();
+    //~^ ERROR `Rc<u32>` cannot be sent between threads safely [E0277]
+    //~^^ ERROR `Rc<u32>` cannot be shared between threads safely [E0277]
+}
diff --git a/src/test/ui/traits/alias/cross-crate.stderr b/src/test/ui/traits/alias/cross-crate.stderr
new file mode 100644 (file)
index 0000000..3b8fee8
--- /dev/null
@@ -0,0 +1,25 @@
+error[E0277]: `Rc<u32>` cannot be sent between threads safely
+  --> $DIR/cross-crate.rs:14:17
+   |
+LL | fn use_alias<T: SendSync>() {}
+   |                 -------- required by this bound in `use_alias`
+...
+LL |     use_alias::<Rc<u32>>();
+   |                 ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
+   |
+   = help: the trait `Send` is not implemented for `Rc<u32>`
+
+error[E0277]: `Rc<u32>` cannot be shared between threads safely
+  --> $DIR/cross-crate.rs:14:17
+   |
+LL | fn use_alias<T: SendSync>() {}
+   |                 -------- required by this bound in `use_alias`
+...
+LL |     use_alias::<Rc<u32>>();
+   |                 ^^^^^^^ `Rc<u32>` cannot be shared between threads safely
+   |
+   = help: the trait `Sync` is not implemented for `Rc<u32>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/alias/impl.rs b/src/test/ui/traits/alias/impl.rs
new file mode 100644 (file)
index 0000000..6e35793
--- /dev/null
@@ -0,0 +1,7 @@
+#![feature(trait_alias)]
+
+trait DefaultAlias = Default;
+
+impl DefaultAlias for () {} //~ ERROR expected trait, found trait alias
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/impl.stderr b/src/test/ui/traits/alias/impl.stderr
new file mode 100644 (file)
index 0000000..cedcd10
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0404]: expected trait, found trait alias `DefaultAlias`
+  --> $DIR/impl.rs:5:6
+   |
+LL | impl DefaultAlias for () {}
+   |      ^^^^^^^^^^^^ not a trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/src/test/ui/traits/alias/import-cross-crate.rs b/src/test/ui/traits/alias/import-cross-crate.rs
new file mode 100644 (file)
index 0000000..868585c
--- /dev/null
@@ -0,0 +1,14 @@
+// run-pass
+// aux-build:greeter.rs
+
+#![feature(trait_alias)]
+
+extern crate greeter;
+
+// Import only the alias, not the real trait.
+use greeter::{Greet, Hi};
+
+fn main() {
+    let hi = Hi;
+    hi.hello(); // From `Hello`, via `Greet` alias.
+}
diff --git a/src/test/ui/traits/alias/import.rs b/src/test/ui/traits/alias/import.rs
new file mode 100644 (file)
index 0000000..802a8f1
--- /dev/null
@@ -0,0 +1,40 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+mod inner {
+    pub trait Foo {
+        fn foo(&self);
+    }
+
+    pub struct Qux;
+
+    impl Foo for Qux {
+        fn foo(&self) {}
+    }
+
+    pub trait Bar = Foo;
+}
+
+mod two {
+    pub trait A {
+        fn foo();
+    }
+
+    impl A for u8 {
+        fn foo() {}
+    }
+}
+
+// Import only the alias, not the `Foo` trait.
+use inner::{Bar, Qux};
+
+// Declaring an alias also brings in aliased methods.
+trait Two = two::A;
+
+fn main() {
+    let q = Qux;
+    q.foo(); // From Bar.
+
+    u8::foo(); // From A.
+}
diff --git a/src/test/ui/traits/alias/issue-60021-assoc-method-resolve.rs b/src/test/ui/traits/alias/issue-60021-assoc-method-resolve.rs
new file mode 100644 (file)
index 0000000..5e27ed3
--- /dev/null
@@ -0,0 +1,19 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+trait SomeTrait {
+    fn map(&self) {}
+}
+
+impl<T> SomeTrait for Option<T> {}
+
+trait SomeAlias = SomeTrait;
+
+fn main() {
+    let x = Some(123);
+    // This should resolve to the trait impl for Option
+    Option::map(x, |z| z);
+    // This should resolve to the trait impl for SomeTrait
+    SomeTrait::map(&x);
+}
diff --git a/src/test/ui/traits/alias/issue-72415-assoc-const-resolve.rs b/src/test/ui/traits/alias/issue-72415-assoc-const-resolve.rs
new file mode 100644 (file)
index 0000000..e49125d
--- /dev/null
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+trait Bounded { const MAX: Self; }
+
+impl Bounded for u32 {
+    // This should correctly resolve to the associated const in the inherent impl of u32.
+    const MAX: Self = u32::MAX;
+}
+
+trait Num = Bounded + Copy;
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/issue-75983.rs b/src/test/ui/traits/alias/issue-75983.rs
new file mode 100644 (file)
index 0000000..f9a7f36
--- /dev/null
@@ -0,0 +1,17 @@
+// check-pass
+
+#![feature(trait_alias)]
+
+struct Bar;
+trait Foo {}
+impl Foo for Bar {}
+
+trait Baz = Foo where Bar: Foo;
+
+fn new() -> impl Baz {
+    Bar
+}
+
+fn main() {
+    let _ = new();
+}
diff --git a/src/test/ui/traits/alias/maybe-bound.rs b/src/test/ui/traits/alias/maybe-bound.rs
new file mode 100644 (file)
index 0000000..284baa4
--- /dev/null
@@ -0,0 +1,29 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+// Test that `dyn ... + ?Sized + ...` resulting from the expansion of trait aliases is okay.
+
+#![feature(trait_alias)]
+
+trait Foo {}
+
+trait S = ?Sized;
+
+// Nest a couple of levels deep:
+trait _0 = S;
+trait _1 = _0;
+
+// Straight list expansion:
+type _T0 = dyn _1 + Foo;
+
+// In second position:
+type _T1 = dyn Foo + _1;
+
+// ... and with an auto trait:
+type _T2 = dyn Foo + Send + _1;
+
+// Twice:
+trait _2 = _1 + _1;
+
+type _T3 = dyn _2 + Foo;
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/no-duplicates.rs b/src/test/ui/traits/alias/no-duplicates.rs
new file mode 100644 (file)
index 0000000..88feb89
--- /dev/null
@@ -0,0 +1,126 @@
+// The purpose of this test is to demonstrate that duplicating object safe traits
+// that are not auto traits is rejected with trait aliases even though one could
+// reasonably accept this.
+
+#![feature(trait_alias)]
+
+use std::marker::Unpin;
+
+// Some arbitrary object-safe trait:
+trait Obj {}
+
+// Nest a few levels deep:
+trait _0 = Obj;
+trait _1 = _0;
+
+type _T00 = dyn _0 + _0;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T01 = dyn _1 + _0;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T02 = dyn _1 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T03 = dyn Obj + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T04 = dyn _1 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more and in weird ways:
+
+trait _2 = _0 + _1;
+trait _3 = Obj;
+trait _4 = _3;
+
+type _T10 = dyn _2 + _3;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T11 = dyn _3 + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T12 = dyn Obj + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T13 = dyn _2 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T14 = dyn _1 + _3;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T15 = dyn _3 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T16 = dyn _1 + _4;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T17 = dyn _4 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Include auto traits:
+
+trait _5 = Obj + Send;
+
+type _T20 = dyn _5 + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T21 = dyn Obj + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T22 = dyn _5 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T23 = dyn _5 + Send + Sync + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Also nest:
+
+trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+
+type _T30 = dyn _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T31 = dyn _6 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T32 = dyn Send + _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more:
+
+trait _7 = _5 + Sync;
+trait _8 = Unpin + _7;
+
+type _T40 = dyn _8 + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T41 = dyn Obj + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T42 = dyn _8 + _4;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T43 = dyn _4 + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T44 = dyn _4 + Send + Sync + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Take higher ranked types into account.
+
+// Note that `'a` and `'b` are intentionally different to make sure we consider
+// them semantically the same.
+trait ObjL<'l> {}
+trait _9 = for<'a> ObjL<'a>;
+trait _10 = for<'b> ObjL<'b>;
+type _T50 = dyn _9 + _10;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+trait ObjT<T> {}
+trait _11 = ObjT<for<'a> fn(&'a u8)>;
+trait _12 = ObjT<for<'b> fn(&'b u8)>;
+type _T60 = dyn _11 + _12;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/no-duplicates.stderr b/src/test/ui/traits/alias/no-duplicates.stderr
new file mode 100644 (file)
index 0000000..9f38dd4
--- /dev/null
@@ -0,0 +1,527 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:16:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | type _T00 = dyn _0 + _0;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:19:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | type _T01 = dyn _1 + _0;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:22:22
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T02 = dyn _1 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:25:23
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | type _T03 = dyn Obj + _1;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:28:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | type _T04 = dyn _1 + Obj;
+   |                 --   ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:37:17
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _2 = _0 + _1;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T10 = dyn _2 + _3;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:40:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+...
+LL | trait _2 = _0 + _1;
+   |            -- referenced here (additional use)
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T11 = dyn _3 + _2;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:43:23
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+...
+LL | trait _2 = _0 + _1;
+   |            -- referenced here (additional use)
+...
+LL | type _T12 = dyn Obj + _2;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:46:17
+   |
+LL | trait _0 = Obj;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _2 = _0 + _1;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T13 = dyn _2 + Obj;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:49:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+...
+LL | type _T14 = dyn _1 + _3;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:52:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+...
+LL | type _T15 = dyn _3 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:55:22
+   |
+LL | trait _0 = Obj;
+   |            --- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (additional use)
+...
+LL | type _T16 = dyn _1 + _4;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:58:22
+   |
+LL | trait _0 = Obj;
+   |            --- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | type _T17 = dyn _4 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:65:22
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | 
+LL | type _T20 = dyn _5 + _5;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:68:23
+   |
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | type _T21 = dyn Obj + _5;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:71:22
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T22 = dyn _5 + Obj;
+   |                 --   ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:74:36
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | type _T23 = dyn _5 + Send + Sync + Obj;
+   |                 --                 ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:81:17
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | 
+LL | type _T30 = dyn _6;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:84:17
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T31 = dyn _6 + Send;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:87:24
+   |
+LL | trait _5 = Obj + Send;
+   |            ---
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+...
+LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T32 = dyn Send + _6;
+   |                        ^^
+   |                        |
+   |                        trait alias used in trait object type (additional use)
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:95:22
+   |
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (first use)
+LL | 
+LL | type _T40 = dyn _8 + Obj;
+   |                 --   ^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:98:23
+   |
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (additional use)
+...
+LL | type _T41 = dyn Obj + _8;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:101:22
+   |
+LL | trait _3 = Obj;
+   |            --- additional non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Obj + Send;
+   |            --- first non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (first use)
+...
+LL | type _T42 = dyn _8 + _4;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:104:22
+   |
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (additional use)
+...
+LL | type _T43 = dyn _4 + _8;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:107:36
+   |
+LL | trait _3 = Obj;
+   |            --- first non-auto trait
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Obj + Send;
+   |            --- additional non-auto trait
+...
+LL | trait _7 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _8 = Unpin + _7;
+   |                    -- referenced here (additional use)
+...
+LL | type _T44 = dyn _4 + Send + Sync + _8;
+   |                 --                 ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:117:22
+   |
+LL | trait _9 = for<'a> ObjL<'a>;
+   |            ---------------- first non-auto trait
+LL | trait _10 = for<'b> ObjL<'b>;
+   |             ---------------- additional non-auto trait
+LL | type _T50 = dyn _9 + _10;
+   |                 --   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: for<'a> ObjL<'a> + for<'b> ObjL<'b> {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:123:23
+   |
+LL | trait _11 = ObjT<for<'a> fn(&'a u8)>;
+   |             ------------------------ first non-auto trait
+LL | trait _12 = ObjT<for<'b> fn(&'b u8)>;
+   |             ------------------------ additional non-auto trait
+LL | type _T60 = dyn _11 + _12;
+   |                 ---   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)> {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error: aborting due to 27 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/alias/no-extra-traits.rs b/src/test/ui/traits/alias/no-extra-traits.rs
new file mode 100644 (file)
index 0000000..4dad8c0
--- /dev/null
@@ -0,0 +1,121 @@
+// The purpose of this test is to demonstrate that trait alias expansion
+// preserves the rule that `dyn Trait` may only reference one non-auto trait.
+
+#![feature(trait_alias)]
+
+use std::marker::Unpin;
+
+// Some arbitrary object-safe traits:
+trait ObjA {}
+trait ObjB {}
+
+// Nest a few levels deep:
+trait _0 = ObjA;
+trait _1 = _0;
+
+type _T00 = dyn _0 + ObjB;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T01 = dyn ObjB + _0;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T02 = dyn ObjB + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T03 = dyn _1 + ObjB;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more and in weird ways:
+
+trait _2 = ObjB;
+trait _3 = _2;
+trait _4 = _3;
+
+type _T10 = dyn _2 + _3;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T11 = dyn _3 + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T12 = dyn _2 + _4;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T13 = dyn _4 + _2;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Include auto traits:
+
+trait _5 = Sync + ObjB + Send;
+
+type _T20 = dyn _5 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T21 = dyn _1 + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T22 = dyn _5 + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T23 = dyn ObjA + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T24 = dyn Send + _5 + _1 + Sync;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T25 = dyn _1 + Sync + _5 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T26 = dyn Sync + Send + _5 + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T27 = dyn Send + Sync + ObjA + _5;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Also nest:
+
+trait _6 = _1 + _5;
+trait _7 = _6;
+trait _8 = _7;
+
+type _T30 = dyn _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T31 = dyn _6 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T32 = dyn Send + _6;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T33 = dyn _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T34 = dyn _8 + Send;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T35 = dyn Send + _8;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Nest some more:
+
+trait _9 = _5 + Sync;
+trait _10 = Unpin + _9;
+
+type _T40 = dyn _10 + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T41 = dyn ObjA + _10;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T42 = dyn _10 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T43 = dyn Send + _10 + Sync + ObjA;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T44 = dyn ObjA + _10 + Send + Sync;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _T45 = dyn Sync + Send + _10 + _1;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/no-extra-traits.stderr b/src/test/ui/traits/alias/no-extra-traits.stderr
new file mode 100644 (file)
index 0000000..cdb5cd9
--- /dev/null
@@ -0,0 +1,579 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:16:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+...
+LL | type _T00 = dyn _0 + ObjB;
+   |                 --   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:19:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+...
+LL | type _T01 = dyn ObjB + _0;
+   |                 ----   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:22:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | type _T02 = dyn ObjB + _1;
+   |                 ----   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:25:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | type _T03 = dyn _1 + ObjB;
+   |                 --   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:34:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (additional use)
+...
+LL | type _T10 = dyn _2 + _3;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:37:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (first use)
+...
+LL | type _T11 = dyn _3 + _2;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:40:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (additional use)
+LL | trait _4 = _3;
+   |            -- referenced here (additional use)
+...
+LL | type _T12 = dyn _2 + _4;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:43:22
+   |
+LL | trait _2 = ObjB;
+   |            ----
+   |            |
+   |            additional non-auto trait
+   |            first non-auto trait
+LL | trait _3 = _2;
+   |            -- referenced here (first use)
+LL | trait _4 = _3;
+   |            -- referenced here (first use)
+...
+LL | type _T13 = dyn _4 + _2;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:50:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+LL | 
+LL | type _T20 = dyn _5 + _1;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:53:22
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T21 = dyn _1 + _5;
+   |                 --   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:56:22
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T22 = dyn _5 + ObjA;
+   |                 --   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:59:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T23 = dyn ObjA + _5;
+   |                 ----   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:62:29
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T24 = dyn Send + _5 + _1 + Sync;
+   |                        --   ^^ trait alias used in trait object type (additional use)
+   |                        |
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:65:29
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T25 = dyn _1 + Sync + _5 + Send;
+   |                 --          ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:68:36
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | type _T26 = dyn Sync + Send + _5 + ObjA;
+   |                               --   ^^^^ additional non-auto trait
+   |                               |
+   |                               trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:71:38
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | type _T27 = dyn Send + Sync + ObjA + _5;
+   |                               ----   ^^ trait alias used in trait object type (additional use)
+   |                               |
+   |                               first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:80:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T30 = dyn _6;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:83:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T31 = dyn _6 + Send;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:86:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+...
+LL | type _T32 = dyn Send + _6;
+   |                        ^^
+   |                        |
+   |                        trait alias used in trait object type (additional use)
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:89:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | trait _7 = _6;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+LL | trait _8 = _7;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T33 = dyn _8;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:92:17
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | trait _7 = _6;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+LL | trait _8 = _7;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T34 = dyn _8 + Send;
+   |                 ^^
+   |                 |
+   |                 trait alias used in trait object type (additional use)
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:95:24
+   |
+LL | trait _0 = ObjA;
+   |            ---- first non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (first use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _6 = _1 + _5;
+   |            --   -- referenced here (additional use)
+   |            |
+   |            referenced here (first use)
+LL | trait _7 = _6;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+LL | trait _8 = _7;
+   |            --
+   |            |
+   |            referenced here (additional use)
+   |            referenced here (first use)
+...
+LL | type _T35 = dyn Send + _8;
+   |                        ^^
+   |                        |
+   |                        trait alias used in trait object type (additional use)
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:103:23
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+LL | 
+LL | type _T40 = dyn _10 + ObjA;
+   |                 ---   ^^^^ additional non-auto trait
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:106:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (additional use)
+...
+LL | type _T41 = dyn ObjA + _10;
+   |                 ----   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:109:23
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+...
+LL | type _T42 = dyn _10 + _1;
+   |                 ---   ^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:112:37
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+...
+LL | type _T43 = dyn Send + _10 + Sync + ObjA;
+   |                        ---          ^^^^ additional non-auto trait
+   |                        |
+   |                        trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:115:24
+   |
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- additional non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (additional use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (additional use)
+...
+LL | type _T44 = dyn ObjA + _10 + Send + Sync;
+   |                 ----   ^^^ trait alias used in trait object type (additional use)
+   |                 |
+   |                 first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-extra-traits.rs:118:37
+   |
+LL | trait _0 = ObjA;
+   |            ---- additional non-auto trait
+LL | trait _1 = _0;
+   |            -- referenced here (additional use)
+...
+LL | trait _5 = Sync + ObjB + Send;
+   |                   ---- first non-auto trait
+...
+LL | trait _9 = _5 + Sync;
+   |            -- referenced here (first use)
+LL | trait _10 = Unpin + _9;
+   |                     -- referenced here (first use)
+...
+LL | type _T45 = dyn Sync + Send + _10 + _1;
+   |                               ---   ^^ trait alias used in trait object type (additional use)
+   |                               |
+   |                               trait alias used in trait object type (first use)
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error: aborting due to 28 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/alias/object-fail.rs b/src/test/ui/traits/alias/object-fail.rs
new file mode 100644 (file)
index 0000000..5c753ff
--- /dev/null
@@ -0,0 +1,11 @@
+#![feature(trait_alias)]
+
+trait EqAlias = Eq;
+trait IteratorAlias = Iterator;
+
+fn main() {
+    let _: &dyn EqAlias = &123;
+    //~^ ERROR the trait `Eq` cannot be made into an object [E0038]
+    let _: &dyn IteratorAlias = &vec![123].into_iter();
+    //~^ ERROR must be specified
+}
diff --git a/src/test/ui/traits/alias/object-fail.stderr b/src/test/ui/traits/alias/object-fail.stderr
new file mode 100644 (file)
index 0000000..325bc6d
--- /dev/null
@@ -0,0 +1,22 @@
+error[E0038]: the trait `Eq` cannot be made into an object
+  --> $DIR/object-fail.rs:7:13
+   |
+LL |     let _: &dyn EqAlias = &123;
+   |             ^^^^^^^^^^^ `Eq` cannot be made into an object
+   |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $SRC_DIR/core/src/cmp.rs:LL:COL
+   |
+LL | pub trait Eq: PartialEq<Self> {
+   |               ^^^^^^^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
+
+error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified
+  --> $DIR/object-fail.rs:9:17
+   |
+LL |     let _: &dyn IteratorAlias = &vec![123].into_iter();
+   |                 ^^^^^^^^^^^^^ help: specify the associated type: `IteratorAlias<Item = Type>`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0038, E0191.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/alias/object-wf.rs b/src/test/ui/traits/alias/object-wf.rs
new file mode 100644 (file)
index 0000000..1440f02
--- /dev/null
@@ -0,0 +1,85 @@
+// check-pass
+
+// This test checks that trait objects involving trait aliases are well-formed.
+
+#![feature(trait_alias)]
+
+trait Obj {}
+
+trait _0 = Send + Sync;
+
+// Just auto traits:
+
+trait _1 = _0 + Send + Sync;
+
+use std::marker::Unpin;
+
+fn _f0() {
+    let _: Box<dyn _0>;
+    let _: Box<dyn _1>;
+    let _: Box<dyn Unpin + _1 + Send + Sync>;
+}
+
+// Include object safe traits:
+
+fn _f1() {
+    let _: Box<dyn Obj + _0>;
+    let _: Box<dyn Obj + _1>;
+    let _: Box<dyn Obj + _1 + _0>;
+}
+
+// And when the object safe trait is in a trait alias:
+
+trait _2 = Obj;
+
+fn _f2() {
+    let _: Box<dyn _2 + _0>;
+    let _: Box<dyn _2 + _1>;
+    let _: Box<dyn _2 + _1 + _0>;
+}
+
+// And it should also work when that trait is has auto traits to the right of it.
+
+trait _3 = Obj + Unpin;
+
+fn _f3() {
+    let _: Box<dyn _3 + _0>;
+    let _: Box<dyn _3 + _1>;
+    let _: Box<dyn _3 + _1 + _0>;
+}
+
+// Nest the trait deeply:
+
+trait _4 = _3;
+trait _5 = _4 + Sync + _0 + Send;
+trait _6 = _5 + Send + _1 + Sync;
+
+fn _f4() {
+    let _: Box<dyn _6 + _0>;
+    let _: Box<dyn _6 + _1>;
+    let _: Box<dyn _6 + _1 + _0>;
+}
+
+// Just nest the trait alone:
+
+trait _7 = _2;
+trait _8 = _7;
+trait _9 = _8;
+
+fn _f5() {
+    let _: Box<dyn _9>;
+}
+
+// First bound is auto trait:
+
+trait _10 = Send + Obj;
+trait _11 = Obj + Send;
+trait _12 = Sync + _11;
+trait _13 = Send + _12;
+
+fn f6() {
+    let _: Box<dyn _10>;
+    let _: Box<dyn _13>;
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/object.rs b/src/test/ui/traits/alias/object.rs
new file mode 100644 (file)
index 0000000..12177cd
--- /dev/null
@@ -0,0 +1,18 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+trait Foo = PartialEq<i32> + Send;
+trait Bar = Foo + Sync;
+
+trait I32Iterator = Iterator<Item = i32>;
+
+pub fn main() {
+    let a: &dyn Bar = &123;
+    assert!(*a == 123);
+    let b = Box::new(456) as Box<dyn Foo>;
+    assert!(*b == 456);
+
+    let c: &mut dyn I32Iterator = &mut vec![123].into_iter();
+    assert_eq!(c.next(), Some(123));
+}
diff --git a/src/test/ui/traits/alias/only-maybe-bound.rs b/src/test/ui/traits/alias/only-maybe-bound.rs
new file mode 100644 (file)
index 0000000..e4abf31
--- /dev/null
@@ -0,0 +1,22 @@
+// Test that `dyn ?Sized` (i.e., a trait object with only a maybe buond) is not allowed, when just
+// `?Sized` results from trait alias expansion.
+
+#![feature(trait_alias)]
+
+trait S = ?Sized;
+
+// Nest a couple of levels deep:
+trait _0 = S;
+trait _1 = _0;
+
+// Straight list expansion:
+type _T0 = dyn _1;
+//~^ ERROR at least one trait is required for an object type [E0224]
+
+// Twice:
+trait _2 = _1 + _1;
+
+type _T1 = dyn _2;
+//~^ ERROR at least one trait is required for an object type [E0224]
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/only-maybe-bound.stderr b/src/test/ui/traits/alias/only-maybe-bound.stderr
new file mode 100644 (file)
index 0000000..99589ed
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/only-maybe-bound.rs:13:12
+   |
+LL | type _T0 = dyn _1;
+   |            ^^^^^^
+
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/only-maybe-bound.rs:19:12
+   |
+LL | type _T1 = dyn _2;
+   |            ^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0224`.
diff --git a/src/test/ui/traits/alias/syntax-fail.rs b/src/test/ui/traits/alias/syntax-fail.rs
new file mode 100644 (file)
index 0000000..039bbce
--- /dev/null
@@ -0,0 +1,10 @@
+#![feature(trait_alias)]
+
+trait Foo {}
+auto trait A = Foo; //~ ERROR trait aliases cannot be `auto`
+unsafe trait B = Foo; //~ ERROR trait aliases cannot be `unsafe`
+
+trait C: Ord = Eq; //~ ERROR bounds are not allowed on trait aliases
+trait D: = Eq; //~ ERROR bounds are not allowed on trait aliases
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/syntax-fail.stderr b/src/test/ui/traits/alias/syntax-fail.stderr
new file mode 100644 (file)
index 0000000..748b920
--- /dev/null
@@ -0,0 +1,26 @@
+error: trait aliases cannot be `auto`
+  --> $DIR/syntax-fail.rs:4:1
+   |
+LL | auto trait A = Foo;
+   | ^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto`
+
+error: trait aliases cannot be `unsafe`
+  --> $DIR/syntax-fail.rs:5:1
+   |
+LL | unsafe trait B = Foo;
+   | ^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe`
+
+error: bounds are not allowed on trait aliases
+  --> $DIR/syntax-fail.rs:7:8
+   |
+LL | trait C: Ord = Eq;
+   |        ^^^^^
+
+error: bounds are not allowed on trait aliases
+  --> $DIR/syntax-fail.rs:8:8
+   |
+LL | trait D: = Eq;
+   |        ^
+
+error: aborting due to 4 previous errors
+
diff --git a/src/test/ui/traits/alias/syntax.rs b/src/test/ui/traits/alias/syntax.rs
new file mode 100644 (file)
index 0000000..17557a5
--- /dev/null
@@ -0,0 +1,24 @@
+// run-pass
+
+#![feature(trait_alias)]
+
+trait SimpleAlias = Default;
+trait GenericAlias<T> = Iterator<Item = T>;
+trait Partial<T> = IntoIterator<Item = T>;
+trait SpecificAlias = GenericAlias<i32>;
+trait PartialEqRef<'a, T: 'a> = PartialEq<&'a T>;
+trait StaticAlias = 'static;
+
+trait Things<T> {}
+trait Romeo {}
+#[allow(dead_code)]
+struct The<T>(T);
+#[allow(dead_code)]
+struct Fore<T>(T);
+impl<T, U> Things<T> for The<U> {}
+impl<T> Romeo for Fore<T> {}
+
+trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo;
+trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>;
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/wf.rs b/src/test/ui/traits/alias/wf.rs
new file mode 100644 (file)
index 0000000..d10e2ab
--- /dev/null
@@ -0,0 +1,7 @@
+#![feature(trait_alias)]
+
+trait Foo {}
+trait A<T: Foo> {}
+trait B<T> = A<T>; //~ ERROR `T: Foo` is not satisfied
+
+fn main() {}
diff --git a/src/test/ui/traits/alias/wf.stderr b/src/test/ui/traits/alias/wf.stderr
new file mode 100644 (file)
index 0000000..b07145f
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0277]: the trait bound `T: Foo` is not satisfied
+  --> $DIR/wf.rs:5:14
+   |
+LL | trait A<T: Foo> {}
+   |            --- required by this bound in `A`
+LL | trait B<T> = A<T>;
+   |              ^^^^ the trait `Foo` is not implemented for `T`
+   |
+help: consider restricting type parameter `T`
+   |
+LL | trait B<T: Foo> = A<T>;
+   |          ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/anon-static-method.rs b/src/test/ui/traits/anon-static-method.rs
new file mode 100644 (file)
index 0000000..ede01af
--- /dev/null
@@ -0,0 +1,15 @@
+// run-pass
+struct Foo {
+    x: isize
+}
+
+impl Foo {
+    pub fn new() -> Foo {
+        Foo { x: 3 }
+    }
+}
+
+pub fn main() {
+    let x = Foo::new();
+    println!("{}", x.x);
+}
diff --git a/src/test/ui/traits/anon-trait-static-method.rs b/src/test/ui/traits/anon-trait-static-method.rs
deleted file mode 100644 (file)
index ede01af..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-struct Foo {
-    x: isize
-}
-
-impl Foo {
-    pub fn new() -> Foo {
-        Foo { x: 3 }
-    }
-}
-
-pub fn main() {
-    let x = Foo::new();
-    println!("{}", x.x);
-}
diff --git a/src/test/ui/traits/as-struct-constructor.rs b/src/test/ui/traits/as-struct-constructor.rs
new file mode 100644 (file)
index 0000000..13ebf9d
--- /dev/null
@@ -0,0 +1,6 @@
+trait TraitNotAStruct {}
+
+fn main() {
+    TraitNotAStruct{ value: 0 };
+    //~^ ERROR expected struct, variant or union type, found trait `TraitNotAStruct`
+}
diff --git a/src/test/ui/traits/as-struct-constructor.stderr b/src/test/ui/traits/as-struct-constructor.stderr
new file mode 100644 (file)
index 0000000..d06e85f
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0574]: expected struct, variant or union type, found trait `TraitNotAStruct`
+  --> $DIR/as-struct-constructor.rs:4:5
+   |
+LL |     TraitNotAStruct{ value: 0 };
+   |     ^^^^^^^^^^^^^^^ not a struct, variant or union type
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0574`.
diff --git a/src/test/ui/traits/assoc-type-in-superbad.rs b/src/test/ui/traits/assoc-type-in-superbad.rs
new file mode 100644 (file)
index 0000000..579ce7c
--- /dev/null
@@ -0,0 +1,16 @@
+// Test case where an associated type is referenced from within the
+// supertrait definition, and the impl makes the wrong
+// associations. Issue #20220.
+
+use std::vec::IntoIter;
+
+pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
+    type Key;
+}
+
+impl Foo for IntoIter<i32> {
+    type Key = u32; //~ ERROR type mismatch
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/assoc-type-in-superbad.stderr b/src/test/ui/traits/assoc-type-in-superbad.stderr
new file mode 100644 (file)
index 0000000..cbdb6b9
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0271]: type mismatch resolving `<std::vec::IntoIter<i32> as Iterator>::Item == u32`
+  --> $DIR/assoc-type-in-superbad.rs:12:16
+   |
+LL |     type Key = u32;
+   |                ^^^ expected `i32`, found `u32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/traits/assoc-type-in-supertrait.rs b/src/test/ui/traits/assoc-type-in-supertrait.rs
new file mode 100644 (file)
index 0000000..7d6a754
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+// Test case where an associated type is referenced from within the
+// supertrait definition. Issue #20220.
+
+
+use std::vec::IntoIter;
+
+pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
+    type Key;
+}
+
+impl Foo for IntoIter<i32> {
+    type Key = i32;
+}
+
+fn sum_foo<F:Foo<Key=i32>>(f: F) -> i32 {
+    f.fold(0, |a,b| a + b)
+}
+
+fn main() {
+    let x = sum_foo(vec![11, 10, 1].into_iter());
+    assert_eq!(x, 22);
+}
diff --git a/src/test/ui/traits/assoc_type_bound_with_struct.rs b/src/test/ui/traits/assoc_type_bound_with_struct.rs
deleted file mode 100644 (file)
index c66009f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-trait Bar {
-    type Baz;
-}
-
-struct Foo<T> where T: Bar, <T as Bar>::Baz: String { //~ ERROR expected trait, found struct
-    t: T,
-}
-
-struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String { //~ ERROR expected trait, found struct
-    t: &'a T,
-}
-
-fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String { //~ ERROR expected trait, found struct
-}
-
-fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String { //~ ERROR expected trait, found
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/assoc_type_bound_with_struct.stderr b/src/test/ui/traits/assoc_type_bound_with_struct.stderr
deleted file mode 100644 (file)
index 7cf872e..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-error[E0404]: expected trait, found struct `String`
-  --> $DIR/assoc_type_bound_with_struct.rs:5:46
-   |
-LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: String {
-   |                                              ^^^^^^ not a trait
-   | 
-  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
-   |
-LL | pub trait ToString {
-   | ------------------ similarly named trait `ToString` defined here
-   |
-help: constrain the associated type to `String`
-   |
-LL | struct Foo<T> where T: Bar, T: Bar<Baz = String> {
-   |                             ^^^^^^^^^^^^^^^^^^^^
-help: a trait with a similar name exists
-   |
-LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: ToString {
-   |                                              ^^^^^^^^
-
-error[E0404]: expected trait, found struct `String`
-  --> $DIR/assoc_type_bound_with_struct.rs:9:54
-   |
-LL | struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String {
-   |                                                      ^^^^^^ not a trait
-   | 
-  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
-   |
-LL | pub trait ToString {
-   | ------------------ similarly named trait `ToString` defined here
-   |
-help: constrain the associated type to `String`
-   |
-LL | struct Qux<'a, T> where T: Bar, &'a T: Bar<Baz = String> {
-   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^
-help: a trait with a similar name exists
-   |
-LL | struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: ToString {
-   |                                                      ^^^^^^^^
-
-error[E0404]: expected trait, found struct `String`
-  --> $DIR/assoc_type_bound_with_struct.rs:13:45
-   |
-LL | fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String {
-   |                                             ^^^^^^ not a trait
-   | 
-  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
-   |
-LL | pub trait ToString {
-   | ------------------ similarly named trait `ToString` defined here
-   |
-help: constrain the associated type to `String`
-   |
-LL | fn foo<T: Bar>(_: T) where T: Bar<Baz = String> {
-   |                            ^^^^^^^^^^^^^^^^^^^^
-help: a trait with a similar name exists
-   |
-LL | fn foo<T: Bar>(_: T) where <T as Bar>::Baz: ToString {
-   |                                             ^^^^^^^^
-
-error[E0404]: expected trait, found struct `String`
-  --> $DIR/assoc_type_bound_with_struct.rs:16:57
-   |
-LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String {
-   |                                                         ^^^^^^ not a trait
-   | 
-  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
-   |
-LL | pub trait ToString {
-   | ------------------ similarly named trait `ToString` defined here
-   |
-help: constrain the associated type to `String`
-   |
-LL | fn qux<'a, T: Bar>(_: &'a T) where &'a T: Bar<Baz = String> {
-   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^
-help: a trait with a similar name exists
-   |
-LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: ToString {
-   |                                                         ^^^^^^^^
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0404`.
diff --git a/src/test/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs b/src/test/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs
new file mode 100644 (file)
index 0000000..c66009f
--- /dev/null
@@ -0,0 +1,19 @@
+trait Bar {
+    type Baz;
+}
+
+struct Foo<T> where T: Bar, <T as Bar>::Baz: String { //~ ERROR expected trait, found struct
+    t: T,
+}
+
+struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String { //~ ERROR expected trait, found struct
+    t: &'a T,
+}
+
+fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String { //~ ERROR expected trait, found struct
+}
+
+fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String { //~ ERROR expected trait, found
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr b/src/test/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr
new file mode 100644 (file)
index 0000000..7cf872e
--- /dev/null
@@ -0,0 +1,83 @@
+error[E0404]: expected trait, found struct `String`
+  --> $DIR/assoc_type_bound_with_struct.rs:5:46
+   |
+LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: String {
+   |                                              ^^^^^^ not a trait
+   | 
+  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
+   |
+LL | pub trait ToString {
+   | ------------------ similarly named trait `ToString` defined here
+   |
+help: constrain the associated type to `String`
+   |
+LL | struct Foo<T> where T: Bar, T: Bar<Baz = String> {
+   |                             ^^^^^^^^^^^^^^^^^^^^
+help: a trait with a similar name exists
+   |
+LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: ToString {
+   |                                              ^^^^^^^^
+
+error[E0404]: expected trait, found struct `String`
+  --> $DIR/assoc_type_bound_with_struct.rs:9:54
+   |
+LL | struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String {
+   |                                                      ^^^^^^ not a trait
+   | 
+  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
+   |
+LL | pub trait ToString {
+   | ------------------ similarly named trait `ToString` defined here
+   |
+help: constrain the associated type to `String`
+   |
+LL | struct Qux<'a, T> where T: Bar, &'a T: Bar<Baz = String> {
+   |                                 ^^^^^^^^^^^^^^^^^^^^^^^^
+help: a trait with a similar name exists
+   |
+LL | struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: ToString {
+   |                                                      ^^^^^^^^
+
+error[E0404]: expected trait, found struct `String`
+  --> $DIR/assoc_type_bound_with_struct.rs:13:45
+   |
+LL | fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String {
+   |                                             ^^^^^^ not a trait
+   | 
+  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
+   |
+LL | pub trait ToString {
+   | ------------------ similarly named trait `ToString` defined here
+   |
+help: constrain the associated type to `String`
+   |
+LL | fn foo<T: Bar>(_: T) where T: Bar<Baz = String> {
+   |                            ^^^^^^^^^^^^^^^^^^^^
+help: a trait with a similar name exists
+   |
+LL | fn foo<T: Bar>(_: T) where <T as Bar>::Baz: ToString {
+   |                                             ^^^^^^^^
+
+error[E0404]: expected trait, found struct `String`
+  --> $DIR/assoc_type_bound_with_struct.rs:16:57
+   |
+LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String {
+   |                                                         ^^^^^^ not a trait
+   | 
+  ::: $SRC_DIR/alloc/src/string.rs:LL:COL
+   |
+LL | pub trait ToString {
+   | ------------------ similarly named trait `ToString` defined here
+   |
+help: constrain the associated type to `String`
+   |
+LL | fn qux<'a, T: Bar>(_: &'a T) where &'a T: Bar<Baz = String> {
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^
+help: a trait with a similar name exists
+   |
+LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: ToString {
+   |                                                         ^^^^^^^^
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.rs
new file mode 100644 (file)
index 0000000..b1f124c
--- /dev/null
@@ -0,0 +1,14 @@
+// Check that we validate associated type bounds for trait objects
+
+trait X {
+    type Y: Clone;
+}
+
+fn f<T: X + ?Sized>() {
+    None::<T::Y>.clone();
+}
+
+fn main() {
+    f::<dyn X<Y = str>>();
+    //~^ ERROR the trait bound `str: Clone` is not satisfied
+}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-1.stderr
new file mode 100644 (file)
index 0000000..170ed6e
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `str: Clone` is not satisfied
+  --> $DIR/check-trait-object-bounds-1.rs:12:5
+   |
+LL | fn f<T: X + ?Sized>() {
+   |         - required by this bound in `f`
+...
+LL |     f::<dyn X<Y = str>>();
+   |     ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2-ok.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2-ok.rs
new file mode 100644 (file)
index 0000000..1422dda
--- /dev/null
@@ -0,0 +1,15 @@
+// Make sure that we're handling bound lifetimes correctly when validating trait
+// bounds.
+// run-pass
+
+trait X<'a> {
+    type F: FnOnce(&i32) -> &'a i32;
+}
+
+fn f<T: for<'r> X<'r> + ?Sized>() {
+    None::<T::F>.map(|f| f(&0));
+}
+
+fn main() {
+    f::<dyn for<'x> X<'x, F = fn(&i32) -> &'x i32>>();
+}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2.rs
new file mode 100644 (file)
index 0000000..eb2fb6e
--- /dev/null
@@ -0,0 +1,15 @@
+// Check that we validate associated type bounds for trait objects when they
+// have bound lifetimes
+
+trait X<'a> {
+    type F: FnOnce(&i32) -> &'a i32;
+}
+
+fn f<T: for<'r> X<'r> + ?Sized>() {
+    None::<T::F>.map(|f| f(&0));
+}
+
+fn main() {
+    f::<dyn for<'x> X<'x, F = i32>>();
+    //~^ expected a `FnOnce<(&i32,)>` closure, found `i32`
+}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-2.stderr
new file mode 100644 (file)
index 0000000..04e2348
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0277]: expected a `FnOnce<(&i32,)>` closure, found `i32`
+  --> $DIR/check-trait-object-bounds-2.rs:13:5
+   |
+LL | fn f<T: for<'r> X<'r> + ?Sized>() {
+   |         ------------- required by this bound in `f`
+...
+LL |     f::<dyn for<'x> X<'x, F = i32>>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&i32,)>` closure, found `i32`
+   |
+   = help: the trait `for<'r> FnOnce<(&'r i32,)>` is not implemented for `i32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.rs
new file mode 100644 (file)
index 0000000..ba04fd9
--- /dev/null
@@ -0,0 +1,20 @@
+// Check that we validate associated type bounds for trait objects
+
+trait X<'a> {
+    type Y: Into<&'static str> + From<&'a str>;
+}
+
+fn f<'a, T: X<'a> + ?Sized>(s: &'a str) -> &'static str {
+    T::Y::from(s).into()
+}
+
+pub fn main() {
+    let z;
+    {
+        let s = String::from("abcdef");
+        z = f::<dyn X<Y = &str>>(&s);
+        //~^ ERROR `s` does not live long enough
+    }
+
+    println!("{}", z)
+}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-3.stderr
new file mode 100644 (file)
index 0000000..ade552c
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0597]: `s` does not live long enough
+  --> $DIR/check-trait-object-bounds-3.rs:15:34
+   |
+LL |         z = f::<dyn X<Y = &str>>(&s);
+   |             ---------------------^^-
+   |             |                    |
+   |             |                    borrowed value does not live long enough
+   |             argument requires that `s` is borrowed for `'static`
+LL |
+LL |     }
+   |     - `s` dropped here while still borrowed
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.rs
new file mode 100644 (file)
index 0000000..e9ca156
--- /dev/null
@@ -0,0 +1,17 @@
+// Check that we validate associated type bounds on super traits for trait
+// objects
+
+trait Super {
+    type Y: Clone;
+}
+
+trait X: Super {}
+
+fn f<T: X + ?Sized>() {
+    None::<T::Y>.clone();
+}
+
+fn main() {
+    f::<dyn X<Y = str>>();
+    //~^ ERROR the trait bound `str: Clone` is not satisfied
+}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-4.stderr
new file mode 100644 (file)
index 0000000..fc9f31c
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `str: Clone` is not satisfied
+  --> $DIR/check-trait-object-bounds-4.rs:15:5
+   |
+LL | fn f<T: X + ?Sized>() {
+   |         - required by this bound in `f`
+...
+LL |     f::<dyn X<Y = str>>();
+   |     ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.rs
new file mode 100644 (file)
index 0000000..7d733ad
--- /dev/null
@@ -0,0 +1,27 @@
+// Check that we validate associated type bounds on super traits for trait
+// objects
+
+trait Is {
+    type T;
+}
+
+impl<U> Is for U {
+    type T = U;
+}
+
+trait Super {
+    type V;
+}
+
+trait Obj: Super {
+    type U: Is<T = Self::V>;
+}
+
+fn is_obj<T: ?Sized + Obj>(_: &T) {}
+
+fn f(x: &dyn Obj<U = i32, V = i64>) {
+    is_obj(x)
+    //~^ type mismatch resolving `<i32 as Is>::T == i64`
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-5.stderr
new file mode 100644 (file)
index 0000000..bd2b789
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
+  --> $DIR/check-trait-object-bounds-5.rs:23:5
+   |
+LL | fn is_obj<T: ?Sized + Obj>(_: &T) {}
+   |                       --- required by this bound in `is_obj`
+...
+LL |     is_obj(x)
+   |     ^^^^^^ expected `i64`, found `i32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.rs b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.rs
new file mode 100644 (file)
index 0000000..cb196d6
--- /dev/null
@@ -0,0 +1,24 @@
+// Check that we validate associated type bounds on super traits for trait
+// objects
+
+trait Is {
+    type T;
+}
+
+impl<U> Is for U {
+    type T = U;
+}
+
+trait Obj {
+    type U: Is<T = Self::V>;
+    type V;
+}
+
+fn is_obj<T: ?Sized + Obj>(_: &T) {}
+
+fn f(x: &dyn Obj<U = i32, V = i64>) {
+    is_obj(x)
+    //~^ ERROR type mismatch resolving `<i32 as Is>::T == i64`
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr b/src/test/ui/traits/associated_type_bound/check-trait-object-bounds-6.stderr
new file mode 100644 (file)
index 0000000..ea1fdaf
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
+  --> $DIR/check-trait-object-bounds-6.rs:20:5
+   |
+LL | fn is_obj<T: ?Sized + Obj>(_: &T) {}
+   |                       --- required by this bound in `is_obj`
+...
+LL |     is_obj(x)
+   |     ^^^^^^ expected `i64`, found `i32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/traits/astconv-cycle-between-and-type.rs b/src/test/ui/traits/astconv-cycle-between-and-type.rs
new file mode 100644 (file)
index 0000000..cc8f9dc
--- /dev/null
@@ -0,0 +1,29 @@
+// run-pass
+// Test that we are able to successfully compile a setup where a trait
+// (`Trait1`) references a struct (`SomeType<u32>`) which in turn
+// carries a predicate that references the trait (`u32 : Trait1`,
+// substituted).
+
+// pretty-expanded FIXME #23616
+
+#![allow(dead_code)]
+
+trait Trait1 : Trait2<SomeType<u32>> {
+    fn dumb(&self) { }
+}
+
+trait Trait2<A> {
+    fn dumber(&self, _: A) { }
+}
+
+struct SomeType<A>
+    where A : Trait1
+{
+    a: A
+}
+
+impl Trait1 for u32 { }
+
+impl Trait2<SomeType<u32>> for u32 { }
+
+fn main() { }
diff --git a/src/test/ui/traits/astconv-cycle-between-trait-and-type.rs b/src/test/ui/traits/astconv-cycle-between-trait-and-type.rs
deleted file mode 100644 (file)
index cc8f9dc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// run-pass
-// Test that we are able to successfully compile a setup where a trait
-// (`Trait1`) references a struct (`SomeType<u32>`) which in turn
-// carries a predicate that references the trait (`u32 : Trait1`,
-// substituted).
-
-// pretty-expanded FIXME #23616
-
-#![allow(dead_code)]
-
-trait Trait1 : Trait2<SomeType<u32>> {
-    fn dumb(&self) { }
-}
-
-trait Trait2<A> {
-    fn dumber(&self, _: A) { }
-}
-
-struct SomeType<A>
-    where A : Trait1
-{
-    a: A
-}
-
-impl Trait1 for u32 { }
-
-impl Trait2<SomeType<u32>> for u32 { }
-
-fn main() { }
diff --git a/src/test/ui/traits/auxiliary/crate_a1.rs b/src/test/ui/traits/auxiliary/crate_a1.rs
deleted file mode 100644 (file)
index 6aa0102..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-pub trait Bar {}
-
-pub fn try_foo(x: impl Bar) {}
-
-pub struct ImplementsTraitForUsize<T> {
-    _marker: std::marker::PhantomData<T>,
-}
-
-impl Bar for ImplementsTraitForUsize<usize> {}
diff --git a/src/test/ui/traits/auxiliary/crate_a2.rs b/src/test/ui/traits/auxiliary/crate_a2.rs
deleted file mode 100644 (file)
index d6057db..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-pub struct Foo;
-
-pub trait Bar {}
-
-impl Bar for Foo {}
-
-pub struct DoesNotImplementTrait;
-
-pub struct ImplementsWrongTraitConditionally<T> {
-    _marker: std::marker::PhantomData<T>,
-}
-
-impl Bar for ImplementsWrongTraitConditionally<isize> {}
diff --git a/src/test/ui/traits/auxiliary/trait_alias.rs b/src/test/ui/traits/auxiliary/trait_alias.rs
deleted file mode 100644 (file)
index 9e41221..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#![feature(trait_alias)]
-
-pub trait Hello {
-    fn hello(&self);
-}
-
-pub struct Hi;
-
-impl Hello for Hi {
-    fn hello(&self) {}
-}
-
-pub trait Greet = Hello;
diff --git a/src/test/ui/traits/auxiliary/trait_bounds_on_structs_and_enums_xc.rs b/src/test/ui/traits/auxiliary/trait_bounds_on_structs_and_enums_xc.rs
deleted file mode 100644 (file)
index 7e9592e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-pub trait Trait {
-    fn dummy(&self) { }
-}
-
-pub struct Foo<T:Trait> {
-    pub x: T,
-}
-
-pub enum Bar<T:Trait> {
-    ABar(isize),
-    BBar(T),
-    CBar(usize),
-}
diff --git a/src/test/ui/traits/auxiliary/trait_default_method_xc_aux.rs b/src/test/ui/traits/auxiliary/trait_default_method_xc_aux.rs
deleted file mode 100644 (file)
index 0fb26af..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-pub struct Something { pub x: isize }
-
-pub trait A {
-    fn f(&self) -> isize;
-    fn g(&self) -> isize { 10 }
-    fn h(&self) -> isize { 11 }
-    fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() }
-}
-
-
-impl A for isize {
-    fn f(&self) -> isize { 10 }
-}
-
-impl A for Something {
-    fn f(&self) -> isize { 10 }
-}
-
-pub trait B<T> {
-    fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
-    fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) }
-}
-
-impl<T> B<T> for isize { }
-impl B<f64> for bool { }
-
-
-
-pub trait TestEquality {
-    fn test_eq(&self, rhs: &Self) -> bool;
-    fn test_neq(&self, rhs: &Self) -> bool {
-        !self.test_eq(rhs)
-    }
-}
-
-impl TestEquality for isize {
-    fn test_eq(&self, rhs: &isize) -> bool {
-        *self == *rhs
-    }
-}
diff --git a/src/test/ui/traits/auxiliary/trait_default_method_xc_aux_2.rs b/src/test/ui/traits/auxiliary/trait_default_method_xc_aux_2.rs
deleted file mode 100644 (file)
index 1548013..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// aux-build:trait_default_method_xc_aux.rs
-
-extern crate trait_default_method_xc_aux as aux;
-use aux::A;
-
-pub struct a_struct { pub x: isize }
-
-impl A for a_struct {
-    fn f(&self) -> isize { 10 }
-}
-
-// This function will need to get inlined, and badness may result.
-pub fn welp<A>(x: A) -> A {
-    let a = a_struct { x: 0 };
-    a.g();
-    x
-}
diff --git a/src/test/ui/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs b/src/test/ui/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs
deleted file mode 100644 (file)
index e932767..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-pub trait Foo { fn f(&self) -> isize; }
-pub trait Bar { fn g(&self) -> isize; }
-pub trait Baz { fn h(&self) -> isize; }
-
-pub struct A { pub x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-impl Baz for A { fn h(&self) -> isize { 30 } }
diff --git a/src/test/ui/traits/auxiliary/trait_inheritance_auto_xc_aux.rs b/src/test/ui/traits/auxiliary/trait_inheritance_auto_xc_aux.rs
deleted file mode 100644 (file)
index 9af26cb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-pub trait Foo { fn f(&self) -> isize; }
-pub trait Bar { fn g(&self) -> isize; }
-pub trait Baz { fn h(&self) -> isize; }
-
-pub trait Quux: Foo + Bar + Baz { }
-
-impl<T:Foo + Bar + Baz> Quux for T { }
diff --git a/src/test/ui/traits/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/ui/traits/auxiliary/trait_inheritance_overloading_xc.rs
deleted file mode 100644 (file)
index a257044..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-use std::cmp::PartialEq;
-use std::ops::{Add, Sub, Mul};
-
-pub trait MyNum : Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + PartialEq + Clone {
-}
-
-#[derive(Clone, Debug)]
-pub struct MyInt {
-    pub val: isize
-}
-
-impl Add for MyInt {
-    type Output = MyInt;
-
-    fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
-}
-
-impl Sub for MyInt {
-    type Output = MyInt;
-
-    fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
-}
-
-impl Mul for MyInt {
-    type Output = MyInt;
-
-    fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
-}
-
-impl PartialEq for MyInt {
-    fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
-
-    fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
-}
-
-impl MyNum for MyInt {}
-
-fn mi(v: isize) -> MyInt { MyInt { val: v } }
diff --git a/src/test/ui/traits/auxiliary/trait_xc_call_aux.rs b/src/test/ui/traits/auxiliary/trait_xc_call_aux.rs
deleted file mode 100644 (file)
index b76c52e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-pub trait Foo {
-    fn f(&self) -> isize;
-}
-
-pub struct A {
-    pub x: isize
-}
-
-impl Foo for A {
-    fn f(&self) -> isize { 10 }
-}
diff --git a/src/test/ui/traits/bound/auxiliary/crate_a1.rs b/src/test/ui/traits/bound/auxiliary/crate_a1.rs
new file mode 100644 (file)
index 0000000..6aa0102
--- /dev/null
@@ -0,0 +1,9 @@
+pub trait Bar {}
+
+pub fn try_foo(x: impl Bar) {}
+
+pub struct ImplementsTraitForUsize<T> {
+    _marker: std::marker::PhantomData<T>,
+}
+
+impl Bar for ImplementsTraitForUsize<usize> {}
diff --git a/src/test/ui/traits/bound/auxiliary/crate_a2.rs b/src/test/ui/traits/bound/auxiliary/crate_a2.rs
new file mode 100644 (file)
index 0000000..d6057db
--- /dev/null
@@ -0,0 +1,13 @@
+pub struct Foo;
+
+pub trait Bar {}
+
+impl Bar for Foo {}
+
+pub struct DoesNotImplementTrait;
+
+pub struct ImplementsWrongTraitConditionally<T> {
+    _marker: std::marker::PhantomData<T>,
+}
+
+impl Bar for ImplementsWrongTraitConditionally<isize> {}
diff --git a/src/test/ui/traits/bound/auxiliary/on_structs_and_enums_xc.rs b/src/test/ui/traits/bound/auxiliary/on_structs_and_enums_xc.rs
new file mode 100644 (file)
index 0000000..7e9592e
--- /dev/null
@@ -0,0 +1,13 @@
+pub trait Trait {
+    fn dummy(&self) { }
+}
+
+pub struct Foo<T:Trait> {
+    pub x: T,
+}
+
+pub enum Bar<T:Trait> {
+    ABar(isize),
+    BBar(T),
+    CBar(usize),
+}
diff --git a/src/test/ui/traits/bound/basic.rs b/src/test/ui/traits/bound/basic.rs
new file mode 100644 (file)
index 0000000..8c8a7eb
--- /dev/null
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unconditional_recursion)]
+
+// pretty-expanded FIXME #23616
+
+trait Foo {
+}
+
+fn b(_x: Box<dyn Foo+Send>) {
+}
+
+fn c(x: Box<dyn Foo+Sync+Send>) {
+    e(x);
+}
+
+fn d(x: Box<dyn Foo+Send>) {
+    e(x);
+}
+
+fn e(x: Box<dyn Foo>) {
+    e(x);
+}
+
+pub fn main() { }
diff --git a/src/test/ui/traits/bound/generic_trait.rs b/src/test/ui/traits/bound/generic_trait.rs
new file mode 100644 (file)
index 0000000..18382bb
--- /dev/null
@@ -0,0 +1,30 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+
+trait connection {
+    fn read(&self) -> isize;
+}
+
+trait connection_factory<C:connection> {
+    fn create(&self) -> C;
+}
+
+type my_connection = ();
+type my_connection_factory = ();
+
+impl connection for () {
+    fn read(&self) -> isize { 43 }
+}
+
+impl connection_factory<my_connection> for my_connection_factory {
+    fn create(&self) -> my_connection { () }
+}
+
+pub fn main() {
+    let factory = ();
+    let connection = factory.create();
+    let result = connection.read();
+    assert_eq!(result, 43);
+}
diff --git a/src/test/ui/traits/bound/impl-comparison-duplicates.rs b/src/test/ui/traits/bound/impl-comparison-duplicates.rs
new file mode 100644 (file)
index 0000000..de6c2af
--- /dev/null
@@ -0,0 +1,16 @@
+// run-pass
+// Tests that type parameter bounds on an implementation need not match the
+// trait exactly, as long as the implementation doesn't demand *more* bounds
+// than the trait.
+
+// pretty-expanded FIXME #23616
+
+trait A {
+    fn foo<T: Eq + Ord>(&self);
+}
+
+impl A for isize {
+    fn foo<T: Ord>(&self) {} // Ord implies Eq, so this is ok.
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/bound/in-arc.rs b/src/test/ui/traits/bound/in-arc.rs
new file mode 100644 (file)
index 0000000..941f66c
--- /dev/null
@@ -0,0 +1,109 @@
+// run-pass
+#![allow(unused_must_use)]
+// Tests that a heterogeneous list of existential `dyn` types can be put inside an Arc
+// and shared between threads as long as all types fulfill Send.
+
+// ignore-emscripten no threads support
+
+#![feature(box_syntax)]
+
+use std::sync::Arc;
+use std::sync::mpsc::channel;
+use std::thread;
+
+trait Pet {
+    fn name(&self, blk: Box<dyn FnMut(&str)>);
+    fn num_legs(&self) -> usize;
+    fn of_good_pedigree(&self) -> bool;
+}
+
+struct Catte {
+    num_whiskers: usize,
+    name: String,
+}
+
+struct Dogge {
+    bark_decibels: usize,
+    tricks_known: usize,
+    name: String,
+}
+
+struct Goldfyshe {
+    swim_speed: usize,
+    name: String,
+}
+
+impl Pet for Catte {
+    fn name(&self, mut blk: Box<dyn FnMut(&str)>) { blk(&self.name) }
+    fn num_legs(&self) -> usize { 4 }
+    fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 }
+}
+impl Pet for Dogge {
+    fn name(&self, mut blk: Box<dyn FnMut(&str)>) { blk(&self.name) }
+    fn num_legs(&self) -> usize { 4 }
+    fn of_good_pedigree(&self) -> bool {
+        self.bark_decibels < 70 || self.tricks_known > 20
+    }
+}
+impl Pet for Goldfyshe {
+    fn name(&self, mut blk: Box<dyn FnMut(&str)>) { blk(&self.name) }
+    fn num_legs(&self) -> usize { 0 }
+    fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
+}
+
+pub fn main() {
+    let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_string() };
+    let dogge1 = Dogge {
+        bark_decibels: 100,
+        tricks_known: 42,
+        name: "alan_turing".to_string(),
+    };
+    let dogge2 = Dogge {
+        bark_decibels: 55,
+        tricks_known: 11,
+        name: "albert_einstein".to_string(),
+    };
+    let fishe = Goldfyshe {
+        swim_speed: 998,
+        name: "alec_guinness".to_string(),
+    };
+    let arc = Arc::new(vec![box catte  as Box<dyn Pet+Sync+Send>,
+                            box dogge1 as Box<dyn Pet+Sync+Send>,
+                            box fishe  as Box<dyn Pet+Sync+Send>,
+                            box dogge2 as Box<dyn Pet+Sync+Send>]);
+    let (tx1, rx1) = channel();
+    let arc1 = arc.clone();
+    let t1 = thread::spawn(move|| { check_legs(arc1); tx1.send(()); });
+    let (tx2, rx2) = channel();
+    let arc2 = arc.clone();
+    let t2 = thread::spawn(move|| { check_names(arc2); tx2.send(()); });
+    let (tx3, rx3) = channel();
+    let arc3 = arc.clone();
+    let t3 = thread::spawn(move|| { check_pedigree(arc3); tx3.send(()); });
+    rx1.recv();
+    rx2.recv();
+    rx3.recv();
+    t1.join();
+    t2.join();
+    t3.join();
+}
+
+fn check_legs(arc: Arc<Vec<Box<dyn Pet+Sync+Send>>>) {
+    let mut legs = 0;
+    for pet in arc.iter() {
+        legs += pet.num_legs();
+    }
+    assert!(legs == 12);
+}
+fn check_names(arc: Arc<Vec<Box<dyn Pet+Sync+Send>>>) {
+    for pet in arc.iter() {
+        pet.name(Box::new(|name| {
+            assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8);
+        }))
+    }
+}
+fn check_pedigree(arc: Arc<Vec<Box<dyn Pet+Sync+Send>>>) {
+    for pet in arc.iter() {
+        assert!(pet.of_good_pedigree());
+    }
+}
diff --git a/src/test/ui/traits/bound/multiple.rs b/src/test/ui/traits/bound/multiple.rs
new file mode 100644 (file)
index 0000000..868b334
--- /dev/null
@@ -0,0 +1,9 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+fn f<T:PartialEq + PartialOrd>(_: T) {
+}
+
+pub fn main() {
+    f(3);
+}
diff --git a/src/test/ui/traits/bound/not-on-bare-trait.rs b/src/test/ui/traits/bound/not-on-bare-trait.rs
new file mode 100644 (file)
index 0000000..33c9f2f
--- /dev/null
@@ -0,0 +1,12 @@
+trait Foo {
+    fn dummy(&self) { }
+}
+
+// This should emit the less confusing error, not the more confusing one.
+
+fn foo(_x: Foo + Send) {
+    //~^ ERROR the size for values of type
+    //~| WARN trait objects without an explicit `dyn` are deprecated
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/bound/not-on-bare-trait.stderr b/src/test/ui/traits/bound/not-on-bare-trait.stderr
new file mode 100644 (file)
index 0000000..e7fc0fa
--- /dev/null
@@ -0,0 +1,24 @@
+warning: trait objects without an explicit `dyn` are deprecated
+  --> $DIR/not-on-bare-trait.rs:7:12
+   |
+LL | fn foo(_x: Foo + Send) {
+   |            ^^^^^^^^^^ help: use `dyn`: `dyn Foo + Send`
+   |
+   = note: `#[warn(bare_trait_objects)]` on by default
+
+error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time
+  --> $DIR/not-on-bare-trait.rs:7:8
+   |
+LL | fn foo(_x: Foo + Send) {
+   |        ^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `(dyn Foo + Send + 'static)`
+   = help: unsized fn params are gated as an unstable feature
+help: function arguments must have a statically known size, borrowed types always have a known size
+   |
+LL | fn foo(&_x: Foo + Send) {
+   |        ^
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/not-on-struct.rs b/src/test/ui/traits/bound/not-on-struct.rs
new file mode 100644 (file)
index 0000000..8633e9d
--- /dev/null
@@ -0,0 +1,38 @@
+// We don't need those errors. Ideally we would silence them, but to do so we need to move the
+// lint from being an early-lint during parsing to a late-lint, because it needs to be aware of
+// the types involved.
+#![allow(bare_trait_objects)]
+
+struct Foo;
+
+fn foo(_x: Box<Foo + Send>) { } //~ ERROR expected trait, found struct `Foo`
+
+type TypeAlias<T> = Box<dyn Vec<T>>; //~ ERROR expected trait, found struct `Vec`
+
+struct A;
+fn a() -> A + 'static { //~ ERROR expected trait, found
+    A
+}
+fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) { //~ ERROR expected trait, found
+    panic!()
+}
+fn c() -> 'static + A { //~ ERROR expected trait, found
+    A
+}
+fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) { //~ ERROR expected trait, found
+    panic!()
+}
+fn e() -> 'static + A + 'static { //~ ERROR expected trait, found
+//~^ ERROR only a single explicit lifetime bound is permitted
+    A
+}
+fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) { //~ ERROR expected trait, found
+//~^ ERROR only a single explicit lifetime bound is permitted
+    panic!()
+}
+struct Traitor;
+trait Trait {}
+fn g() -> Traitor + 'static { //~ ERROR expected trait, found struct `Traitor`
+    A
+}
+fn main() {}
diff --git a/src/test/ui/traits/bound/not-on-struct.stderr b/src/test/ui/traits/bound/not-on-struct.stderr
new file mode 100644 (file)
index 0000000..951e974
--- /dev/null
@@ -0,0 +1,168 @@
+error[E0226]: only a single explicit lifetime bound is permitted
+  --> $DIR/not-on-struct.rs:25:25
+   |
+LL | fn e() -> 'static + A + 'static {
+   |                         ^^^^^^^
+
+error[E0226]: only a single explicit lifetime bound is permitted
+  --> $DIR/not-on-struct.rs:29:53
+   |
+LL | fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) {
+   |                                                     ^^
+
+error[E0404]: expected trait, found struct `Foo`
+  --> $DIR/not-on-struct.rs:8:16
+   |
+LL | fn foo(_x: Box<Foo + Send>) { }
+   |                ^^^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:8:22
+   |
+LL | fn foo(_x: Box<Foo + Send>) { }
+   |                ---   ^^^^ ...because of this bound
+   |                |
+   |                expected this type to be a trait...
+
+error[E0404]: expected trait, found struct `Vec`
+  --> $DIR/not-on-struct.rs:10:29
+   |
+LL | type TypeAlias<T> = Box<dyn Vec<T>>;
+   |                             ^^^^^^ not a trait
+
+error[E0404]: expected trait, found struct `A`
+  --> $DIR/not-on-struct.rs:13:11
+   |
+LL | fn a() -> A + 'static {
+   |           ^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:13:15
+   |
+LL | fn a() -> A + 'static {
+   |           -   ^^^^^^^ ...because of this bound
+   |           |
+   |           expected this type to be a trait...
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn a() -> A {
+   |           --
+
+error[E0404]: expected trait, found enum `Result`
+  --> $DIR/not-on-struct.rs:16:34
+   |
+LL | fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) {
+   |                                  ^^^^^^^^^^^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:16:48
+   |
+LL | fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) {
+   |                                  -----------   ^^ ...because of this bound
+   |                                  |
+   |                                  expected this type to be a trait...
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn b<'a,T,E>(iter: Iterator<Item=Result<T,E>>) {
+   |                                            --
+
+error[E0404]: expected trait, found struct `A`
+  --> $DIR/not-on-struct.rs:19:21
+   |
+LL | fn c() -> 'static + A {
+   |                     ^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:19:11
+   |
+LL | fn c() -> 'static + A {
+   |           ^^^^^^^   - expected this type to be a trait...
+   |           |
+   |           ...because of this bound
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn c() -> A {
+   |          --
+
+error[E0404]: expected trait, found enum `Result`
+  --> $DIR/not-on-struct.rs:22:39
+   |
+LL | fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) {
+   |                                       ^^^^^^^^^^^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:22:34
+   |
+LL | fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) {
+   |                                  ^^   ----------- expected this type to be a trait...
+   |                                  |
+   |                                  ...because of this bound
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn d<'a,T,E>(iter: Iterator<Item=Result<T,E>>) {
+   |                                 --
+
+error[E0404]: expected trait, found struct `A`
+  --> $DIR/not-on-struct.rs:25:21
+   |
+LL | fn e() -> 'static + A + 'static {
+   |                     ^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:25:11
+   |
+LL | fn e() -> 'static + A + 'static {
+   |           ^^^^^^^   -   ^^^^^^^ ...because of these bounds
+   |                     |
+   |                     expected this type to be a trait...
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn e() -> A {
+   |          ---
+
+error[E0404]: expected trait, found enum `Result`
+  --> $DIR/not-on-struct.rs:29:39
+   |
+LL | fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) {
+   |                                       ^^^^^^^^^^^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:29:34
+   |
+LL | fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) {
+   |                                  ^^   -----------   ^^ ...because of these bounds
+   |                                       |
+   |                                       expected this type to be a trait...
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn f<'a,T,E>(iter: Iterator<Item=Result<T,E>>) {
+   |                                 --         --
+
+error[E0404]: expected trait, found struct `Traitor`
+  --> $DIR/not-on-struct.rs:35:11
+   |
+LL | trait Trait {}
+   | ----------- similarly named trait `Trait` defined here
+LL | fn g() -> Traitor + 'static {
+   |           ^^^^^^^ not a trait
+   |
+help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
+  --> $DIR/not-on-struct.rs:35:21
+   |
+LL | fn g() -> Traitor + 'static {
+   |           -------   ^^^^^^^ ...because of this bound
+   |           |
+   |           expected this type to be a trait...
+help: if you meant to use a type and not a trait here, remove the bounds
+   |
+LL | fn g() -> Traitor {
+   |                 --
+help: a trait with a similar name exists
+   |
+LL | fn g() -> Trait + 'static {
+   |           ^^^^^
+
+error: aborting due to 11 previous errors
+
+Some errors have detailed explanations: E0226, E0404.
+For more information about an error, try `rustc --explain E0226`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-in-fns.rs b/src/test/ui/traits/bound/on-structs-and-enums-in-fns.rs
new file mode 100644 (file)
index 0000000..6a6fcf5
--- /dev/null
@@ -0,0 +1,20 @@
+trait Trait {}
+
+struct Foo<T:Trait> {
+    x: T,
+}
+
+enum Bar<T:Trait> {
+    ABar(isize),
+    BBar(T),
+    CBar(usize),
+}
+
+fn explode(x: Foo<u32>) {}
+//~^ ERROR E0277
+
+fn kaboom(y: Bar<f32>) {}
+//~^ ERROR E0277
+
+fn main() {
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-in-fns.stderr b/src/test/ui/traits/bound/on-structs-and-enums-in-fns.stderr
new file mode 100644 (file)
index 0000000..346b690
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0277]: the trait bound `u32: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-in-fns.rs:13:15
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL | fn explode(x: Foo<u32>) {}
+   |               ^^^^^^^^ the trait `Trait` is not implemented for `u32`
+
+error[E0277]: the trait bound `f32: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-in-fns.rs:16:14
+   |
+LL | enum Bar<T:Trait> {
+   |            ----- required by this bound in `Bar`
+...
+LL | fn kaboom(y: Bar<f32>) {}
+   |              ^^^^^^^^ the trait `Trait` is not implemented for `f32`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-in-impls.rs b/src/test/ui/traits/bound/on-structs-and-enums-in-impls.rs
new file mode 100644 (file)
index 0000000..d379499
--- /dev/null
@@ -0,0 +1,25 @@
+trait Trait {}
+
+struct Foo<T:Trait> {
+    x: T,
+}
+
+enum Bar<T:Trait> {
+    ABar(isize),
+    BBar(T),
+    CBar(usize),
+}
+
+trait PolyTrait<T>
+{
+    fn whatever(&self, t: T) {}
+}
+
+struct Struct;
+
+impl PolyTrait<Foo<u16>> for Struct {
+//~^ ERROR E0277
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-in-impls.stderr b/src/test/ui/traits/bound/on-structs-and-enums-in-impls.stderr
new file mode 100644 (file)
index 0000000..47bab6c
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `u16: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-in-impls.rs:20:6
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL | impl PolyTrait<Foo<u16>> for Struct {
+   |      ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u16`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-locals.rs b/src/test/ui/traits/bound/on-structs-and-enums-locals.rs
new file mode 100644 (file)
index 0000000..21c0ce8
--- /dev/null
@@ -0,0 +1,17 @@
+trait Trait {
+    fn dummy(&self) { }
+}
+
+struct Foo<T:Trait> {
+    x: T,
+}
+
+fn main() {
+    let foo = Foo {
+    //~^ ERROR E0277
+        x: 3
+    };
+
+    let baz: Foo<usize> = loop { };
+    //~^ ERROR E0277
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-locals.stderr b/src/test/ui/traits/bound/on-structs-and-enums-locals.stderr
new file mode 100644 (file)
index 0000000..967b732
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0277]: the trait bound `usize: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-locals.rs:15:14
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL |     let baz: Foo<usize> = loop { };
+   |              ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
+
+error[E0277]: the trait bound `{integer}: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-locals.rs:10:15
+   |
+LL | struct Foo<T:Trait> {
+   | ------------------- required by `Foo`
+...
+LL |     let foo = Foo {
+   |               ^^^ the trait `Trait` is not implemented for `{integer}`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-rpass.rs b/src/test/ui/traits/bound/on-structs-and-enums-rpass.rs
new file mode 100644 (file)
index 0000000..4dc4fec
--- /dev/null
@@ -0,0 +1,21 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_variables)]
+// pretty-expanded FIXME #23616
+
+trait U {}
+trait T<X: U> { fn get(self) -> X; }
+
+trait S2<Y: U> {
+    fn m(x: Box<dyn T<Y>+'static>) {}
+}
+
+struct St<X: U> {
+    f: Box<dyn T<X>+'static>,
+}
+
+impl<X: U> St<X> {
+    fn blah() {}
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-static.rs b/src/test/ui/traits/bound/on-structs-and-enums-static.rs
new file mode 100644 (file)
index 0000000..df3f8b8
--- /dev/null
@@ -0,0 +1,15 @@
+trait Trait {
+    fn dummy(&self) { }
+}
+
+struct Foo<T:Trait> {
+    x: T,
+}
+
+static X: Foo<usize> = Foo {
+//~^ ERROR E0277
+    x: 1,
+};
+
+fn main() {
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-static.stderr b/src/test/ui/traits/bound/on-structs-and-enums-static.stderr
new file mode 100644 (file)
index 0000000..2cf8a62
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `usize: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-static.rs:9:11
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL | static X: Foo<usize> = Foo {
+   |           ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-xc.rs b/src/test/ui/traits/bound/on-structs-and-enums-xc.rs
new file mode 100644 (file)
index 0000000..94316d2
--- /dev/null
@@ -0,0 +1,14 @@
+// aux-build:on_structs_and_enums_xc.rs
+
+extern crate on_structs_and_enums_xc;
+
+use on_structs_and_enums_xc::{Bar, Foo, Trait};
+
+fn explode(x: Foo<usize>) {}
+//~^ ERROR E0277
+
+fn kaboom(y: Bar<f32>) {}
+//~^ ERROR E0277
+
+fn main() {
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-xc.stderr b/src/test/ui/traits/bound/on-structs-and-enums-xc.stderr
new file mode 100644 (file)
index 0000000..0adb20d
--- /dev/null
@@ -0,0 +1,25 @@
+error[E0277]: the trait bound `usize: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-xc.rs:7:15
+   |
+LL | fn explode(x: Foo<usize>) {}
+   |               ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
+   | 
+  ::: $DIR/auxiliary/on_structs_and_enums_xc.rs:5:18
+   |
+LL | pub struct Foo<T:Trait> {
+   |                  ----- required by this bound in `Foo`
+
+error[E0277]: the trait bound `f32: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-xc.rs:10:14
+   |
+LL | fn kaboom(y: Bar<f32>) {}
+   |              ^^^^^^^^ the trait `Trait` is not implemented for `f32`
+   | 
+  ::: $DIR/auxiliary/on_structs_and_enums_xc.rs:9:16
+   |
+LL | pub enum Bar<T:Trait> {
+   |                ----- required by this bound in `Bar`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-xc1.rs b/src/test/ui/traits/bound/on-structs-and-enums-xc1.rs
new file mode 100644 (file)
index 0000000..8156868
--- /dev/null
@@ -0,0 +1,15 @@
+// aux-build:on_structs_and_enums_xc.rs
+
+extern crate on_structs_and_enums_xc;
+
+use on_structs_and_enums_xc::{Bar, Foo, Trait};
+
+fn main() {
+    let foo = Foo {
+    //~^ ERROR E0277
+        x: 3
+    };
+    let bar: Bar<f64> = return;
+    //~^ ERROR E0277
+    let _ = bar;
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums-xc1.stderr b/src/test/ui/traits/bound/on-structs-and-enums-xc1.stderr
new file mode 100644 (file)
index 0000000..08f0f20
--- /dev/null
@@ -0,0 +1,22 @@
+error[E0277]: the trait bound `f64: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-xc1.rs:12:14
+   |
+LL |     let bar: Bar<f64> = return;
+   |              ^^^^^^^^ the trait `Trait` is not implemented for `f64`
+   | 
+  ::: $DIR/auxiliary/on_structs_and_enums_xc.rs:9:16
+   |
+LL | pub enum Bar<T:Trait> {
+   |                ----- required by this bound in `Bar`
+
+error[E0277]: the trait bound `{integer}: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums-xc1.rs:8:15
+   |
+LL |     let foo = Foo {
+   |               ^^^ the trait `Trait` is not implemented for `{integer}`
+   |
+   = note: required by `Foo`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/on-structs-and-enums.rs b/src/test/ui/traits/bound/on-structs-and-enums.rs
new file mode 100644 (file)
index 0000000..024084f
--- /dev/null
@@ -0,0 +1,43 @@
+trait Trait {}
+
+struct Foo<T:Trait> {
+    x: T,
+}
+
+enum Bar<T:Trait> {
+    ABar(isize),
+    BBar(T),
+    CBar(usize),
+}
+
+impl<T> Foo<T> {
+//~^ ERROR `T: Trait` is not satisfied
+    fn uhoh() {}
+}
+
+struct Baz {
+    a: Foo<isize>, //~ ERROR E0277
+}
+
+enum Boo {
+    Quux(Bar<usize>), //~ ERROR E0277
+}
+
+struct Badness<U> {
+    b: Foo<U>, //~ ERROR E0277
+}
+
+enum MoreBadness<V> {
+    EvenMoreBadness(Bar<V>), //~ ERROR E0277
+}
+
+struct TupleLike(
+    Foo<i32>, //~ ERROR E0277
+);
+
+enum Enum {
+    DictionaryLike { field: Bar<u8> }, //~ ERROR E0277
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/bound/on-structs-and-enums.stderr b/src/test/ui/traits/bound/on-structs-and-enums.stderr
new file mode 100644 (file)
index 0000000..0c69e7b
--- /dev/null
@@ -0,0 +1,81 @@
+error[E0277]: the trait bound `T: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:13:9
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL | impl<T> Foo<T> {
+   |         ^^^^^^ the trait `Trait` is not implemented for `T`
+   |
+help: consider restricting type parameter `T`
+   |
+LL | impl<T: Trait> Foo<T> {
+   |       ^^^^^^^
+
+error[E0277]: the trait bound `isize: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:19:8
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL |     a: Foo<isize>,
+   |        ^^^^^^^^^^ the trait `Trait` is not implemented for `isize`
+
+error[E0277]: the trait bound `usize: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:23:10
+   |
+LL | enum Bar<T:Trait> {
+   |            ----- required by this bound in `Bar`
+...
+LL |     Quux(Bar<usize>),
+   |          ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
+
+error[E0277]: the trait bound `U: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:27:8
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL |     b: Foo<U>,
+   |        ^^^^^^ the trait `Trait` is not implemented for `U`
+   |
+help: consider restricting type parameter `U`
+   |
+LL | struct Badness<U: Trait> {
+   |                 ^^^^^^^
+
+error[E0277]: the trait bound `V: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:31:21
+   |
+LL | enum Bar<T:Trait> {
+   |            ----- required by this bound in `Bar`
+...
+LL |     EvenMoreBadness(Bar<V>),
+   |                     ^^^^^^ the trait `Trait` is not implemented for `V`
+   |
+help: consider restricting type parameter `V`
+   |
+LL | enum MoreBadness<V: Trait> {
+   |                   ^^^^^^^
+
+error[E0277]: the trait bound `i32: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:35:5
+   |
+LL | struct Foo<T:Trait> {
+   |              ----- required by this bound in `Foo`
+...
+LL |     Foo<i32>,
+   |     ^^^^^^^^ the trait `Trait` is not implemented for `i32`
+
+error[E0277]: the trait bound `u8: Trait` is not satisfied
+  --> $DIR/on-structs-and-enums.rs:39:29
+   |
+LL | enum Bar<T:Trait> {
+   |            ----- required by this bound in `Bar`
+...
+LL |     DictionaryLike { field: Bar<u8> },
+   |                             ^^^^^^^ the trait `Trait` is not implemented for `u8`
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/recursion.rs b/src/test/ui/traits/bound/recursion.rs
new file mode 100644 (file)
index 0000000..0023ff6
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+trait I { fn i(&self) -> Self; }
+
+trait A<T:I> {
+    fn id(x:T) -> T { x.i() }
+}
+
+trait J<T> { fn j(&self) -> T; }
+
+trait B<T:J<T>> {
+    fn id(x:T) -> T { x.j() }
+}
+
+trait C {
+    fn id<T:J<T>>(x:T) -> T { x.j() }
+}
+
+pub fn main() { }
diff --git a/src/test/ui/traits/bound/same-crate-name.rs b/src/test/ui/traits/bound/same-crate-name.rs
new file mode 100644 (file)
index 0000000..1012edb
--- /dev/null
@@ -0,0 +1,55 @@
+// aux-build:crate_a1.rs
+// aux-build:crate_a2.rs
+
+// Issue 22750
+// This tests the extra help message reported when a trait bound
+// is not met but the struct implements a trait with the same path.
+
+fn main() {
+    let foo = {
+        extern crate crate_a2 as a;
+        a::Foo
+    };
+
+    let implements_no_traits = {
+        extern crate crate_a2 as a;
+        a::DoesNotImplementTrait
+    };
+
+    let other_variant_implements_mismatched_trait = {
+        extern crate crate_a2 as a;
+        a::ImplementsWrongTraitConditionally { _marker: std::marker::PhantomData::<isize> }
+    };
+
+    let other_variant_implements_correct_trait = {
+        extern crate crate_a1 as a;
+        a::ImplementsTraitForUsize { _marker: std::marker::PhantomData::<isize> }
+    };
+
+    {
+        extern crate crate_a1 as a;
+        a::try_foo(foo);
+        //~^ ERROR E0277
+        //~| trait impl with same name found
+        //~| perhaps two different versions of crate `crate_a2`
+
+        // We don't want to see the "version mismatch" help message here
+        // because `implements_no_traits` has no impl for `Foo`
+        a::try_foo(implements_no_traits);
+        //~^ ERROR E0277
+
+        // We don't want to see the "version mismatch" help message here
+        // because `other_variant_implements_mismatched_trait`
+        // does not have an impl for its `<isize>` variant,
+        // only for its `<usize>` variant.
+        a::try_foo(other_variant_implements_mismatched_trait);
+        //~^ ERROR E0277
+
+        // We don't want to see the "version mismatch" help message here
+        // because `ImplementsTraitForUsize` only has
+        // impls for the correct trait where the path is not misleading.
+        a::try_foo(other_variant_implements_correct_trait);
+        //~^ ERROR E0277
+        //~| the following implementations were found:
+    }
+}
diff --git a/src/test/ui/traits/bound/same-crate-name.stderr b/src/test/ui/traits/bound/same-crate-name.stderr
new file mode 100644 (file)
index 0000000..c48f2f0
--- /dev/null
@@ -0,0 +1,64 @@
+error[E0277]: the trait bound `Foo: main::a::Bar` is not satisfied
+  --> $DIR/same-crate-name.rs:31:20
+   |
+LL |         a::try_foo(foo);
+   |                    ^^^ the trait `main::a::Bar` is not implemented for `Foo`
+   | 
+  ::: $DIR/auxiliary/crate_a1.rs:3:24
+   |
+LL | pub fn try_foo(x: impl Bar) {}
+   |                        --- required by this bound in `try_foo`
+   |
+help: trait impl with same name found
+  --> $DIR/auxiliary/crate_a2.rs:5:1
+   |
+LL | impl Bar for Foo {}
+   | ^^^^^^^^^^^^^^^^^^^
+   = note: perhaps two different versions of crate `crate_a2` are being used?
+
+error[E0277]: the trait bound `DoesNotImplementTrait: main::a::Bar` is not satisfied
+  --> $DIR/same-crate-name.rs:38:20
+   |
+LL |         a::try_foo(implements_no_traits);
+   |                    ^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `DoesNotImplementTrait`
+   | 
+  ::: $DIR/auxiliary/crate_a1.rs:3:24
+   |
+LL | pub fn try_foo(x: impl Bar) {}
+   |                        --- required by this bound in `try_foo`
+
+error[E0277]: the trait bound `ImplementsWrongTraitConditionally<isize>: main::a::Bar` is not satisfied
+  --> $DIR/same-crate-name.rs:45:20
+   |
+LL |         a::try_foo(other_variant_implements_mismatched_trait);
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsWrongTraitConditionally<isize>`
+   | 
+  ::: $DIR/auxiliary/crate_a1.rs:3:24
+   |
+LL | pub fn try_foo(x: impl Bar) {}
+   |                        --- required by this bound in `try_foo`
+   |
+help: trait impl with same name found
+  --> $DIR/auxiliary/crate_a2.rs:13:1
+   |
+LL | impl Bar for ImplementsWrongTraitConditionally<isize> {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: perhaps two different versions of crate `crate_a2` are being used?
+
+error[E0277]: the trait bound `ImplementsTraitForUsize<isize>: main::a::Bar` is not satisfied
+  --> $DIR/same-crate-name.rs:51:20
+   |
+LL |         a::try_foo(other_variant_implements_correct_trait);
+   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsTraitForUsize<isize>`
+   | 
+  ::: $DIR/auxiliary/crate_a1.rs:3:24
+   |
+LL | pub fn try_foo(x: impl Bar) {}
+   |                        --- required by this bound in `try_foo`
+   |
+   = help: the following implementations were found:
+             <ImplementsTraitForUsize<usize> as main::a::Bar>
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/bound/sugar.rs b/src/test/ui/traits/bound/sugar.rs
new file mode 100644 (file)
index 0000000..65b6f6f
--- /dev/null
@@ -0,0 +1,19 @@
+// Tests for "default" bounds inferred for traits with no bounds list.
+
+trait Foo {}
+
+fn a(_x: Box<dyn Foo + Send>) {
+}
+
+fn b(_x: &'static (dyn Foo + 'static)) {
+}
+
+fn c(x: Box<dyn Foo + Sync>) {
+    a(x); //~ ERROR mismatched types
+}
+
+fn d(x: &'static (dyn Foo + Sync)) {
+    b(x);
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/bound/sugar.stderr b/src/test/ui/traits/bound/sugar.stderr
new file mode 100644 (file)
index 0000000..feb0c73
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/sugar.rs:12:7
+   |
+LL |     a(x);
+   |       ^ expected trait `Foo + Send`, found trait `Foo + Sync`
+   |
+   = note: expected struct `Box<(dyn Foo + Send + 'static)>`
+              found struct `Box<(dyn Foo + Sync + 'static)>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/cache-issue-18209.rs b/src/test/ui/traits/cache-issue-18209.rs
new file mode 100644 (file)
index 0000000..15676e4
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+// Test that the cache results from the default method do not pollute
+// the cache for the later call in `load()`.
+//
+// See issue #18209.
+
+// pretty-expanded FIXME #23616
+
+pub trait Foo {
+    fn load_from() -> Box<Self>;
+    fn load() -> Box<Self> {
+        Foo::load_from()
+    }
+}
+
+pub fn load<M: Foo>() -> Box<M> {
+    Foo::load()
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/check-trait-object-bounds-1.rs b/src/test/ui/traits/check-trait-object-bounds-1.rs
deleted file mode 100644 (file)
index b1f124c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Check that we validate associated type bounds for trait objects
-
-trait X {
-    type Y: Clone;
-}
-
-fn f<T: X + ?Sized>() {
-    None::<T::Y>.clone();
-}
-
-fn main() {
-    f::<dyn X<Y = str>>();
-    //~^ ERROR the trait bound `str: Clone` is not satisfied
-}
diff --git a/src/test/ui/traits/check-trait-object-bounds-1.stderr b/src/test/ui/traits/check-trait-object-bounds-1.stderr
deleted file mode 100644 (file)
index 170ed6e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0277]: the trait bound `str: Clone` is not satisfied
-  --> $DIR/check-trait-object-bounds-1.rs:12:5
-   |
-LL | fn f<T: X + ?Sized>() {
-   |         - required by this bound in `f`
-...
-LL |     f::<dyn X<Y = str>>();
-   |     ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/check-trait-object-bounds-2-ok.rs b/src/test/ui/traits/check-trait-object-bounds-2-ok.rs
deleted file mode 100644 (file)
index 1422dda..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Make sure that we're handling bound lifetimes correctly when validating trait
-// bounds.
-// run-pass
-
-trait X<'a> {
-    type F: FnOnce(&i32) -> &'a i32;
-}
-
-fn f<T: for<'r> X<'r> + ?Sized>() {
-    None::<T::F>.map(|f| f(&0));
-}
-
-fn main() {
-    f::<dyn for<'x> X<'x, F = fn(&i32) -> &'x i32>>();
-}
diff --git a/src/test/ui/traits/check-trait-object-bounds-2.rs b/src/test/ui/traits/check-trait-object-bounds-2.rs
deleted file mode 100644 (file)
index eb2fb6e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Check that we validate associated type bounds for trait objects when they
-// have bound lifetimes
-
-trait X<'a> {
-    type F: FnOnce(&i32) -> &'a i32;
-}
-
-fn f<T: for<'r> X<'r> + ?Sized>() {
-    None::<T::F>.map(|f| f(&0));
-}
-
-fn main() {
-    f::<dyn for<'x> X<'x, F = i32>>();
-    //~^ expected a `FnOnce<(&i32,)>` closure, found `i32`
-}
diff --git a/src/test/ui/traits/check-trait-object-bounds-2.stderr b/src/test/ui/traits/check-trait-object-bounds-2.stderr
deleted file mode 100644 (file)
index 04e2348..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0277]: expected a `FnOnce<(&i32,)>` closure, found `i32`
-  --> $DIR/check-trait-object-bounds-2.rs:13:5
-   |
-LL | fn f<T: for<'r> X<'r> + ?Sized>() {
-   |         ------------- required by this bound in `f`
-...
-LL |     f::<dyn for<'x> X<'x, F = i32>>();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&i32,)>` closure, found `i32`
-   |
-   = help: the trait `for<'r> FnOnce<(&'r i32,)>` is not implemented for `i32`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/check-trait-object-bounds-3.rs b/src/test/ui/traits/check-trait-object-bounds-3.rs
deleted file mode 100644 (file)
index ba04fd9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Check that we validate associated type bounds for trait objects
-
-trait X<'a> {
-    type Y: Into<&'static str> + From<&'a str>;
-}
-
-fn f<'a, T: X<'a> + ?Sized>(s: &'a str) -> &'static str {
-    T::Y::from(s).into()
-}
-
-pub fn main() {
-    let z;
-    {
-        let s = String::from("abcdef");
-        z = f::<dyn X<Y = &str>>(&s);
-        //~^ ERROR `s` does not live long enough
-    }
-
-    println!("{}", z)
-}
diff --git a/src/test/ui/traits/check-trait-object-bounds-3.stderr b/src/test/ui/traits/check-trait-object-bounds-3.stderr
deleted file mode 100644 (file)
index ade552c..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0597]: `s` does not live long enough
-  --> $DIR/check-trait-object-bounds-3.rs:15:34
-   |
-LL |         z = f::<dyn X<Y = &str>>(&s);
-   |             ---------------------^^-
-   |             |                    |
-   |             |                    borrowed value does not live long enough
-   |             argument requires that `s` is borrowed for `'static`
-LL |
-LL |     }
-   |     - `s` dropped here while still borrowed
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/traits/check-trait-object-bounds-4.rs b/src/test/ui/traits/check-trait-object-bounds-4.rs
deleted file mode 100644 (file)
index e9ca156..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Check that we validate associated type bounds on super traits for trait
-// objects
-
-trait Super {
-    type Y: Clone;
-}
-
-trait X: Super {}
-
-fn f<T: X + ?Sized>() {
-    None::<T::Y>.clone();
-}
-
-fn main() {
-    f::<dyn X<Y = str>>();
-    //~^ ERROR the trait bound `str: Clone` is not satisfied
-}
diff --git a/src/test/ui/traits/check-trait-object-bounds-4.stderr b/src/test/ui/traits/check-trait-object-bounds-4.stderr
deleted file mode 100644 (file)
index fc9f31c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0277]: the trait bound `str: Clone` is not satisfied
-  --> $DIR/check-trait-object-bounds-4.rs:15:5
-   |
-LL | fn f<T: X + ?Sized>() {
-   |         - required by this bound in `f`
-...
-LL |     f::<dyn X<Y = str>>();
-   |     ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `str`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/check-trait-object-bounds-5.rs b/src/test/ui/traits/check-trait-object-bounds-5.rs
deleted file mode 100644 (file)
index 7d733ad..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// Check that we validate associated type bounds on super traits for trait
-// objects
-
-trait Is {
-    type T;
-}
-
-impl<U> Is for U {
-    type T = U;
-}
-
-trait Super {
-    type V;
-}
-
-trait Obj: Super {
-    type U: Is<T = Self::V>;
-}
-
-fn is_obj<T: ?Sized + Obj>(_: &T) {}
-
-fn f(x: &dyn Obj<U = i32, V = i64>) {
-    is_obj(x)
-    //~^ type mismatch resolving `<i32 as Is>::T == i64`
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/check-trait-object-bounds-5.stderr b/src/test/ui/traits/check-trait-object-bounds-5.stderr
deleted file mode 100644 (file)
index bd2b789..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
-  --> $DIR/check-trait-object-bounds-5.rs:23:5
-   |
-LL | fn is_obj<T: ?Sized + Obj>(_: &T) {}
-   |                       --- required by this bound in `is_obj`
-...
-LL |     is_obj(x)
-   |     ^^^^^^ expected `i64`, found `i32`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/traits/check-trait-object-bounds-6.rs b/src/test/ui/traits/check-trait-object-bounds-6.rs
deleted file mode 100644 (file)
index cb196d6..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Check that we validate associated type bounds on super traits for trait
-// objects
-
-trait Is {
-    type T;
-}
-
-impl<U> Is for U {
-    type T = U;
-}
-
-trait Obj {
-    type U: Is<T = Self::V>;
-    type V;
-}
-
-fn is_obj<T: ?Sized + Obj>(_: &T) {}
-
-fn f(x: &dyn Obj<U = i32, V = i64>) {
-    is_obj(x)
-    //~^ ERROR type mismatch resolving `<i32 as Is>::T == i64`
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/check-trait-object-bounds-6.stderr b/src/test/ui/traits/check-trait-object-bounds-6.stderr
deleted file mode 100644 (file)
index ea1fdaf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0271]: type mismatch resolving `<i32 as Is>::T == i64`
-  --> $DIR/check-trait-object-bounds-6.rs:20:5
-   |
-LL | fn is_obj<T: ?Sized + Obj>(_: &T) {}
-   |                       --- required by this bound in `is_obj`
-...
-LL |     is_obj(x)
-   |     ^^^^^^ expected `i64`, found `i32`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/traits/coercion-generic-bad.rs b/src/test/ui/traits/coercion-generic-bad.rs
new file mode 100644 (file)
index 0000000..2e115c7
--- /dev/null
@@ -0,0 +1,19 @@
+struct Struct {
+    person: &'static str
+}
+
+trait Trait<T> {
+    fn f(&self, x: T);
+}
+
+impl Trait<&'static str> for Struct {
+    fn f(&self, x: &'static str) {
+        println!("Hello, {}!", x);
+    }
+}
+
+fn main() {
+    let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
+    //~^ ERROR `Struct: Trait<isize>` is not satisfied
+    s.f(1);
+}
diff --git a/src/test/ui/traits/coercion-generic-bad.stderr b/src/test/ui/traits/coercion-generic-bad.stderr
new file mode 100644 (file)
index 0000000..f367d39
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0277]: the trait bound `Struct: Trait<isize>` is not satisfied
+  --> $DIR/coercion-generic-bad.rs:16:36
+   |
+LL |     let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<isize>` is not implemented for `Struct`
+   |
+   = help: the following implementations were found:
+             <Struct as Trait<&'static str>>
+   = note: required for the cast to the object type `dyn Trait<isize>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/coercion-generic-regions.rs b/src/test/ui/traits/coercion-generic-regions.rs
new file mode 100644 (file)
index 0000000..af478df
--- /dev/null
@@ -0,0 +1,19 @@
+struct Struct {
+    person: &'static str
+}
+
+trait Trait<T> {
+    fn f(&self, x: T);
+}
+
+impl Trait<&'static str> for Struct {
+    fn f(&self, x: &'static str) {
+        println!("Hello, {}!", x);
+    }
+}
+
+fn main() {
+    let person = "Fred".to_string();
+    let person: &str = &person;  //~ ERROR `person` does not live long enough
+    let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person });
+}
diff --git a/src/test/ui/traits/coercion-generic-regions.stderr b/src/test/ui/traits/coercion-generic-regions.stderr
new file mode 100644 (file)
index 0000000..5cfb649
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0597]: `person` does not live long enough
+  --> $DIR/coercion-generic-regions.rs:17:24
+   |
+LL |     let person: &str = &person;
+   |                        ^^^^^^^
+   |                        |
+   |                        borrowed value does not live long enough
+   |                        assignment requires that `person` is borrowed for `'static`
+LL |     let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person });
+LL | }
+   | - `person` dropped here while still borrowed
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/traits/coercion-generic.rs b/src/test/ui/traits/coercion-generic.rs
new file mode 100644 (file)
index 0000000..bf4dda4
--- /dev/null
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(dead_code)]
+trait Trait<T> {
+    fn f(&self, x: T);
+}
+
+#[derive(Copy, Clone)]
+struct Struct {
+    x: isize,
+    y: isize,
+}
+
+impl Trait<&'static str> for Struct {
+    fn f(&self, x: &'static str) {
+        println!("Hi, {}!", x);
+    }
+}
+
+pub fn main() {
+    let a = Struct { x: 1, y: 2 };
+    let b: Box<dyn Trait<&'static str>> = Box::new(a);
+    b.f("Mary");
+    let c: &dyn Trait<&'static str> = &a;
+    c.f("Joe");
+}
diff --git a/src/test/ui/traits/coercion.rs b/src/test/ui/traits/coercion.rs
new file mode 100644 (file)
index 0000000..cba33af
--- /dev/null
@@ -0,0 +1,36 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_mut)]
+#![allow(unused_variables)]
+#![feature(box_syntax)]
+
+use std::io::{self, Write};
+
+trait Trait {
+    fn f(&self);
+}
+
+#[derive(Copy, Clone)]
+struct Struct {
+    x: isize,
+    y: isize,
+}
+
+impl Trait for Struct {
+    fn f(&self) {
+        println!("Hi!");
+    }
+}
+
+fn foo(mut a: Box<dyn Write>) {}
+
+pub fn main() {
+    let a = Struct { x: 1, y: 2 };
+    let b: Box<dyn Trait> = Box::new(a);
+    b.f();
+    let c: &dyn Trait = &a;
+    c.f();
+
+    let out = io::stdout();
+    foo(Box::new(out));
+}
diff --git a/src/test/ui/traits/composition-trivial.rs b/src/test/ui/traits/composition-trivial.rs
new file mode 100644 (file)
index 0000000..90e5dcd
--- /dev/null
@@ -0,0 +1,12 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+trait Foo {
+    fn foo(&self);
+}
+
+trait Bar : Foo {
+    fn bar(&self);
+}
+
+pub fn main() {}
diff --git a/src/test/ui/traits/conditional-dispatch.rs b/src/test/ui/traits/conditional-dispatch.rs
new file mode 100644 (file)
index 0000000..a9c1944
--- /dev/null
@@ -0,0 +1,35 @@
+// run-pass
+// Test that we are able to resolve conditional dispatch.  Here, the
+// blanket impl for T:Copy coexists with an impl for Box<T>, because
+// Box does not impl Copy.
+
+#![feature(box_syntax)]
+
+trait Get {
+    fn get(&self) -> Self;
+}
+
+trait MyCopy { fn copy(&self) -> Self; }
+impl MyCopy for u16 { fn copy(&self) -> Self { *self } }
+impl MyCopy for u32 { fn copy(&self) -> Self { *self } }
+impl MyCopy for i32 { fn copy(&self) -> Self { *self } }
+impl<T:Copy> MyCopy for Option<T> { fn copy(&self) -> Self { *self } }
+
+impl<T:MyCopy> Get for T {
+    fn get(&self) -> T { self.copy() }
+}
+
+impl Get for Box<i32> {
+    fn get(&self) -> Box<i32> { box get_it(&**self) }
+}
+
+fn get_it<T:Get>(t: &T) -> T {
+    (*t).get()
+}
+
+fn main() {
+    assert_eq!(get_it(&1_u32), 1_u32);
+    assert_eq!(get_it(&1_u16), 1_u16);
+    assert_eq!(get_it(&Some(1_u16)), Some(1_u16));
+    assert_eq!(get_it(&Box::new(1)), Box::new(1));
+}
diff --git a/src/test/ui/traits/conditional-model-fn.rs b/src/test/ui/traits/conditional-model-fn.rs
new file mode 100644 (file)
index 0000000..ba88670
--- /dev/null
@@ -0,0 +1,53 @@
+// run-pass
+#![allow(unused_imports)]
+// A model for how the `Fn` traits could work. You can implement at
+// most one of `Go`, `GoMut`, or `GoOnce`, and then the others follow
+// automatically.
+
+// aux-build:go_trait.rs
+
+extern crate go_trait;
+
+use go_trait::{Go, GoMut, GoOnce, go, go_mut, go_once};
+
+use std::rc::Rc;
+use std::cell::Cell;
+
+struct SomeGoableThing {
+    counter: Rc<Cell<isize>>
+}
+
+impl Go for SomeGoableThing {
+    fn go(&self, arg: isize) {
+        self.counter.set(self.counter.get() + arg);
+    }
+}
+
+struct SomeGoOnceableThing {
+    counter: Rc<Cell<isize>>
+}
+
+impl GoOnce for SomeGoOnceableThing {
+    fn go_once(self, arg: isize) {
+        self.counter.set(self.counter.get() + arg);
+    }
+}
+
+fn main() {
+    let counter = Rc::new(Cell::new(0));
+    let mut x = SomeGoableThing { counter: counter.clone() };
+
+    go(&x, 10);
+    assert_eq!(counter.get(), 10);
+
+    go_mut(&mut x, 100);
+    assert_eq!(counter.get(), 110);
+
+    go_once(x, 1_000);
+    assert_eq!(counter.get(), 1_110);
+
+    let x = SomeGoOnceableThing { counter: counter.clone() };
+
+    go_once(x, 10_000);
+    assert_eq!(counter.get(), 11_110);
+}
diff --git a/src/test/ui/traits/copy-guessing.rs b/src/test/ui/traits/copy-guessing.rs
new file mode 100644 (file)
index 0000000..f031dd9
--- /dev/null
@@ -0,0 +1,38 @@
+// run-pass
+#![allow(dead_code)]
+// "guessing" in trait selection can affect `copy_or_move`. Check that this
+// is correctly handled. I am not sure what is the "correct" behaviour,
+// but we should at least not ICE.
+
+use std::mem;
+
+struct U([u8; 1337]);
+
+struct S<'a,T:'a>(&'a T);
+impl<'a, T> Clone for S<'a, T> { fn clone(&self) -> Self { S(self.0) } }
+/// This impl triggers inference "guessing" - S<_>: Copy => _ = U
+impl<'a> Copy for S<'a, Option<U>> {}
+
+fn assert_impls_fn<R,T: Fn()->R>(_: &T){}
+
+fn main() {
+    let n = None;
+    let e = S(&n);
+    let f = || {
+        // S being copy is critical for this to work
+        drop(e);
+        mem::size_of_val(e.0)
+    };
+    assert_impls_fn(&f);
+    assert_eq!(f(), 1337+1);
+
+    assert_eq!((|| {
+        // S being Copy is not critical here, but
+        // we check it anyway.
+        let n = None;
+        let e = S(&n);
+        let ret = mem::size_of_val(e.0);
+        drop(e);
+        ret
+    })(), 1337+1);
+}
diff --git a/src/test/ui/traits/cycle-trait-type-trait.rs b/src/test/ui/traits/cycle-trait-type-trait.rs
deleted file mode 100644 (file)
index c62d014..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// Test a case where a supertrait references a type that references
-// the original trait. This poses no problem at the moment.
-
-// pretty-expanded FIXME #23616
-
-trait Chromosome: Get<Struct<i32>> {
-}
-
-trait Get<A> {
-    fn get(&self) -> A;
-}
-
-struct Struct<C:Chromosome> { c: C }
-
-impl Chromosome for i32 { }
-
-impl Get<Struct<i32>> for i32 {
-    fn get(&self) -> Struct<i32> {
-        Struct { c: *self }
-    }
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/cycle-type-trait.rs b/src/test/ui/traits/cycle-type-trait.rs
new file mode 100644 (file)
index 0000000..c62d014
--- /dev/null
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(dead_code)]
+// Test a case where a supertrait references a type that references
+// the original trait. This poses no problem at the moment.
+
+// pretty-expanded FIXME #23616
+
+trait Chromosome: Get<Struct<i32>> {
+}
+
+trait Get<A> {
+    fn get(&self) -> A;
+}
+
+struct Struct<C:Chromosome> { c: C }
+
+impl Chromosome for i32 { }
+
+impl Get<Struct<i32>> for i32 {
+    fn get(&self) -> Struct<i32> {
+        Struct { c: *self }
+    }
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/default-method-supertrait-vtable.rs b/src/test/ui/traits/default-method-supertrait-vtable.rs
deleted file mode 100644 (file)
index 939ad51..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// run-pass
-
-
-// Tests that we can call a function bounded over a supertrait from
-// a default method
-
-fn require_y<T: Y>(x: T) -> isize { x.y() }
-
-trait Y {
-    fn y(self) -> isize;
-}
-
-
-trait Z: Y + Sized {
-    fn x(self) -> isize {
-        require_y(self)
-    }
-}
-
-impl Y for isize {
-    fn y(self) -> isize { self }
-}
-
-impl Z for isize {}
-
-pub fn main() {
-    assert_eq!(12.x(), 12);
-}
diff --git a/src/test/ui/traits/default-method/auxiliary/xc.rs b/src/test/ui/traits/default-method/auxiliary/xc.rs
new file mode 100644 (file)
index 0000000..0fb26af
--- /dev/null
@@ -0,0 +1,40 @@
+pub struct Something { pub x: isize }
+
+pub trait A {
+    fn f(&self) -> isize;
+    fn g(&self) -> isize { 10 }
+    fn h(&self) -> isize { 11 }
+    fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() }
+}
+
+
+impl A for isize {
+    fn f(&self) -> isize { 10 }
+}
+
+impl A for Something {
+    fn f(&self) -> isize { 10 }
+}
+
+pub trait B<T> {
+    fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
+    fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) }
+}
+
+impl<T> B<T> for isize { }
+impl B<f64> for bool { }
+
+
+
+pub trait TestEquality {
+    fn test_eq(&self, rhs: &Self) -> bool;
+    fn test_neq(&self, rhs: &Self) -> bool {
+        !self.test_eq(rhs)
+    }
+}
+
+impl TestEquality for isize {
+    fn test_eq(&self, rhs: &isize) -> bool {
+        *self == *rhs
+    }
+}
diff --git a/src/test/ui/traits/default-method/auxiliary/xc_2.rs b/src/test/ui/traits/default-method/auxiliary/xc_2.rs
new file mode 100644 (file)
index 0000000..9792338
--- /dev/null
@@ -0,0 +1,17 @@
+// aux-build:xc.rs
+
+extern crate xc as aux;
+use aux::A;
+
+pub struct a_struct { pub x: isize }
+
+impl A for a_struct {
+    fn f(&self) -> isize { 10 }
+}
+
+// This function will need to get inlined, and badness may result.
+pub fn welp<A>(x: A) -> A {
+    let a = a_struct { x: 0 };
+    a.g();
+    x
+}
diff --git a/src/test/ui/traits/default-method/bound-subst.rs b/src/test/ui/traits/default-method/bound-subst.rs
new file mode 100644 (file)
index 0000000..6a5d5c8
--- /dev/null
@@ -0,0 +1,18 @@
+// run-pass
+
+
+trait A<T> {
+    fn g<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
+}
+
+impl A<i32> for i32 { }
+impl<T> A<T> for u32 { }
+
+fn f<T, U, V: A<T>>(i: V, j: T, k: U) -> (T, U) {
+    i.g(j, k)
+}
+
+pub fn main () {
+    assert_eq!(f(0, 1, 2), (1, 2));
+    assert_eq!(f(0, 1, 2), (1, 2));
+}
diff --git a/src/test/ui/traits/default-method/bound-subst2.rs b/src/test/ui/traits/default-method/bound-subst2.rs
new file mode 100644 (file)
index 0000000..78eabba
--- /dev/null
@@ -0,0 +1,16 @@
+// run-pass
+
+
+trait A<T> {
+    fn g(&self, x: T) -> T { x }
+}
+
+impl A<isize> for isize { }
+
+fn f<T, V: A<T>>(i: V, j: T) -> T {
+    i.g(j)
+}
+
+pub fn main () {
+    assert_eq!(f(0, 2), 2);
+}
diff --git a/src/test/ui/traits/default-method/bound-subst3.rs b/src/test/ui/traits/default-method/bound-subst3.rs
new file mode 100644 (file)
index 0000000..dd39dec
--- /dev/null
@@ -0,0 +1,17 @@
+// run-pass
+
+
+trait A {
+    fn g<T>(&self, x: T, y: T) -> (T, T) { (x, y) }
+}
+
+impl A for isize { }
+
+fn f<T, V: A>(i: V, j: T, k: T) -> (T, T) {
+    i.g(j, k)
+}
+
+pub fn main () {
+    assert_eq!(f(0, 1, 2), (1, 2));
+    assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8));
+}
diff --git a/src/test/ui/traits/default-method/bound-subst4.rs b/src/test/ui/traits/default-method/bound-subst4.rs
new file mode 100644 (file)
index 0000000..ef13306
--- /dev/null
@@ -0,0 +1,19 @@
+// run-pass
+#![allow(unused_variables)]
+
+
+trait A<T> {
+    fn g(&self, x: usize) -> usize { x }
+    fn h(&self, x: T) { }
+}
+
+impl<T> A<T> for isize { }
+
+fn f<T, V: A<T>>(i: V, j: usize) -> usize {
+    i.g(j)
+}
+
+pub fn main () {
+    assert_eq!(f::<f64, isize>(0, 2), 2);
+    assert_eq!(f::<usize, isize>(0, 2), 2);
+}
diff --git a/src/test/ui/traits/default-method/bound.rs b/src/test/ui/traits/default-method/bound.rs
new file mode 100644 (file)
index 0000000..0855a9d
--- /dev/null
@@ -0,0 +1,16 @@
+// run-pass
+
+
+trait A {
+    fn g(&self) -> isize { 10 }
+}
+
+impl A for isize { }
+
+fn f<T:A>(i: T) {
+    assert_eq!(i.g(), 10);
+}
+
+pub fn main () {
+    f(0);
+}
diff --git a/src/test/ui/traits/default-method/macro.rs b/src/test/ui/traits/default-method/macro.rs
new file mode 100644 (file)
index 0000000..2b50ee9
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+
+
+trait Foo {
+    fn bar(&self) -> String {
+        format!("test")
+    }
+}
+
+enum Baz {
+    Quux
+}
+
+impl Foo for Baz {
+}
+
+pub fn main() {
+    let q = Baz::Quux;
+    assert_eq!(q.bar(), "test".to_string());
+}
diff --git a/src/test/ui/traits/default-method/mut.rs b/src/test/ui/traits/default-method/mut.rs
new file mode 100644 (file)
index 0000000..5f8e983
--- /dev/null
@@ -0,0 +1,11 @@
+// run-pass
+#![allow(unused_assignments)]
+// pretty-expanded FIXME #23616
+
+#![allow(unused_variables)]
+
+trait Foo {
+    fn foo(&self, mut v: isize) { v = 1; }
+}
+
+pub fn main() {}
diff --git a/src/test/ui/traits/default-method/self.rs b/src/test/ui/traits/default-method/self.rs
new file mode 100644 (file)
index 0000000..cdf4d1e
--- /dev/null
@@ -0,0 +1,18 @@
+// run-pass
+
+
+trait Cat {
+    fn meow(&self) -> bool;
+    fn scratch(&self) -> bool { self.purr() }
+    fn purr(&self) -> bool { true }
+}
+
+impl Cat for isize {
+    fn meow(&self) -> bool {
+        self.scratch()
+    }
+}
+
+pub fn main() {
+    assert!(5.meow());
+}
diff --git a/src/test/ui/traits/default-method/supervtable.rs b/src/test/ui/traits/default-method/supervtable.rs
new file mode 100644 (file)
index 0000000..939ad51
--- /dev/null
@@ -0,0 +1,28 @@
+// run-pass
+
+
+// Tests that we can call a function bounded over a supertrait from
+// a default method
+
+fn require_y<T: Y>(x: T) -> isize { x.y() }
+
+trait Y {
+    fn y(self) -> isize;
+}
+
+
+trait Z: Y + Sized {
+    fn x(self) -> isize {
+        require_y(self)
+    }
+}
+
+impl Y for isize {
+    fn y(self) -> isize { self }
+}
+
+impl Z for isize {}
+
+pub fn main() {
+    assert_eq!(12.x(), 12);
+}
diff --git a/src/test/ui/traits/default-method/trivial.rs b/src/test/ui/traits/default-method/trivial.rs
new file mode 100644 (file)
index 0000000..dc41938
--- /dev/null
@@ -0,0 +1,21 @@
+// run-pass
+
+
+trait Cat {
+    fn meow(&self) -> bool;
+    fn scratch(&self) -> bool;
+    fn purr(&self) -> bool { true }
+}
+
+impl Cat for isize {
+    fn meow(&self) -> bool {
+        self.scratch()
+    }
+    fn scratch(&self) -> bool {
+        self.purr()
+    }
+}
+
+pub fn main() {
+    assert!(5.meow());
+}
diff --git a/src/test/ui/traits/default-method/xc-2.rs b/src/test/ui/traits/default-method/xc-2.rs
new file mode 100644 (file)
index 0000000..1de61dc
--- /dev/null
@@ -0,0 +1,26 @@
+// run-pass
+// aux-build:xc.rs
+// aux-build:xc_2.rs
+
+
+
+extern crate xc as aux;
+extern crate xc_2 as aux2;
+use aux::A;
+use aux2::{a_struct, welp};
+
+
+pub fn main () {
+
+    let a = a_struct { x: 0 };
+    let b = a_struct { x: 1 };
+
+    assert_eq!(0.g(), 10);
+    assert_eq!(a.g(), 10);
+    assert_eq!(a.h(), 11);
+    assert_eq!(b.g(), 10);
+    assert_eq!(b.h(), 11);
+    assert_eq!(A::lurr(&a, &b), 21);
+
+    welp(&0);
+}
diff --git a/src/test/ui/traits/default-method/xc.rs b/src/test/ui/traits/default-method/xc.rs
new file mode 100644 (file)
index 0000000..76a1573
--- /dev/null
@@ -0,0 +1,81 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_camel_case_types)]
+
+// aux-build:xc.rs
+
+
+extern crate xc as aux;
+use aux::{A, TestEquality, Something};
+use aux::B;
+
+fn f<T: aux::A>(i: T) {
+    assert_eq!(i.g(), 10);
+}
+
+fn welp<T>(i: isize, _x: &T) -> isize {
+    i.g()
+}
+
+mod stuff {
+    pub struct thing { pub x: isize }
+}
+
+impl A for stuff::thing {
+    fn f(&self) -> isize { 10 }
+}
+
+fn g<T, U, V: B<T>>(i: V, j: T, k: U) -> (T, U) {
+    i.thing(j, k)
+}
+
+fn eq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
+    lhs.test_eq(rhs)
+}
+fn neq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
+    lhs.test_neq(rhs)
+}
+
+
+impl TestEquality for stuff::thing {
+    fn test_eq(&self, rhs: &stuff::thing) -> bool {
+        //self.x.test_eq(&rhs.x)
+        eq(&self.x, &rhs.x)
+    }
+}
+
+
+pub fn main() {
+    // Some tests of random things
+    f(0);
+
+    assert_eq!(A::lurr(&0, &1), 21);
+
+    let a = stuff::thing { x: 0 };
+    let b = stuff::thing { x: 1 };
+    let c = Something { x: 1 };
+
+    assert_eq!(0.g(), 10);
+    assert_eq!(a.g(), 10);
+    assert_eq!(a.h(), 11);
+    assert_eq!(c.h(), 11);
+
+    assert_eq!(0.thing(3.14f64, 1), (3.14f64, 1));
+    assert_eq!(B::staticthing(&0, 3.14f64, 1), (3.14f64, 1));
+    assert_eq!(B::<f64>::staticthing::<isize>(&0, 3.14, 1), (3.14, 1));
+
+    assert_eq!(g(0, 3.14f64, 1), (3.14f64, 1));
+    assert_eq!(g(false, 3.14f64, 1), (3.14, 1));
+
+
+    // Trying out a real one
+    assert!(12.test_neq(&10));
+    assert!(!10.test_neq(&10));
+    assert!(a.test_neq(&b));
+    assert!(!a.test_neq(&a));
+
+    assert!(neq(&12, &10));
+    assert!(!neq(&10, &10));
+    assert!(neq(&a, &b));
+    assert!(!neq(&a, &a));
+}
diff --git a/src/test/ui/traits/duplicate-methods.rs b/src/test/ui/traits/duplicate-methods.rs
new file mode 100644 (file)
index 0000000..1f9bdf5
--- /dev/null
@@ -0,0 +1,6 @@
+trait Foo {
+    fn orange(&self);
+    fn orange(&self); //~ ERROR the name `orange` is defined multiple times
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/duplicate-methods.stderr b/src/test/ui/traits/duplicate-methods.stderr
new file mode 100644 (file)
index 0000000..6aa88d0
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0428]: the name `orange` is defined multiple times
+  --> $DIR/duplicate-methods.rs:3:5
+   |
+LL |     fn orange(&self);
+   |     ----------------- previous definition of the value `orange` here
+LL |     fn orange(&self);
+   |     ^^^^^^^^^^^^^^^^^ `orange` redefined here
+   |
+   = note: `orange` must be defined only once in the value namespace of this trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0428`.
diff --git a/src/test/ui/traits/elaborate-type-region.rs b/src/test/ui/traits/elaborate-type-region.rs
new file mode 100644 (file)
index 0000000..03aef01
--- /dev/null
@@ -0,0 +1,49 @@
+// run-pass
+#![allow(dead_code)]
+
+// Test that we elaborate `Type: 'region` constraints and infer various important things.
+
+trait Master<'a, T: ?Sized> {
+    fn foo() where T: 'a;
+}
+
+// [U]: 'a => U: 'a
+impl<'a, U> Master<'a, [U]> for () {
+    fn foo() where U: 'a { }
+}
+
+// &'b U: 'a => 'b: 'a, U: 'a
+impl<'a, 'b, U> Master<'a, &'b U> for () {
+    fn foo() where 'b: 'a, U: 'a { }
+}
+
+// &'b [U]: 'a => 'b: 'a, U: 'a
+impl<'a, 'b, U> Master<'a, &'b [U]> for () {
+    fn foo() where 'b: 'a, U: 'a { }
+}
+
+// Foo<'b>: 'a => 'b: 'a
+struct Foo<'a> { x: &'a () }
+impl<'a, 'b> Master<'a, Foo<'b>> for () {
+    fn foo() where 'b: 'a { }
+}
+
+// Bar<'b, T>: 'a => 'b: 'a, T: 'a
+struct Bar<'a, T: 'a> { x: &'a T }
+impl<'a, 'b, T> Master<'a, Bar<'b, T>> for () {
+    fn foo() where 'b: 'a, T: 'a { }
+}
+
+// fn(T): 'a => T: 'a
+impl<'a, T> Master<'a, fn(T)> for () {
+    fn foo() where T: 'a { }
+}
+
+// fn() -> T: 'a => T: 'a
+impl<'a, T> Master<'a, fn() -> T> for () {
+    fn foo() where T: 'a { }
+}
+
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/src/test/ui/traits/false-ambiguity-where-clause-builtin-bound.rs b/src/test/ui/traits/false-ambiguity-where-clause-builtin-bound.rs
new file mode 100644 (file)
index 0000000..3413db6
--- /dev/null
@@ -0,0 +1,16 @@
+// run-pass
+// Test that we do not error out because of a (False) ambiguity
+// between the builtin rules for Sized and the where clause. Issue
+// #20959.
+
+// pretty-expanded FIXME #23616
+
+fn foo<K>(x: Option<K>)
+    where Option<K> : Sized
+{
+    let _y = x;
+}
+
+fn main() {
+    foo(Some(22));
+}
diff --git a/src/test/ui/traits/generic.rs b/src/test/ui/traits/generic.rs
new file mode 100644 (file)
index 0000000..80efe1c
--- /dev/null
@@ -0,0 +1,45 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+
+
+trait to_str {
+    fn to_string_(&self) -> String;
+}
+impl to_str for isize {
+    fn to_string_(&self) -> String { self.to_string() }
+}
+impl to_str for String {
+    fn to_string_(&self) -> String { self.clone() }
+}
+impl to_str for () {
+    fn to_string_(&self) -> String { "()".to_string() }
+}
+
+trait map<T> {
+    fn map<U, F>(&self, f: F) -> Vec<U> where F: FnMut(&T) -> U;
+}
+impl<T> map<T> for Vec<T> {
+    fn map<U, F>(&self, mut f: F) -> Vec<U> where F: FnMut(&T) -> U {
+        let mut r = Vec::new();
+        for i in self {
+            r.push(f(i));
+        }
+        r
+    }
+}
+
+fn foo<U, T: map<U>>(x: T) -> Vec<String> {
+    x.map(|_e| "hi".to_string() )
+}
+fn bar<U:to_str,T:map<U>>(x: T) -> Vec<String> {
+    x.map(|_e| _e.to_string_() )
+}
+
+pub fn main() {
+    assert_eq!(foo(vec![1]), ["hi".to_string()]);
+    assert_eq!(bar::<isize, Vec<isize> >(vec![4, 5]), ["4".to_string(), "5".to_string()]);
+    assert_eq!(bar::<String, Vec<String> >(vec!["x".to_string(), "y".to_string()]),
+               ["x".to_string(), "y".to_string()]);
+    assert_eq!(bar::<(), Vec<()>>(vec![()]), ["()".to_string()]);
+}
diff --git a/src/test/ui/traits/impl-1.rs b/src/test/ui/traits/impl-1.rs
new file mode 100644 (file)
index 0000000..d22ac72
--- /dev/null
@@ -0,0 +1,16 @@
+// Test calling methods on an impl for a bare trait. This test checks that the
+// trait impl is only applied to a trait object, not concrete types which implement
+// the trait.
+
+trait T {}
+
+impl<'a> dyn T + 'a {
+    fn foo(&self) {}
+}
+
+impl T for i32 {}
+
+fn main() {
+    let x = &42i32;
+    x.foo(); //~ERROR: no method named `foo` found
+}
diff --git a/src/test/ui/traits/impl-1.stderr b/src/test/ui/traits/impl-1.stderr
new file mode 100644 (file)
index 0000000..7694e3f
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0599]: no method named `foo` found for reference `&i32` in the current scope
+  --> $DIR/impl-1.rs:15:7
+   |
+LL |     x.foo();
+   |       ^^^ method not found in `&i32`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/traits/impl-2.rs b/src/test/ui/traits/impl-2.rs
new file mode 100644 (file)
index 0000000..804ffec
--- /dev/null
@@ -0,0 +1,19 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_snake_case)]
+
+// pretty-expanded FIXME #23616
+
+pub mod Foo {
+    pub trait Trait {
+        fn foo(&self);
+    }
+}
+
+mod Bar {
+    impl<'a> dyn (::Foo::Trait) + 'a {
+        fn bar(&self) { self.foo() }
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/impl-can-not-have-untraitful-items.rs b/src/test/ui/traits/impl-can-not-have-untraitful-items.rs
new file mode 100644 (file)
index 0000000..0c88544
--- /dev/null
@@ -0,0 +1,9 @@
+trait A { }
+
+impl A for isize {
+    const BAR: () = (); //~ ERROR const `BAR` is not a member of trait `A`
+    type Baz = (); //~ ERROR type `Baz` is not a member of trait `A`
+    fn foo(&self) { } //~ ERROR method `foo` is not a member of trait `A`
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/impl-can-not-have-untraitful-items.stderr b/src/test/ui/traits/impl-can-not-have-untraitful-items.stderr
new file mode 100644 (file)
index 0000000..7f56f34
--- /dev/null
@@ -0,0 +1,22 @@
+error[E0438]: const `BAR` is not a member of trait `A`
+  --> $DIR/impl-can-not-have-untraitful-items.rs:4:5
+   |
+LL |     const BAR: () = ();
+   |     ^^^^^^^^^^^^^^^^^^^ not a member of trait `A`
+
+error[E0437]: type `Baz` is not a member of trait `A`
+  --> $DIR/impl-can-not-have-untraitful-items.rs:5:5
+   |
+LL |     type Baz = ();
+   |     ^^^^^^^^^^^^^^ not a member of trait `A`
+
+error[E0407]: method `foo` is not a member of trait `A`
+  --> $DIR/impl-can-not-have-untraitful-items.rs:6:5
+   |
+LL |     fn foo(&self) { }
+   |     ^^^^^^^^^^^^^^^^^ not a member of trait `A`
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0407, E0437, E0438.
+For more information about an error, try `rustc --explain E0407`.
diff --git a/src/test/ui/traits/impl-different-num-params.rs b/src/test/ui/traits/impl-different-num-params.rs
new file mode 100644 (file)
index 0000000..5340062
--- /dev/null
@@ -0,0 +1,12 @@
+trait Foo {
+    fn bar(&self, x: usize) -> Self;
+}
+impl Foo for isize {
+    fn bar(&self) -> isize {
+        //~^ ERROR method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 2
+        *self
+    }
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/impl-different-num-params.stderr b/src/test/ui/traits/impl-different-num-params.stderr
new file mode 100644 (file)
index 0000000..910ba35
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0050]: method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 2
+  --> $DIR/impl-different-num-params.rs:5:12
+   |
+LL |     fn bar(&self, x: usize) -> Self;
+   |            --------------- trait requires 2 parameters
+...
+LL |     fn bar(&self) -> isize {
+   |            ^^^^^ expected 2 parameters, found 1
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0050`.
diff --git a/src/test/ui/traits/impl-for-module.rs b/src/test/ui/traits/impl-for-module.rs
new file mode 100644 (file)
index 0000000..9004627
--- /dev/null
@@ -0,0 +1,11 @@
+mod a {
+}
+
+trait A {
+}
+
+impl A for a { //~ ERROR expected type, found module
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/impl-for-module.stderr b/src/test/ui/traits/impl-for-module.stderr
new file mode 100644 (file)
index 0000000..6ec4083
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0573]: expected type, found module `a`
+  --> $DIR/impl-for-module.rs:7:12
+   |
+LL | trait A {
+   | ------- similarly named trait `A` defined here
+...
+LL | impl A for a {
+   |            ^ help: a trait with a similar name exists: `A`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0573`.
diff --git a/src/test/ui/traits/impl-method-mismatch.rs b/src/test/ui/traits/impl-method-mismatch.rs
new file mode 100644 (file)
index 0000000..683b1c1
--- /dev/null
@@ -0,0 +1,13 @@
+trait Mumbo {
+    fn jumbo(&self, x: &usize) -> usize;
+}
+
+impl Mumbo for usize {
+    // Cannot have a larger effect than the trait:
+    unsafe fn jumbo(&self, x: &usize) { *self + *x; }
+    //~^ ERROR method `jumbo` has an incompatible type for trait
+    //~| expected fn pointer `fn
+    //~| found fn pointer `unsafe fn
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/impl-method-mismatch.stderr b/src/test/ui/traits/impl-method-mismatch.stderr
new file mode 100644 (file)
index 0000000..c909446
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0053]: method `jumbo` has an incompatible type for trait
+  --> $DIR/impl-method-mismatch.rs:7:5
+   |
+LL |     fn jumbo(&self, x: &usize) -> usize;
+   |     ------------------------------------ type in trait
+...
+LL |     unsafe fn jumbo(&self, x: &usize) { *self + *x; }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn
+   |
+   = note: expected fn pointer `fn(&usize, &usize) -> usize`
+              found fn pointer `unsafe fn(&usize, &usize)`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0053`.
diff --git a/src/test/ui/traits/impl-object-overlap-issue-23853.rs b/src/test/ui/traits/impl-object-overlap-issue-23853.rs
new file mode 100644 (file)
index 0000000..e490967
--- /dev/null
@@ -0,0 +1,18 @@
+// run-pass
+// Test that we are able to compile the case where both a blanket impl
+// and the object type itself supply the required trait obligation.
+// In this case, the blanket impl for `Foo` applies to any type,
+// including `Bar`, but the object type `Bar` also implicitly supplies
+// this context.
+
+trait Foo { fn dummy(&self) { } }
+
+trait Bar: Foo { }
+
+impl<T:?Sized> Foo for T { }
+
+fn want_foo<B:?Sized+Foo>() { }
+
+fn main() {
+    want_foo::<dyn Bar>();
+}
diff --git a/src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.rs b/src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.rs
new file mode 100644 (file)
index 0000000..05b9db9
--- /dev/null
@@ -0,0 +1,31 @@
+// Check that when we test the supertrait we ensure consistent use of
+// lifetime parameters. In this case, implementing T2<'a,'b> requires
+// an impl of T1<'a>, but we have an impl of T1<'b>.
+
+trait T1<'x> {
+    fn x(&self) -> &'x isize;
+}
+
+trait T2<'x, 'y> : T1<'x> {
+    fn y(&self) -> &'y isize;
+}
+
+struct S<'a, 'b> {
+    a: &'a isize,
+    b: &'b isize
+}
+
+impl<'a,'b> T1<'b> for S<'a, 'b> {
+    fn x(&self) -> &'b isize {
+        self.b
+    }
+}
+
+impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime
+    fn y(&self) -> &'b isize {
+        self.b
+    }
+}
+
+pub fn main() {
+}
diff --git a/src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr b/src/test/ui/traits/impl-of-supertrait-has-wrong-lifetime-parameters.stderr
new file mode 100644 (file)
index 0000000..539a56f
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
+  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
+   |
+LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
+   |             ^^^^^^^^^^
+   |
+note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 24:6...
+  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:6
+   |
+LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
+   |      ^^
+note: ...but the lifetime must also be valid for the lifetime `'b` as defined on the impl at 24:9...
+  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:9
+   |
+LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
+   |         ^^
+note: ...so that the types are compatible
+  --> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
+   |
+LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
+   |             ^^^^^^^^^^
+   = note: expected `T1<'a>`
+              found `T1<'_>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/traits/impl.rs b/src/test/ui/traits/impl.rs
new file mode 100644 (file)
index 0000000..14796ce
--- /dev/null
@@ -0,0 +1,41 @@
+// run-pass
+// Test calling methods on an impl for a bare trait.
+
+// aux-build:traitimpl.rs
+
+extern crate traitimpl;
+use traitimpl::Bar;
+
+static mut COUNT: usize = 1;
+
+trait T {
+    fn t(&self) {}
+}
+
+impl<'a> dyn T+'a {
+    fn foo(&self) {
+        unsafe { COUNT *= 2; }
+    }
+    fn bar() {
+        unsafe { COUNT *= 3; }
+    }
+}
+
+impl T for isize {}
+
+struct Foo;
+impl<'a> Bar<'a> for Foo {}
+
+fn main() {
+    let x: &dyn T = &42;
+
+    x.foo();
+    T::foo(x);
+    T::bar();
+
+    unsafe { assert_eq!(COUNT, 12); }
+
+    // Cross-crait case
+    let x: &dyn Bar = &Foo;
+    x.bar();
+}
diff --git a/src/test/ui/traits/inductive-overflow/lifetime.rs b/src/test/ui/traits/inductive-overflow/lifetime.rs
new file mode 100644 (file)
index 0000000..205d50a
--- /dev/null
@@ -0,0 +1,30 @@
+// Test that we don't hit the recursion limit for short cycles involving lifetimes.
+
+// Shouldn't hit this, we should realize that we're in a cycle sooner.
+#![recursion_limit="20"]
+
+trait NotAuto {}
+trait Y {
+    type P;
+}
+
+impl<'a> Y for C<'a> {
+    type P = Box<X<C<'a>>>;
+}
+
+struct C<'a>(&'a ());
+struct X<T: Y>(T::P);
+
+impl<T: NotAuto> NotAuto for Box<T> {}
+impl<T: Y> NotAuto for X<T> where T::P: NotAuto {}
+impl<'a> NotAuto for C<'a> {}
+
+fn is_send<S: NotAuto>() {}
+//~^ NOTE: required
+
+fn main() {
+    // Should only be a few notes.
+    is_send::<X<C<'static>>>();
+    //~^ ERROR overflow evaluating
+    //~| NOTE: required
+}
diff --git a/src/test/ui/traits/inductive-overflow/lifetime.stderr b/src/test/ui/traits/inductive-overflow/lifetime.stderr
new file mode 100644 (file)
index 0000000..659f9e2
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0275]: overflow evaluating the requirement `Box<X<C<'_>>>: NotAuto`
+  --> $DIR/lifetime.rs:27:5
+   |
+LL | fn is_send<S: NotAuto>() {}
+   |               ------- required by this bound in `is_send`
+...
+LL |     is_send::<X<C<'static>>>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: required because of the requirements on the impl of `NotAuto` for `X<C<'static>>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/inductive-overflow/simultaneous.rs b/src/test/ui/traits/inductive-overflow/simultaneous.rs
new file mode 100644 (file)
index 0000000..40ac921
--- /dev/null
@@ -0,0 +1,20 @@
+// Regression test for #33344, initial version. This example allowed
+// arbitrary trait bounds to be synthesized.
+
+trait Tweedledum: IntoIterator {}
+trait Tweedledee: IntoIterator {}
+
+impl<T: Tweedledum> Tweedledee for T {}
+impl<T: Tweedledee> Tweedledum for T {}
+
+trait Combo: IntoIterator {}
+impl<T: Tweedledee + Tweedledum> Combo for T {}
+
+fn is_ee<T: Combo>(t: T) {
+    t.into_iter();
+}
+
+fn main() {
+    is_ee(4);
+    //~^ ERROR overflow evaluating the requirement `{integer}: Tweedle
+}
diff --git a/src/test/ui/traits/inductive-overflow/simultaneous.stderr b/src/test/ui/traits/inductive-overflow/simultaneous.stderr
new file mode 100644 (file)
index 0000000..484ac85
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum`
+  --> $DIR/simultaneous.rs:18:5
+   |
+LL | fn is_ee<T: Combo>(t: T) {
+   |             ----- required by this bound in `is_ee`
+...
+LL |     is_ee(4);
+   |     ^^^^^
+   |
+   = note: required because of the requirements on the impl of `Combo` for `{integer}`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.rs
new file mode 100644 (file)
index 0000000..5fea47a
--- /dev/null
@@ -0,0 +1,18 @@
+// Auto-trait-based version of #29859, supertrait version. Test that using
+// a simple auto trait `..` impl alone still doesn't allow arbitrary bounds
+// to be synthesized.
+
+#![feature(auto_traits)]
+#![feature(negative_impls)]
+
+auto trait Magic: Copy {} //~ ERROR E0568
+
+fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
+
+#[derive(Debug)]
+struct NoClone;
+
+fn main() {
+    let (a, b) = copy(NoClone); //~ ERROR
+    println!("{:?} {:?}", a, b);
+}
diff --git a/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/src/test/ui/traits/inductive-overflow/supertrait-auto-trait.stderr
new file mode 100644 (file)
index 0000000..6a0f739
--- /dev/null
@@ -0,0 +1,23 @@
+error[E0568]: auto traits cannot have super traits
+  --> $DIR/supertrait-auto-trait.rs:8:19
+   |
+LL | auto trait Magic: Copy {}
+   |            -----  ^^^^ help: remove the super traits
+   |            |
+   |            auto trait cannot have super traits
+
+error[E0277]: the trait bound `NoClone: Copy` is not satisfied
+  --> $DIR/supertrait-auto-trait.rs:16:23
+   |
+LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
+   |            ----- required by this bound in `copy`
+...
+LL |     let (a, b) = copy(NoClone);
+   |                       ^^^^^^^ the trait `Copy` is not implemented for `NoClone`
+   |
+   = note: required because of the requirements on the impl of `Magic` for `NoClone`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0277, E0568.
+For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/inductive-overflow/supertrait.rs b/src/test/ui/traits/inductive-overflow/supertrait.rs
new file mode 100644 (file)
index 0000000..c7aa4d9
--- /dev/null
@@ -0,0 +1,15 @@
+// Regression test for #29859, supertrait version. This example
+// allowed arbitrary trait bounds to be synthesized.
+
+trait Magic: Copy {}
+impl<T: Magic> Magic for T {}
+
+fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
+
+#[derive(Debug)]
+struct NoClone;
+
+fn main() {
+    let (a, b) = copy(NoClone); //~ ERROR E0275
+    println!("{:?} {:?}", a, b);
+}
diff --git a/src/test/ui/traits/inductive-overflow/supertrait.stderr b/src/test/ui/traits/inductive-overflow/supertrait.stderr
new file mode 100644 (file)
index 0000000..dfb9676
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0275]: overflow evaluating the requirement `NoClone: Magic`
+  --> $DIR/supertrait.rs:13:18
+   |
+LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
+   |            ----- required by this bound in `copy`
+...
+LL |     let (a, b) = copy(NoClone);
+   |                  ^^^^
+   |
+   = note: required because of the requirements on the impl of `Magic` for `NoClone`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/inductive-overflow/two-traits.rs b/src/test/ui/traits/inductive-overflow/two-traits.rs
new file mode 100644 (file)
index 0000000..463b55d
--- /dev/null
@@ -0,0 +1,22 @@
+// Regression test for #29859, initial version. This example allowed
+// arbitrary trait bounds to be synthesized.
+
+// Trait that you want all types to implement.
+use std::marker::{Sync as Trait};
+
+pub trait Magic {
+    type X: Trait;
+}
+impl<T: Magic> Magic for T {
+    type X = Self;
+    //~^ ERROR E0277
+}
+
+fn check<T: Trait>() {}
+
+fn wizard<T: Magic>() { check::<<T as Magic>::X>(); }
+
+fn main() {
+    wizard::<*mut ()>(); //~ ERROR E0275
+    // check::<*mut ()>();
+}
diff --git a/src/test/ui/traits/inductive-overflow/two-traits.stderr b/src/test/ui/traits/inductive-overflow/two-traits.stderr
new file mode 100644 (file)
index 0000000..d3f2931
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0277]: `T` cannot be shared between threads safely
+  --> $DIR/two-traits.rs:11:5
+   |
+LL |     type X: Trait;
+   |             ----- required by this bound in `Magic::X`
+...
+LL |     type X = Self;
+   |     ^^^^^^^^^^^^^^ `T` cannot be shared between threads safely
+   |
+help: consider further restricting this bound
+   |
+LL | impl<T: Magic + Sync> Magic for T {
+   |               ^^^^^^
+
+error[E0275]: overflow evaluating the requirement `*mut (): Magic`
+  --> $DIR/two-traits.rs:20:5
+   |
+LL | fn wizard<T: Magic>() { check::<<T as Magic>::X>(); }
+   |              ----- required by this bound in `wizard`
+...
+LL |     wizard::<*mut ()>();
+   |     ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0275, E0277.
+For more information about an error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/infer-from-object-issue-26952.rs b/src/test/ui/traits/infer-from-object-issue-26952.rs
new file mode 100644 (file)
index 0000000..ed258db
--- /dev/null
@@ -0,0 +1,26 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_variables)]
+// Test that when we match a trait reference like `Foo<A>: Foo<_#0t>`,
+// we unify with `_#0t` with `A`. In this code, if we failed to do
+// that, then you get an unconstrained type-variable in `call`.
+//
+// Also serves as a regression test for issue #26952, though the test
+// was derived from another reported regression with the same cause.
+
+use std::marker::PhantomData;
+
+trait Trait<A> { fn foo(&self); }
+
+struct Type<A> { a: PhantomData<A> }
+
+fn as_trait<A>(t: &Type<A>) -> &dyn Trait<A> { loop {  } }
+
+fn want<A,T:Trait<A>+?Sized>(t: &T) { }
+
+fn call<A>(p: Type<A>) {
+    let q = as_trait(&p);
+    want(q); // parameter A to `want` *would* be unconstrained
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/infer-from-object-trait-issue-26952.rs b/src/test/ui/traits/infer-from-object-trait-issue-26952.rs
deleted file mode 100644 (file)
index ed258db..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(unused_variables)]
-// Test that when we match a trait reference like `Foo<A>: Foo<_#0t>`,
-// we unify with `_#0t` with `A`. In this code, if we failed to do
-// that, then you get an unconstrained type-variable in `call`.
-//
-// Also serves as a regression test for issue #26952, though the test
-// was derived from another reported regression with the same cause.
-
-use std::marker::PhantomData;
-
-trait Trait<A> { fn foo(&self); }
-
-struct Type<A> { a: PhantomData<A> }
-
-fn as_trait<A>(t: &Type<A>) -> &dyn Trait<A> { loop {  } }
-
-fn want<A,T:Trait<A>+?Sized>(t: &T) { }
-
-fn call<A>(p: Type<A>) {
-    let q = as_trait(&p);
-    want(q); // parameter A to `want` *would* be unconstrained
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/inherent-method-order.rs b/src/test/ui/traits/inherent-method-order.rs
new file mode 100644 (file)
index 0000000..f632ae8
--- /dev/null
@@ -0,0 +1,25 @@
+// run-pass
+
+struct Foo;
+
+impl Foo {
+    #[allow(dead_code)]
+    fn foo(self) {
+        panic!("wrong method!")
+    }
+}
+
+trait Trait {
+    fn foo(self);
+}
+
+impl<'a,'b,'c> Trait for &'a &'b &'c Foo {
+    fn foo(self) {
+        // ok
+    }
+}
+
+fn main() {
+    let x = &(&(&Foo));
+    x.foo();
+}
diff --git a/src/test/ui/traits/inherent-trait-method-order.rs b/src/test/ui/traits/inherent-trait-method-order.rs
deleted file mode 100644 (file)
index f632ae8..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// run-pass
-
-struct Foo;
-
-impl Foo {
-    #[allow(dead_code)]
-    fn foo(self) {
-        panic!("wrong method!")
-    }
-}
-
-trait Trait {
-    fn foo(self);
-}
-
-impl<'a,'b,'c> Trait for &'a &'b &'c Foo {
-    fn foo(self) {
-        // ok
-    }
-}
-
-fn main() {
-    let x = &(&(&Foo));
-    x.foo();
-}
diff --git a/src/test/ui/traits/inheritance/auto-xc-2.rs b/src/test/ui/traits/inheritance/auto-xc-2.rs
new file mode 100644 (file)
index 0000000..f213022
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+// aux-build:auto_xc_2.rs
+
+
+extern crate auto_xc_2 as aux;
+
+// aux defines impls of Foo, Bar and Baz for A
+use aux::{Foo, Bar, Baz, A};
+
+// We want to extend all Foo, Bar, Bazes to Quuxes
+pub trait Quux: Foo + Bar + Baz { }
+impl<T:Foo + Bar + Baz> Quux for T { }
+
+fn f<T:Quux>(a: &T) {
+    assert_eq!(a.f(), 10);
+    assert_eq!(a.g(), 20);
+    assert_eq!(a.h(), 30);
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    f(a);
+}
diff --git a/src/test/ui/traits/inheritance/auto-xc.rs b/src/test/ui/traits/inheritance/auto-xc.rs
new file mode 100644 (file)
index 0000000..3d5ae18
--- /dev/null
@@ -0,0 +1,25 @@
+// run-pass
+#![allow(dead_code)]
+// aux-build:auto_xc.rs
+
+
+extern crate auto_xc as aux;
+
+use aux::{Foo, Bar, Baz, Quux};
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+impl Baz for A { fn h(&self) -> isize { 30 } }
+
+fn f<T:Quux>(a: &T) {
+    assert_eq!(a.f(), 10);
+    assert_eq!(a.g(), 20);
+    assert_eq!(a.h(), 30);
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    f(a);
+}
diff --git a/src/test/ui/traits/inheritance/auto.rs b/src/test/ui/traits/inheritance/auto.rs
new file mode 100644 (file)
index 0000000..0be67a5
--- /dev/null
@@ -0,0 +1,29 @@
+// run-pass
+#![allow(dead_code)]
+// Testing that this impl turns A into a Quux, because
+// A is already a Foo Bar Baz
+
+impl<T:Foo + Bar + Baz> Quux for T { }
+
+trait Foo { fn f(&self) -> isize; }
+trait Bar { fn g(&self) -> isize; }
+trait Baz { fn h(&self) -> isize; }
+
+trait Quux: Foo + Bar + Baz { }
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+impl Baz for A { fn h(&self) -> isize { 30 } }
+
+fn f<T:Quux>(a: &T) {
+    assert_eq!(a.f(), 10);
+    assert_eq!(a.g(), 20);
+    assert_eq!(a.h(), 30);
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    f(a);
+}
diff --git a/src/test/ui/traits/inheritance/auxiliary/auto_xc.rs b/src/test/ui/traits/inheritance/auxiliary/auto_xc.rs
new file mode 100644 (file)
index 0000000..9af26cb
--- /dev/null
@@ -0,0 +1,7 @@
+pub trait Foo { fn f(&self) -> isize; }
+pub trait Bar { fn g(&self) -> isize; }
+pub trait Baz { fn h(&self) -> isize; }
+
+pub trait Quux: Foo + Bar + Baz { }
+
+impl<T:Foo + Bar + Baz> Quux for T { }
diff --git a/src/test/ui/traits/inheritance/auxiliary/auto_xc_2.rs b/src/test/ui/traits/inheritance/auxiliary/auto_xc_2.rs
new file mode 100644 (file)
index 0000000..e932767
--- /dev/null
@@ -0,0 +1,9 @@
+pub trait Foo { fn f(&self) -> isize; }
+pub trait Bar { fn g(&self) -> isize; }
+pub trait Baz { fn h(&self) -> isize; }
+
+pub struct A { pub x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+impl Baz for A { fn h(&self) -> isize { 30 } }
diff --git a/src/test/ui/traits/inheritance/auxiliary/overloading_xc.rs b/src/test/ui/traits/inheritance/auxiliary/overloading_xc.rs
new file mode 100644 (file)
index 0000000..a257044
--- /dev/null
@@ -0,0 +1,38 @@
+use std::cmp::PartialEq;
+use std::ops::{Add, Sub, Mul};
+
+pub trait MyNum : Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + PartialEq + Clone {
+}
+
+#[derive(Clone, Debug)]
+pub struct MyInt {
+    pub val: isize
+}
+
+impl Add for MyInt {
+    type Output = MyInt;
+
+    fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
+}
+
+impl Sub for MyInt {
+    type Output = MyInt;
+
+    fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
+}
+
+impl Mul for MyInt {
+    type Output = MyInt;
+
+    fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
+}
+
+impl PartialEq for MyInt {
+    fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
+
+    fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
+}
+
+impl MyNum for MyInt {}
+
+fn mi(v: isize) -> MyInt { MyInt { val: v } }
diff --git a/src/test/ui/traits/inheritance/auxiliary/xc_call.rs b/src/test/ui/traits/inheritance/auxiliary/xc_call.rs
new file mode 100644 (file)
index 0000000..b76c52e
--- /dev/null
@@ -0,0 +1,11 @@
+pub trait Foo {
+    fn f(&self) -> isize;
+}
+
+pub struct A {
+    pub x: isize
+}
+
+impl Foo for A {
+    fn f(&self) -> isize { 10 }
+}
diff --git a/src/test/ui/traits/inheritance/basic.rs b/src/test/ui/traits/inheritance/basic.rs
new file mode 100644 (file)
index 0000000..5bfa60b
--- /dev/null
@@ -0,0 +1,26 @@
+// run-pass
+#![allow(dead_code)]
+
+trait Foo { fn f(&self) -> isize; }
+trait Bar { fn g(&self) -> isize; }
+trait Baz { fn h(&self) -> isize; }
+
+trait Quux: Foo + Bar + Baz { }
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+impl Baz for A { fn h(&self) -> isize { 30 } }
+impl Quux for A {}
+
+fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
+    assert_eq!(a.f(), 10);
+    assert_eq!(a.g(), 20);
+    assert_eq!(a.h(), 30);
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    f(a);
+}
diff --git a/src/test/ui/traits/inheritance/call-bound-inherited.rs b/src/test/ui/traits/inheritance/call-bound-inherited.rs
new file mode 100644 (file)
index 0000000..37c2ff6
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+#![allow(dead_code)]
+
+trait Foo { fn f(&self) -> isize; }
+trait Bar : Foo { fn g(&self) -> isize; }
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+
+// Call a function on Foo, given a T: Bar
+fn gg<T:Bar>(a: &T) -> isize {
+    a.f()
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    assert_eq!(gg(a), 10);
+}
diff --git a/src/test/ui/traits/inheritance/call-bound-inherited2.rs b/src/test/ui/traits/inheritance/call-bound-inherited2.rs
new file mode 100644 (file)
index 0000000..8576d29
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(dead_code)]
+
+trait Foo { fn f(&self) -> isize; }
+trait Bar : Foo { fn g(&self) -> isize; }
+trait Baz : Bar { fn h(&self) -> isize; }
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+impl Baz for A { fn h(&self) -> isize { 30 } }
+
+// Call a function on Foo, given a T: Baz,
+// which is inherited via Bar
+fn gg<T:Baz>(a: &T) -> isize {
+    a.f()
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    assert_eq!(gg(a), 10);
+}
diff --git a/src/test/ui/traits/inheritance/cast-without-call-to-supertrait.rs b/src/test/ui/traits/inheritance/cast-without-call-to-supertrait.rs
new file mode 100644 (file)
index 0000000..25159c1
--- /dev/null
@@ -0,0 +1,33 @@
+// run-pass
+#![allow(dead_code)]
+// Testing that we can cast to a subtrait and call subtrait
+// methods. Not testing supertrait methods
+
+
+trait Foo {
+    fn f(&self) -> isize;
+}
+
+trait Bar : Foo {
+    fn g(&self) -> isize;
+}
+
+struct A {
+    x: isize
+}
+
+impl Foo for A {
+    fn f(&self) -> isize { 10 }
+}
+
+impl Bar for A {
+    fn g(&self) -> isize { 20 }
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    let afoo = a as &dyn Foo;
+    let abar = a as &dyn Bar;
+    assert_eq!(afoo.f(), 10);
+    assert_eq!(abar.g(), 20);
+}
diff --git a/src/test/ui/traits/inheritance/cast.rs b/src/test/ui/traits/inheritance/cast.rs
new file mode 100644 (file)
index 0000000..9070b9d
--- /dev/null
@@ -0,0 +1,33 @@
+// run-pass
+#![allow(dead_code)]
+// Testing that supertrait methods can be called on subtrait object types
+
+
+trait Foo {
+    fn f(&self) -> isize;
+}
+
+trait Bar : Foo {
+    fn g(&self) -> isize;
+}
+
+struct A {
+    x: isize
+}
+
+impl Foo for A {
+    fn f(&self) -> isize { 10 }
+}
+
+impl Bar for A {
+    fn g(&self) -> isize { 20 }
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    let afoo = a as &dyn Foo;
+    let abar = a as &dyn Bar;
+    assert_eq!(afoo.f(), 10);
+    assert_eq!(abar.g(), 20);
+    assert_eq!(abar.f(), 10);
+}
diff --git a/src/test/ui/traits/inheritance/cross-trait-call-xc.rs b/src/test/ui/traits/inheritance/cross-trait-call-xc.rs
new file mode 100644 (file)
index 0000000..99fbb5c
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+// aux-build:xc_call.rs
+
+
+extern crate xc_call as aux;
+
+use aux::Foo;
+
+trait Bar : Foo {
+    fn g(&self) -> isize;
+}
+
+impl Bar for aux::A {
+    fn g(&self) -> isize { self.f() }
+}
+
+pub fn main() {
+    let a = &aux::A { x: 3 };
+    assert_eq!(a.g(), 10);
+}
diff --git a/src/test/ui/traits/inheritance/cross-trait-call.rs b/src/test/ui/traits/inheritance/cross-trait-call.rs
new file mode 100644 (file)
index 0000000..512c928
--- /dev/null
@@ -0,0 +1,19 @@
+// run-pass
+#![allow(dead_code)]
+
+trait Foo { fn f(&self) -> isize; }
+trait Bar : Foo { fn g(&self) -> isize; }
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+
+impl Bar for A {
+    // Testing that this impl can call the impl of Foo
+    fn g(&self) -> isize { self.f() }
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    assert_eq!(a.g(), 10);
+}
diff --git a/src/test/ui/traits/inheritance/diamond.rs b/src/test/ui/traits/inheritance/diamond.rs
new file mode 100644 (file)
index 0000000..32ad0fb
--- /dev/null
@@ -0,0 +1,28 @@
+// run-pass
+#![allow(dead_code)]
+// B and C both require A, so D does as well, twice, but that's just fine
+
+
+trait A { fn a(&self) -> isize; }
+trait B: A { fn b(&self) -> isize; }
+trait C: A { fn c(&self) -> isize; }
+trait D: B + C { fn d(&self) -> isize; }
+
+struct S { bogus: () }
+
+impl A for S { fn a(&self) -> isize { 10 } }
+impl B for S { fn b(&self) -> isize { 20 } }
+impl C for S { fn c(&self) -> isize { 30 } }
+impl D for S { fn d(&self) -> isize { 40 } }
+
+fn f<T:D>(x: &T) {
+    assert_eq!(x.a(), 10);
+    assert_eq!(x.b(), 20);
+    assert_eq!(x.c(), 30);
+    assert_eq!(x.d(), 40);
+}
+
+pub fn main() {
+    let value = &S { bogus: () };
+    f(value);
+}
diff --git a/src/test/ui/traits/inheritance/multiple-inheritors.rs b/src/test/ui/traits/inheritance/multiple-inheritors.rs
new file mode 100644 (file)
index 0000000..77ecbd8
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(dead_code)]
+
+trait A { fn a(&self) -> isize; }
+trait B: A { fn b(&self) -> isize; }
+trait C: A { fn c(&self) -> isize; }
+
+struct S { bogus: () }
+
+impl A for S { fn a(&self) -> isize { 10 } }
+impl B for S { fn b(&self) -> isize { 20 } }
+impl C for S { fn c(&self) -> isize { 30 } }
+
+// Both B and C inherit from A
+fn f<T:B + C>(x: &T) {
+    assert_eq!(x.a(), 10);
+    assert_eq!(x.b(), 20);
+    assert_eq!(x.c(), 30);
+}
+
+pub fn main() {
+    f(&S { bogus: () })
+}
diff --git a/src/test/ui/traits/inheritance/multiple-params.rs b/src/test/ui/traits/inheritance/multiple-params.rs
new file mode 100644 (file)
index 0000000..8ff5ba5
--- /dev/null
@@ -0,0 +1,26 @@
+// run-pass
+#![allow(dead_code)]
+
+trait A { fn a(&self) -> isize; }
+trait B: A { fn b(&self) -> isize; }
+trait C: A { fn c(&self) -> isize; }
+
+struct S { bogus: () }
+
+impl A for S { fn a(&self) -> isize { 10 } }
+impl B for S { fn b(&self) -> isize { 20 } }
+impl C for S { fn c(&self) -> isize { 30 } }
+
+// Multiple type params, multiple levels of inheritance
+fn f<X:A,Y:B,Z:C>(x: &X, y: &Y, z: &Z) {
+    assert_eq!(x.a(), 10);
+    assert_eq!(y.a(), 10);
+    assert_eq!(y.b(), 20);
+    assert_eq!(z.a(), 10);
+    assert_eq!(z.c(), 30);
+}
+
+pub fn main() {
+    let s = &S { bogus: () };
+    f(s, s, s);
+}
diff --git a/src/test/ui/traits/inheritance/num.rs b/src/test/ui/traits/inheritance/num.rs
new file mode 100644 (file)
index 0000000..3d63d78
--- /dev/null
@@ -0,0 +1,13 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_variables)]
+// pretty-expanded FIXME #23616
+
+pub trait NumExt: PartialEq + PartialOrd {}
+
+pub trait FloatExt: NumExt {}
+
+fn greater_than_one<T: NumExt>(n: &T) -> bool { loop {} }
+fn greater_than_one_float<T: FloatExt>(n: &T) -> bool { loop {} }
+
+pub fn main() {}
diff --git a/src/test/ui/traits/inheritance/num0.rs b/src/test/ui/traits/inheritance/num0.rs
new file mode 100644 (file)
index 0000000..cee5254
--- /dev/null
@@ -0,0 +1,24 @@
+// run-pass
+#![allow(dead_code)]
+// Extending Num and using inherited static methods
+
+// pretty-expanded FIXME #23616
+
+use std::cmp::PartialOrd;
+
+pub trait NumCast: Sized {
+    fn from(i: i32) -> Option<Self>;
+}
+
+pub trait Num {
+    fn from_int(i: isize) -> Self;
+    fn gt(&self, other: &Self) -> bool;
+}
+
+pub trait NumExt: NumCast + PartialOrd { }
+
+fn greater_than_one<T:NumExt>(n: &T) -> bool {
+    n.gt(&NumCast::from(1).unwrap())
+}
+
+pub fn main() {}
diff --git a/src/test/ui/traits/inheritance/num1.rs b/src/test/ui/traits/inheritance/num1.rs
new file mode 100644 (file)
index 0000000..663dd3a
--- /dev/null
@@ -0,0 +1,15 @@
+// run-pass
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+pub trait NumCast: Sized {
+    fn from(i: i32) -> Option<Self>;
+}
+
+pub trait NumExt: NumCast + PartialOrd { }
+
+fn greater_than_one<T:NumExt>(n: &T) -> bool {
+    *n > NumCast::from(1).unwrap()
+}
+
+pub fn main() {}
diff --git a/src/test/ui/traits/inheritance/num2.rs b/src/test/ui/traits/inheritance/num2.rs
new file mode 100644 (file)
index 0000000..b713c66
--- /dev/null
@@ -0,0 +1,86 @@
+// run-pass
+// A more complex example of numeric extensions
+
+pub trait TypeExt {}
+
+impl TypeExt for u8 {}
+impl TypeExt for u16 {}
+impl TypeExt for u32 {}
+impl TypeExt for u64 {}
+impl TypeExt for usize {}
+
+impl TypeExt for i8 {}
+impl TypeExt for i16 {}
+impl TypeExt for i32 {}
+impl TypeExt for i64 {}
+impl TypeExt for isize {}
+
+impl TypeExt for f32 {}
+impl TypeExt for f64 {}
+
+
+pub trait NumExt: TypeExt + PartialEq + PartialOrd {}
+
+impl NumExt for u8 {}
+impl NumExt for u16 {}
+impl NumExt for u32 {}
+impl NumExt for u64 {}
+impl NumExt for usize {}
+
+impl NumExt for i8 {}
+impl NumExt for i16 {}
+impl NumExt for i32 {}
+impl NumExt for i64 {}
+impl NumExt for isize {}
+
+impl NumExt for f32 {}
+impl NumExt for f64 {}
+
+
+pub trait UnSignedExt: NumExt {}
+
+impl UnSignedExt for u8 {}
+impl UnSignedExt for u16 {}
+impl UnSignedExt for u32 {}
+impl UnSignedExt for u64 {}
+impl UnSignedExt for usize {}
+
+
+pub trait SignedExt: NumExt {}
+
+impl SignedExt for i8 {}
+impl SignedExt for i16 {}
+impl SignedExt for i32 {}
+impl SignedExt for i64 {}
+impl SignedExt for isize {}
+
+impl SignedExt for f32 {}
+impl SignedExt for f64 {}
+
+
+pub trait IntegerExt: NumExt {}
+
+impl IntegerExt for u8 {}
+impl IntegerExt for u16 {}
+impl IntegerExt for u32 {}
+impl IntegerExt for u64 {}
+impl IntegerExt for usize {}
+
+impl IntegerExt for i8 {}
+impl IntegerExt for i16 {}
+impl IntegerExt for i32 {}
+impl IntegerExt for i64 {}
+impl IntegerExt for isize {}
+
+
+pub trait FloatExt: NumExt {}
+
+impl FloatExt for f32 {}
+impl FloatExt for f64 {}
+
+
+fn test_float_ext<T:FloatExt>(n: T) { println!("{}", n < n) }
+
+pub fn main() {
+    test_float_ext(1f32);
+}
diff --git a/src/test/ui/traits/inheritance/num3.rs b/src/test/ui/traits/inheritance/num3.rs
new file mode 100644 (file)
index 0000000..c40be6f
--- /dev/null
@@ -0,0 +1,19 @@
+// run-pass
+pub trait NumCast: Sized {
+    fn from(i: i32) -> Option<Self>;
+}
+
+pub trait NumExt: PartialEq + PartialOrd + NumCast {}
+
+impl NumExt for f32 {}
+impl NumCast for f32 {
+    fn from(i: i32) -> Option<f32> { Some(i as f32) }
+}
+
+fn num_eq_one<T: NumExt>(n: T) {
+    println!("{}", n == NumCast::from(1).unwrap())
+}
+
+pub fn main() {
+    num_eq_one(1f32); // you need to actually use the function to trigger the ICE
+}
diff --git a/src/test/ui/traits/inheritance/num5.rs b/src/test/ui/traits/inheritance/num5.rs
new file mode 100644 (file)
index 0000000..f478618
--- /dev/null
@@ -0,0 +1,26 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+pub trait NumCast: Sized {
+    fn from(i: i32) -> Option<Self>;
+}
+
+pub trait NumExt: PartialEq + NumCast {}
+
+impl NumExt for f32 {}
+impl NumExt for isize {}
+
+impl NumCast for f32 {
+    fn from(i: i32) -> Option<f32> { Some(i as f32) }
+}
+impl NumCast for isize {
+    fn from(i: i32) -> Option<isize> { Some(i as isize) }
+}
+
+fn num_eq_one<T:NumExt>() -> T {
+    NumCast::from(1).unwrap()
+}
+
+pub fn main() {
+    num_eq_one::<isize>(); // you need to actually use the function to trigger the ICE
+}
diff --git a/src/test/ui/traits/inheritance/overloading-simple.rs b/src/test/ui/traits/inheritance/overloading-simple.rs
new file mode 100644 (file)
index 0000000..c306aa2
--- /dev/null
@@ -0,0 +1,27 @@
+// run-pass
+#![allow(dead_code)]
+use std::cmp::PartialEq;
+
+trait MyNum : PartialEq { }
+
+#[derive(Debug)]
+struct MyInt { val: isize }
+
+impl PartialEq for MyInt {
+    fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
+    fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
+}
+
+impl MyNum for MyInt {}
+
+fn f<T:MyNum>(x: T, y: T) -> bool {
+    return x == y;
+}
+
+fn mi(v: isize) -> MyInt { MyInt { val: v } }
+
+pub fn main() {
+    let (x, y, z) = (mi(3), mi(5), mi(3));
+    assert!(x != y);
+    assert_eq!(x, z);
+}
diff --git a/src/test/ui/traits/inheritance/overloading-xc-exe.rs b/src/test/ui/traits/inheritance/overloading-xc-exe.rs
new file mode 100644 (file)
index 0000000..0877806
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+// aux-build:overloading_xc.rs
+
+
+extern crate overloading_xc;
+use overloading_xc::{MyNum, MyInt};
+
+fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
+    return (x.clone() + y.clone(), x.clone() - y.clone(), x * y);
+}
+
+fn mi(v: isize) -> MyInt { MyInt { val: v } }
+
+pub fn main() {
+    let (x, y) = (mi(3), mi(5));
+    let (a, b, c) = f(x, y);
+    assert_eq!(a, mi(8));
+    assert_eq!(b, mi(-2));
+    assert_eq!(c, mi(15));
+}
diff --git a/src/test/ui/traits/inheritance/overloading.rs b/src/test/ui/traits/inheritance/overloading.rs
new file mode 100644 (file)
index 0000000..083643e
--- /dev/null
@@ -0,0 +1,47 @@
+// run-pass
+use std::cmp::PartialEq;
+use std::ops::{Add, Sub, Mul};
+
+trait MyNum : Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + PartialEq + Clone { }
+
+#[derive(Clone, Debug)]
+struct MyInt { val: isize }
+
+impl Add for MyInt {
+    type Output = MyInt;
+
+    fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
+}
+
+impl Sub for MyInt {
+    type Output = MyInt;
+
+    fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
+}
+
+impl Mul for MyInt {
+    type Output = MyInt;
+
+    fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
+}
+
+impl PartialEq for MyInt {
+    fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
+    fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
+}
+
+impl MyNum for MyInt {}
+
+fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
+    return (x.clone() + y.clone(), x.clone() - y.clone(), x * y);
+}
+
+fn mi(v: isize) -> MyInt { MyInt { val: v } }
+
+pub fn main() {
+    let (x, y) = (mi(3), mi(5));
+    let (a, b, c) = f(x, y);
+    assert_eq!(a, mi(8));
+    assert_eq!(b, mi(-2));
+    assert_eq!(c, mi(15));
+}
diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.rs
new file mode 100644 (file)
index 0000000..6aaef8a
--- /dev/null
@@ -0,0 +1,43 @@
+// Test a case of a trait which extends the same supertrait twice, but
+// with difference type parameters. Test then that when we don't give
+// enough information to pick between these, no selection is made. In
+// this particular case, the two choices are i64/u64 -- so when we use
+// an integer literal, we wind up falling this literal back to i32.
+// See also `run-pass/trait-repeated-supertrait.rs`.
+
+trait CompareTo<T> {
+    fn same_as(&self, t: T) -> bool;
+}
+
+trait CompareToInts : CompareTo<i64> + CompareTo<u64> {
+}
+
+impl CompareTo<i64> for i64 {
+    fn same_as(&self, t: i64) -> bool { *self == t }
+}
+
+impl CompareTo<u64> for i64 {
+    fn same_as(&self, t: u64) -> bool { *self == (t as i64) }
+}
+
+impl CompareToInts for i64 { }
+
+fn with_obj(c: &dyn CompareToInts) -> bool {
+    c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfied
+}
+
+fn with_trait<C:CompareToInts>(c: &C) -> bool {
+    c.same_as(22) //~ ERROR `C: CompareTo<i32>` is not satisfied
+}
+
+fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
+    CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfied
+}
+
+fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {
+    CompareTo::same_as(c, 22) //~ ERROR `C: CompareTo<i32>` is not satisfied
+}
+
+fn main() {
+    assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64: CompareTo<i32>` is not satisfied
+}
diff --git a/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/src/test/ui/traits/inheritance/repeated-supertrait-ambig.stderr
new file mode 100644 (file)
index 0000000..5353b5e
--- /dev/null
@@ -0,0 +1,53 @@
+error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied
+  --> $DIR/repeated-supertrait-ambig.rs:26:7
+   |
+LL |     c.same_as(22)
+   |       ^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
+
+error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied
+  --> $DIR/repeated-supertrait-ambig.rs:30:7
+   |
+LL |     c.same_as(22)
+   |       ^^^^^^^ the trait `CompareTo<i32>` is not implemented for `C`
+   |
+help: consider further restricting this bound
+   |
+LL | fn with_trait<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
+   |                               ^^^^^^^^^^^^^^^^
+
+error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied
+  --> $DIR/repeated-supertrait-ambig.rs:34:5
+   |
+LL |     fn same_as(&self, t: T) -> bool;
+   |     -------------------------------- required by `CompareTo::same_as`
+...
+LL |     CompareToInts::same_as(c, 22)
+   |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
+
+error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied
+  --> $DIR/repeated-supertrait-ambig.rs:38:5
+   |
+LL |     fn same_as(&self, t: T) -> bool;
+   |     -------------------------------- required by `CompareTo::same_as`
+...
+LL |     CompareTo::same_as(c, 22)
+   |     ^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `C`
+   |
+help: consider further restricting this bound
+   |
+LL | fn with_ufcs2<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
+   |                               ^^^^^^^^^^^^^^^^
+
+error[E0277]: the trait bound `i64: CompareTo<i32>` is not satisfied
+  --> $DIR/repeated-supertrait-ambig.rs:42:23
+   |
+LL |     assert_eq!(22_i64.same_as(22), true);
+   |                       ^^^^^^^ the trait `CompareTo<i32>` is not implemented for `i64`
+   |
+   = help: the following implementations were found:
+             <i64 as CompareTo<i64>>
+             <i64 as CompareTo<u64>>
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/inheritance/repeated-supertrait.rs b/src/test/ui/traits/inheritance/repeated-supertrait.rs
new file mode 100644 (file)
index 0000000..339f9c3
--- /dev/null
@@ -0,0 +1,48 @@
+// run-pass
+// Test a case of a trait which extends the same supertrait twice, but
+// with difference type parameters. Test that we can invoke the
+// various methods in various ways successfully.
+// See also `ui/traits/trait-repeated-supertrait-ambig.rs`.
+
+
+trait CompareTo<T> {
+    fn same_as(&self, t: T) -> bool;
+}
+
+trait CompareToInts : CompareTo<i64> + CompareTo<u64> {
+}
+
+impl CompareTo<i64> for i64 {
+    fn same_as(&self, t: i64) -> bool { *self == t }
+}
+
+impl CompareTo<u64> for i64 {
+    fn same_as(&self, t: u64) -> bool { *self == (t as i64) }
+}
+
+impl CompareToInts for i64 { }
+
+fn with_obj(c: &dyn CompareToInts) -> bool {
+    c.same_as(22_i64) && c.same_as(22_u64)
+}
+
+fn with_trait<C:CompareToInts>(c: &C) -> bool {
+    c.same_as(22_i64) && c.same_as(22_u64)
+}
+
+fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
+    CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64)
+}
+
+fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {
+    CompareTo::same_as(c, 22_i64) && CompareTo::same_as(c, 22_u64)
+}
+
+fn main() {
+    assert_eq!(22_i64.same_as(22_i64), true);
+    assert_eq!(22_i64.same_as(22_u64), true);
+    assert_eq!(with_trait(&22), true);
+    assert_eq!(with_obj(&22), true);
+    assert_eq!(with_ufcs1(&22), true);
+    assert_eq!(with_ufcs2(&22), true);
+}
diff --git a/src/test/ui/traits/inheritance/self-in-supertype.rs b/src/test/ui/traits/inheritance/self-in-supertype.rs
new file mode 100644 (file)
index 0000000..e8a2bd7
--- /dev/null
@@ -0,0 +1,62 @@
+// run-pass
+// Test for issue #4183: use of Self in supertraits.
+
+pub static FUZZY_EPSILON: f64 = 0.1;
+
+pub trait FuzzyEq<Eps> {
+    fn fuzzy_eq(&self, other: &Self) -> bool;
+    fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool;
+}
+
+trait Float: Sized+FuzzyEq<Self> {
+    fn two_pi() -> Self;
+}
+
+impl FuzzyEq<f32> for f32 {
+    fn fuzzy_eq(&self, other: &f32) -> bool {
+        self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32))
+    }
+
+    fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool {
+        (*self - *other).abs() < *epsilon
+    }
+}
+
+impl Float for f32 {
+    fn two_pi() -> f32 { 6.28318530717958647692528676655900576_f32 }
+}
+
+impl FuzzyEq<f64> for f64 {
+    fn fuzzy_eq(&self, other: &f64) -> bool {
+        self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64))
+    }
+
+    fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool {
+        (*self - *other).abs() < *epsilon
+    }
+}
+
+impl Float for f64 {
+    fn two_pi() -> f64 { 6.28318530717958647692528676655900576_f64 }
+}
+
+fn compare<F:Float>(f1: F) -> bool {
+    let f2 = Float::two_pi();
+    f1.fuzzy_eq(&f2)
+}
+
+pub fn main() {
+    assert!(compare::<f32>(6.28318530717958647692528676655900576));
+    assert!(compare::<f32>(6.29));
+    assert!(compare::<f32>(6.3));
+    assert!(compare::<f32>(6.19));
+    assert!(!compare::<f32>(7.28318530717958647692528676655900576));
+    assert!(!compare::<f32>(6.18));
+
+    assert!(compare::<f64>(6.28318530717958647692528676655900576));
+    assert!(compare::<f64>(6.29));
+    assert!(compare::<f64>(6.3));
+    assert!(compare::<f64>(6.19));
+    assert!(!compare::<f64>(7.28318530717958647692528676655900576));
+    assert!(!compare::<f64>(6.18));
+}
diff --git a/src/test/ui/traits/inheritance/self.rs b/src/test/ui/traits/inheritance/self.rs
new file mode 100644 (file)
index 0000000..5f2559f
--- /dev/null
@@ -0,0 +1,29 @@
+// run-pass
+trait Foo<T> {
+    fn f(&self, x: &T);
+}
+
+trait Bar : Sized + Foo<Self> {
+    fn g(&self);
+}
+
+struct S {
+    x: isize
+}
+
+impl Foo<S> for S {
+    fn f(&self, x: &S) {
+        println!("{}", x.x);
+    }
+}
+
+impl Bar for S {
+    fn g(&self) {
+        self.f(self);
+    }
+}
+
+pub fn main() {
+    let s = S { x: 1 };
+    s.g();
+}
diff --git a/src/test/ui/traits/inheritance/simple.rs b/src/test/ui/traits/inheritance/simple.rs
new file mode 100644 (file)
index 0000000..ca3a284
--- /dev/null
@@ -0,0 +1,24 @@
+// run-pass
+#![allow(dead_code)]
+
+trait Foo { fn f(&self) -> isize; }
+trait Bar : Foo { fn g(&self) -> isize; }
+
+struct A { x: isize }
+
+impl Foo for A { fn f(&self) -> isize { 10 } }
+impl Bar for A { fn g(&self) -> isize { 20 } }
+
+fn ff<T:Foo>(a: &T) -> isize {
+    a.f()
+}
+
+fn gg<T:Bar>(a: &T) -> isize {
+    a.g()
+}
+
+pub fn main() {
+    let a = &A { x: 3 };
+    assert_eq!(ff(a), 10);
+    assert_eq!(gg(a), 20);
+}
diff --git a/src/test/ui/traits/inheritance/static.rs b/src/test/ui/traits/inheritance/static.rs
new file mode 100644 (file)
index 0000000..16218fb
--- /dev/null
@@ -0,0 +1,26 @@
+// run-pass
+
+pub trait MyNum {
+    fn from_int(_: isize) -> Self;
+}
+
+pub trait NumExt: MyNum { }
+
+struct S { v: isize }
+
+impl MyNum for S {
+    fn from_int(i: isize) -> S {
+        S {
+            v: i
+        }
+    }
+}
+
+impl NumExt for S { }
+
+fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
+
+pub fn main() {
+    let v: S = greater_than_one();
+    assert_eq!(v.v, 1);
+}
diff --git a/src/test/ui/traits/inheritance/static2.rs b/src/test/ui/traits/inheritance/static2.rs
new file mode 100644 (file)
index 0000000..bc78e1e
--- /dev/null
@@ -0,0 +1,29 @@
+// run-pass
+pub trait MyEq {}
+
+pub trait MyNum {
+    fn from_int(_: isize) -> Self;
+}
+
+pub trait NumExt: MyEq + MyNum { }
+
+struct S { v: isize }
+
+impl MyEq for S { }
+
+impl MyNum for S {
+    fn from_int(i: isize) -> S {
+        S {
+            v: i
+        }
+    }
+}
+
+impl NumExt for S { }
+
+fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
+
+pub fn main() {
+    let v: S = greater_than_one();
+    assert_eq!(v.v, 1);
+}
diff --git a/src/test/ui/traits/inheritance/subst.rs b/src/test/ui/traits/inheritance/subst.rs
new file mode 100644 (file)
index 0000000..b2b6503
--- /dev/null
@@ -0,0 +1,27 @@
+// run-pass
+
+pub trait Add<RHS,Result> {
+    fn add(&self, rhs: &RHS) -> Result;
+}
+
+trait MyNum : Sized + Add<Self,Self> { }
+
+struct MyInt { val: isize }
+
+impl Add<MyInt, MyInt> for MyInt {
+    fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
+}
+
+impl MyNum for MyInt {}
+
+fn f<T:MyNum>(x: T, y: T) -> T {
+    return x.add(&y);
+}
+
+fn mi(v: isize) -> MyInt { MyInt { val: v } }
+
+pub fn main() {
+    let (x, y) = (mi(3), mi(5));
+    let z = f(x, y);
+    assert_eq!(z.val, 8)
+}
diff --git a/src/test/ui/traits/inheritance/subst2.rs b/src/test/ui/traits/inheritance/subst2.rs
new file mode 100644 (file)
index 0000000..ccc9628
--- /dev/null
@@ -0,0 +1,37 @@
+// run-pass
+
+trait Panda<T> {
+    fn chomp(&self, bamboo: &T) -> T;
+}
+
+trait Add<RHS,Result>: Panda<RHS> {
+    fn add(&self, rhs: &RHS) -> Result;
+}
+
+trait MyNum : Sized + Add<Self,Self> { }
+
+struct MyInt { val: isize }
+
+impl Panda<MyInt> for MyInt {
+    fn chomp(&self, bamboo: &MyInt) -> MyInt {
+        mi(self.val + bamboo.val)
+    }
+}
+
+impl Add<MyInt, MyInt> for MyInt {
+    fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) }
+}
+
+impl MyNum for MyInt {}
+
+fn f<T:MyNum>(x: T, y: T) -> T {
+    return x.add(&y).chomp(&y);
+}
+
+fn mi(v: isize) -> MyInt { MyInt { val: v } }
+
+pub fn main() {
+    let (x, y) = (mi(3), mi(5));
+    let z = f(x, y);
+    assert_eq!(z.val, 13);
+}
diff --git a/src/test/ui/traits/inheritance/visibility.rs b/src/test/ui/traits/inheritance/visibility.rs
new file mode 100644 (file)
index 0000000..6ad8649
--- /dev/null
@@ -0,0 +1,20 @@
+// run-pass
+
+mod traits {
+    pub trait Foo { fn f(&self) -> isize; }
+
+    impl Foo for isize { fn f(&self) -> isize { 10 } }
+}
+
+trait Quux: traits::Foo { }
+impl<T:traits::Foo> Quux for T { }
+
+// Foo is not in scope but because Quux is we can still access
+// Foo's methods on a Quux bound typaram
+fn f<T:Quux>(x: &T) {
+    assert_eq!(x.f(), 10);
+}
+
+pub fn main() {
+    f(&0)
+}
diff --git a/src/test/ui/traits/issue-22019.rs b/src/test/ui/traits/issue-22019.rs
new file mode 100644 (file)
index 0000000..1a887f0
--- /dev/null
@@ -0,0 +1,34 @@
+// run-pass
+// Test an issue where global caching was causing free regions from
+// distinct scopes to be compared (`'g` and `'h`). The only important
+// thing is that compilation succeeds here.
+
+// pretty-expanded FIXME #23616
+
+#![allow(missing_copy_implementations)]
+#![allow(unused_variables)]
+
+use std::borrow::ToOwned;
+
+pub struct CFGNode;
+
+pub type Node<'a> = &'a CFGNode;
+
+pub trait GraphWalk<'c, N> {
+    /// Returns all the nodes in this graph.
+    fn nodes(&'c self) where [N]:ToOwned<Owned=Vec<N>>;
+}
+
+impl<'g> GraphWalk<'g, Node<'g>> for u32
+{
+    fn nodes(&'g self) where [Node<'g>]:ToOwned<Owned=Vec<Node<'g>>>
+    { loop { } }
+}
+
+impl<'h> GraphWalk<'h, Node<'h>> for u64
+{
+    fn nodes(&'h self) where [Node<'h>]:ToOwned<Owned=Vec<Node<'h>>>
+    { loop { } }
+}
+
+fn main()  { }
diff --git a/src/test/ui/traits/issue-22110.rs b/src/test/ui/traits/issue-22110.rs
new file mode 100644 (file)
index 0000000..bdbfee7
--- /dev/null
@@ -0,0 +1,27 @@
+// run-pass
+// Test an issue where we reported ambiguity between the where-clause
+// and the blanket impl. The only important thing is that compilation
+// succeeds here. Issue #22110.
+
+// pretty-expanded FIXME #23616
+
+#![allow(dead_code)]
+
+trait Foo<A> {
+    fn foo(&self, a: A);
+}
+
+impl<A,F:Fn(A)> Foo<A> for F {
+    fn foo(&self, _: A) { }
+}
+
+fn baz<A,F:for<'a> Foo<(&'a A,)>>(_: F) { }
+
+fn components<T,A>(t: fn(&A))
+    where fn(&A) : for<'a> Foo<(&'a A,)>,
+{
+    baz(t)
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/issue-22655.rs b/src/test/ui/traits/issue-22655.rs
new file mode 100644 (file)
index 0000000..bc08ca0
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(dead_code)]
+// Regression test for issue #22655: This test should not lead to
+// infinite recursion.
+
+// pretty-expanded FIXME #23616
+
+unsafe impl<T: Send + ?Sized> Send for Unique<T> { }
+
+pub struct Unique<T:?Sized> {
+    pointer: *const T,
+}
+
+pub struct Node<V> {
+    vals: V,
+    edges: Unique<Node<V>>,
+}
+
+fn is_send<T: Send>() {}
+
+fn main() {
+    is_send::<Node<&'static ()>>();
+}
diff --git a/src/test/ui/traits/issue-23003-overflow.rs b/src/test/ui/traits/issue-23003-overflow.rs
new file mode 100644 (file)
index 0000000..c5f471f
--- /dev/null
@@ -0,0 +1,29 @@
+// A variant of traits-issue-23003 in which an infinite series of
+// types are required. This test now just compiles fine, since the
+// relevant rules that triggered the overflow were removed.
+
+// check-pass
+#![allow(dead_code)]
+
+use std::marker::PhantomData;
+
+trait Async {
+    type Cancel;
+}
+
+struct Receipt<A:Async> {
+    marker: PhantomData<A>,
+}
+
+struct Complete<B> {
+    core: Option<B>,
+}
+
+impl<B> Async for Complete<B> {
+    type Cancel = Receipt<Complete<Option<B>>>;
+}
+
+fn foo(_: Receipt<Complete<()>>) { }
+
+
+fn main() { }
diff --git a/src/test/ui/traits/issue-23003.rs b/src/test/ui/traits/issue-23003.rs
new file mode 100644 (file)
index 0000000..24c2b2a
--- /dev/null
@@ -0,0 +1,32 @@
+// run-pass
+// Test stack overflow triggered by evaluating the implications. To be
+// WF, the type `Receipt<Complete>` would require that `<Complete as
+// Async>::Cancel` be WF. This normalizes to `Receipt<Complete>`
+// again, leading to an infinite cycle. Issue #23003.
+
+// pretty-expanded FIXME #23616
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+
+use std::marker::PhantomData;
+
+trait Async {
+    type Cancel;
+}
+
+struct Receipt<A:Async> {
+    marker: PhantomData<A>,
+}
+
+struct Complete {
+    core: Option<()>,
+}
+
+impl Async for Complete {
+    type Cancel = Receipt<Complete>;
+}
+
+fn foo(r: Receipt<Complete>) { }
+
+fn main() { }
diff --git a/src/test/ui/traits/issue-26339.rs b/src/test/ui/traits/issue-26339.rs
new file mode 100644 (file)
index 0000000..bedd87c
--- /dev/null
@@ -0,0 +1,31 @@
+// run-pass
+// Test that the right implementation is called through a trait
+// object when supertraits include multiple references to the
+// same trait, with different type parameters.
+
+trait A: PartialEq<Foo> + PartialEq<Bar> { }
+
+struct Foo;
+struct Bar;
+
+struct Aimpl;
+
+impl PartialEq<Foo> for Aimpl {
+    fn eq(&self, _rhs: &Foo) -> bool {
+        true
+    }
+}
+
+impl PartialEq<Bar> for Aimpl {
+    fn eq(&self, _rhs: &Bar) -> bool {
+        false
+    }
+}
+
+impl A for Aimpl { }
+
+fn main() {
+    let a = &Aimpl as &dyn A;
+
+    assert!(*a == Foo);
+}
diff --git a/src/test/ui/traits/issue-71136.rs b/src/test/ui/traits/issue-71136.rs
new file mode 100644 (file)
index 0000000..b21756e
--- /dev/null
@@ -0,0 +1,8 @@
+struct Foo(u8);
+
+#[derive(Clone)]
+struct FooHolster {
+    the_foos: Vec<Foo>, //~ERROR Clone
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/issue-71136.stderr b/src/test/ui/traits/issue-71136.stderr
new file mode 100644 (file)
index 0000000..ba47fdb
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0277]: the trait bound `Foo: Clone` is not satisfied
+  --> $DIR/issue-71136.rs:5:5
+   |
+LL |     the_foos: Vec<Foo>,
+   |     ^^^^^^^^^^^^^^^^^^ expected an implementor of trait `Clone`
+   |
+   = note: required because of the requirements on the impl of `Clone` for `Vec<Foo>`
+   = note: required by `clone`
+   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/issue-9394-inherited-calls.rs b/src/test/ui/traits/issue-9394-inherited-calls.rs
new file mode 100644 (file)
index 0000000..cc0dd4f
--- /dev/null
@@ -0,0 +1,62 @@
+// run-pass
+
+trait Base: Base2 + Base3{
+    fn foo(&self) -> String;
+    fn foo1(&self) -> String;
+    fn foo2(&self) -> String{
+        "base foo2".to_string()
+    }
+}
+
+trait Base2: Base3{
+    fn baz(&self) -> String;
+}
+
+trait Base3{
+    fn root(&self) -> String;
+}
+
+trait Super: Base{
+    fn bar(&self) -> String;
+}
+
+struct X;
+
+impl Base for X {
+    fn foo(&self) -> String{
+        "base foo".to_string()
+    }
+    fn foo1(&self) -> String{
+        "base foo1".to_string()
+    }
+
+}
+
+impl Base2 for X {
+    fn baz(&self) -> String{
+        "base2 baz".to_string()
+    }
+}
+
+impl Base3 for X {
+    fn root(&self) -> String{
+        "base3 root".to_string()
+    }
+}
+
+impl Super for X {
+    fn bar(&self) -> String{
+        "super bar".to_string()
+    }
+}
+
+pub fn main() {
+    let n = X;
+    let s = &n as &dyn Super;
+    assert_eq!(s.bar(),"super bar".to_string());
+    assert_eq!(s.foo(),"base foo".to_string());
+    assert_eq!(s.foo1(),"base foo1".to_string());
+    assert_eq!(s.foo2(),"base foo2".to_string());
+    assert_eq!(s.baz(),"base2 baz".to_string());
+    assert_eq!(s.root(),"base3 root".to_string());
+}
diff --git a/src/test/ui/traits/issue-9394-inherited-trait-calls.rs b/src/test/ui/traits/issue-9394-inherited-trait-calls.rs
deleted file mode 100644 (file)
index cc0dd4f..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// run-pass
-
-trait Base: Base2 + Base3{
-    fn foo(&self) -> String;
-    fn foo1(&self) -> String;
-    fn foo2(&self) -> String{
-        "base foo2".to_string()
-    }
-}
-
-trait Base2: Base3{
-    fn baz(&self) -> String;
-}
-
-trait Base3{
-    fn root(&self) -> String;
-}
-
-trait Super: Base{
-    fn bar(&self) -> String;
-}
-
-struct X;
-
-impl Base for X {
-    fn foo(&self) -> String{
-        "base foo".to_string()
-    }
-    fn foo1(&self) -> String{
-        "base foo1".to_string()
-    }
-
-}
-
-impl Base2 for X {
-    fn baz(&self) -> String{
-        "base2 baz".to_string()
-    }
-}
-
-impl Base3 for X {
-    fn root(&self) -> String{
-        "base3 root".to_string()
-    }
-}
-
-impl Super for X {
-    fn bar(&self) -> String{
-        "super bar".to_string()
-    }
-}
-
-pub fn main() {
-    let n = X;
-    let s = &n as &dyn Super;
-    assert_eq!(s.bar(),"super bar".to_string());
-    assert_eq!(s.foo(),"base foo".to_string());
-    assert_eq!(s.foo1(),"base foo1".to_string());
-    assert_eq!(s.foo2(),"base foo2".to_string());
-    assert_eq!(s.baz(),"base2 baz".to_string());
-    assert_eq!(s.root(),"base3 root".to_string());
-}
diff --git a/src/test/ui/traits/item-inside-macro.rs b/src/test/ui/traits/item-inside-macro.rs
new file mode 100644 (file)
index 0000000..54bf872
--- /dev/null
@@ -0,0 +1,30 @@
+// run-pass
+// Issue #34183
+
+macro_rules! foo {
+    () => {
+        fn foo() { }
+    }
+}
+
+macro_rules! bar {
+    () => {
+        fn bar();
+    }
+}
+
+trait Bleh {
+    foo!();
+    bar!();
+}
+
+struct Test;
+
+impl Bleh for Test {
+    fn bar() {}
+}
+
+fn main() {
+    Test::bar();
+    Test::foo();
+}
diff --git a/src/test/ui/traits/item-privacy.rs b/src/test/ui/traits/item-privacy.rs
new file mode 100644 (file)
index 0000000..1ea1d65
--- /dev/null
@@ -0,0 +1,134 @@
+#![feature(associated_type_defaults)]
+
+struct S;
+
+mod method {
+    trait A {
+        fn a(&self) { }
+    }
+
+    pub trait B {
+        fn b(&self) { }
+    }
+
+    pub trait C: A + B {
+        fn c(&self) { }
+    }
+
+    impl A for ::S {}
+    impl B for ::S {}
+    impl C for ::S {}
+}
+
+mod assoc_const {
+    trait A {
+        const A: u8 = 0;
+    }
+
+    pub trait B {
+        const B: u8 = 0;
+    }
+
+    pub trait C: A + B {
+        const C: u8 = 0;
+    }
+
+    impl A for ::S {}
+    impl B for ::S {}
+    impl C for ::S {}
+}
+
+mod assoc_ty {
+    trait A {
+        type A = u8;
+    }
+
+    pub trait B {
+        type B = u8;
+    }
+
+    pub trait C: A + B {
+        type C = u8;
+    }
+
+    impl A for ::S {}
+    impl B for ::S {}
+    impl C for ::S {}
+}
+
+fn check_method() {
+    // A is private
+    // B is pub, not in scope
+    // C : A + B is pub, in scope
+    use method::C;
+
+    // Methods, method call
+    // a, b, c are resolved as trait items, their traits need to be in scope
+    S.a(); //~ ERROR no method named `a` found
+    S.b(); //~ ERROR no method named `b` found
+    S.c(); // OK
+    // a, b, c are resolved as inherent items, their traits don't need to be in scope
+    let c = &S as &dyn C;
+    c.a(); //~ ERROR associated function `a` is private
+    c.b(); // OK
+    c.c(); // OK
+
+    // Methods, UFCS
+    // a, b, c are resolved as trait items, their traits need to be in scope
+    S::a(&S);
+    //~^ ERROR no function or associated item named `a` found
+    S::b(&S);
+    //~^ ERROR no function or associated item named `b` found
+    S::c(&S); // OK
+    // a, b, c are resolved as inherent items, their traits don't need to be in scope
+    C::a(&S); //~ ERROR associated function `a` is private
+    C::b(&S); // OK
+    C::c(&S); // OK
+}
+
+fn check_assoc_const() {
+    // A is private
+    // B is pub, not in scope
+    // C : A + B is pub, in scope
+    use assoc_const::C;
+
+    // Associated constants
+    // A, B, C are resolved as trait items, their traits need to be in scope
+    S::A; //~ ERROR no associated item named `A` found
+    S::B; //~ ERROR no associated item named `B` found
+    S::C; // OK
+    // A, B, C are resolved as inherent items, their traits don't need to be in scope
+    C::A; //~ ERROR associated constant `A` is private
+          //~^ ERROR the trait `assoc_const::C` cannot be made into an object
+    C::B; // ERROR the trait `assoc_const::C` cannot be made into an object
+    C::C; // OK
+}
+
+fn check_assoc_ty<T: assoc_ty::C>() {
+    // A is private
+    // B is pub, not in scope
+    // C : A + B is pub, in scope
+    use assoc_ty::C;
+
+    // Associated types
+    // A, B, C are resolved as trait items, their traits need to be in scope, not implemented yet
+    let _: S::A; //~ ERROR ambiguous associated type
+    let _: S::B; //~ ERROR ambiguous associated type
+    let _: S::C; //~ ERROR ambiguous associated type
+    // A, B, C are resolved as inherent items, their traits don't need to be in scope
+    let _: T::A; //~ ERROR associated type `A` is private
+    let _: T::B; // OK
+    let _: T::C; // OK
+
+    // Associated types, bindings
+    let _: dyn assoc_ty::B<
+        B = u8, // OK
+    >;
+    let _: dyn C<
+        A = u8, //~ ERROR associated type `A` is private
+        B = u8, // OK
+        C = u8, // OK
+    >;
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/item-privacy.stderr b/src/test/ui/traits/item-privacy.stderr
new file mode 100644 (file)
index 0000000..6fd8214
--- /dev/null
@@ -0,0 +1,168 @@
+error[E0599]: no method named `a` found for struct `S` in the current scope
+  --> $DIR/item-privacy.rs:67:7
+   |
+LL | struct S;
+   | --------- method `a` not found for this
+...
+LL |     S.a();
+   |       ^ method not found in `S`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+note: `method::A` defines an item `a`, perhaps you need to implement it
+  --> $DIR/item-privacy.rs:6:5
+   |
+LL |     trait A {
+   |     ^^^^^^^
+
+error[E0599]: no method named `b` found for struct `S` in the current scope
+  --> $DIR/item-privacy.rs:68:7
+   |
+LL | struct S;
+   | --------- method `b` not found for this
+...
+LL |     S.b();
+   |       ^ method not found in `S`
+   |
+   = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+   |
+LL | use method::B;
+   |
+
+error[E0624]: associated function `a` is private
+  --> $DIR/item-privacy.rs:72:7
+   |
+LL |     c.a();
+   |       ^ private associated function
+
+error[E0599]: no function or associated item named `a` found for struct `S` in the current scope
+  --> $DIR/item-privacy.rs:78:8
+   |
+LL | struct S;
+   | --------- function or associated item `a` not found for this
+...
+LL |     S::a(&S);
+   |        ^ function or associated item not found in `S`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+note: `method::A` defines an item `a`, perhaps you need to implement it
+  --> $DIR/item-privacy.rs:6:5
+   |
+LL |     trait A {
+   |     ^^^^^^^
+
+error[E0599]: no function or associated item named `b` found for struct `S` in the current scope
+  --> $DIR/item-privacy.rs:80:8
+   |
+LL | struct S;
+   | --------- function or associated item `b` not found for this
+...
+LL |     S::b(&S);
+   |        ^ function or associated item not found in `S`
+   |
+   = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+   |
+LL | use method::B;
+   |
+
+error[E0624]: associated function `a` is private
+  --> $DIR/item-privacy.rs:84:8
+   |
+LL |     C::a(&S);
+   |        ^ private associated function
+
+error[E0599]: no associated item named `A` found for struct `S` in the current scope
+  --> $DIR/item-privacy.rs:97:8
+   |
+LL | struct S;
+   | --------- associated item `A` not found for this
+...
+LL |     S::A;
+   |        ^ associated item not found in `S`
+   |
+   = help: items from traits can only be used if the trait is implemented and in scope
+note: `assoc_const::A` defines an item `A`, perhaps you need to implement it
+  --> $DIR/item-privacy.rs:24:5
+   |
+LL |     trait A {
+   |     ^^^^^^^
+
+error[E0599]: no associated item named `B` found for struct `S` in the current scope
+  --> $DIR/item-privacy.rs:98:8
+   |
+LL | struct S;
+   | --------- associated item `B` not found for this
+...
+LL |     S::B;
+   |        ^ associated item not found in `S`
+   |
+   = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+   |
+LL | use assoc_const::B;
+   |
+
+error[E0624]: associated constant `A` is private
+  --> $DIR/item-privacy.rs:101:8
+   |
+LL |     C::A;
+   |        ^ private associated constant
+
+error[E0038]: the trait `assoc_const::C` cannot be made into an object
+  --> $DIR/item-privacy.rs:101:5
+   |
+LL |     C::A;
+   |     ^^^^ `assoc_const::C` cannot be made into an object
+   |
+   = help: consider moving `C` to another trait
+   = help: consider moving `B` to another trait
+   = help: consider moving `A` to another trait
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/item-privacy.rs:25:15
+   |
+LL |         const A: u8 = 0;
+   |               ^ ...because it contains this associated `const`
+...
+LL |         const B: u8 = 0;
+   |               ^ ...because it contains this associated `const`
+...
+LL |     pub trait C: A + B {
+   |               - this trait cannot be made into an object...
+LL |         const C: u8 = 0;
+   |               ^ ...because it contains this associated `const`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/item-privacy.rs:115:12
+   |
+LL |     let _: S::A;
+   |            ^^^^ help: use fully-qualified syntax: `<S as Trait>::A`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/item-privacy.rs:116:12
+   |
+LL |     let _: S::B;
+   |            ^^^^ help: use fully-qualified syntax: `<S as Trait>::B`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/item-privacy.rs:117:12
+   |
+LL |     let _: S::C;
+   |            ^^^^ help: use fully-qualified syntax: `<S as Trait>::C`
+
+error: associated type `A` is private
+  --> $DIR/item-privacy.rs:119:12
+   |
+LL |     let _: T::A;
+   |            ^^^^ private associated type
+
+error: associated type `A` is private
+  --> $DIR/item-privacy.rs:128:9
+   |
+LL |         A = u8,
+   |         ^^^^^^ private associated type
+
+error: aborting due to 15 previous errors
+
+Some errors have detailed explanations: E0038, E0223, E0599, E0624.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/kindck-owned-contains-1.rs b/src/test/ui/traits/kindck-owned-contains-1.rs
new file mode 100644 (file)
index 0000000..23b91f9
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(non_snake_case)]
+#![allow(non_camel_case_types)]
+
+#![feature(box_syntax)]
+
+trait repeat<A> { fn get(&self) -> A; }
+
+impl<A:Clone + 'static> repeat<A> for Box<A> {
+    fn get(&self) -> A {
+        (**self).clone()
+    }
+}
+
+fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
+    box v as Box<dyn repeat<A>+'static> // No
+}
+
+pub fn main() {
+    let x = 3;
+    let y = repeater(box x);
+    assert_eq!(x, y.get());
+}
diff --git a/src/test/ui/traits/kindck-owned-trait-contains-1.rs b/src/test/ui/traits/kindck-owned-trait-contains-1.rs
deleted file mode 100644 (file)
index 23b91f9..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-#![allow(non_snake_case)]
-#![allow(non_camel_case_types)]
-
-#![feature(box_syntax)]
-
-trait repeat<A> { fn get(&self) -> A; }
-
-impl<A:Clone + 'static> repeat<A> for Box<A> {
-    fn get(&self) -> A {
-        (**self).clone()
-    }
-}
-
-fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<dyn repeat<A>+'static> {
-    box v as Box<dyn repeat<A>+'static> // No
-}
-
-pub fn main() {
-    let x = 3;
-    let y = repeater(box x);
-    assert_eq!(x, y.get());
-}
diff --git a/src/test/ui/traits/matching-lifetimes.rs b/src/test/ui/traits/matching-lifetimes.rs
new file mode 100644 (file)
index 0000000..1430dc6
--- /dev/null
@@ -0,0 +1,20 @@
+// Tests that the trait matching code takes lifetime parameters into account.
+// (Issue #15517.)
+
+struct Foo<'a,'b> {
+    x: &'a isize,
+    y: &'b isize,
+}
+
+trait Tr : Sized {
+    fn foo(x: Self) {}
+}
+
+impl<'a,'b> Tr for Foo<'a,'b> {
+    fn foo(x: Foo<'b,'a>) {
+        //~^ ERROR method not compatible with trait
+        //~^^ ERROR method not compatible with trait
+    }
+}
+
+fn main(){}
diff --git a/src/test/ui/traits/matching-lifetimes.stderr b/src/test/ui/traits/matching-lifetimes.stderr
new file mode 100644 (file)
index 0000000..5c28d40
--- /dev/null
@@ -0,0 +1,41 @@
+error[E0308]: method not compatible with trait
+  --> $DIR/matching-lifetimes.rs:14:5
+   |
+LL |     fn foo(x: Foo<'b,'a>) {
+   |     ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
+   |
+   = note: expected fn pointer `fn(Foo<'a, 'b>)`
+              found fn pointer `fn(Foo<'b, 'a>)`
+note: the lifetime `'b` as defined on the impl at 13:9...
+  --> $DIR/matching-lifetimes.rs:13:9
+   |
+LL | impl<'a,'b> Tr for Foo<'a,'b> {
+   |         ^^
+note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 13:6
+  --> $DIR/matching-lifetimes.rs:13:6
+   |
+LL | impl<'a,'b> Tr for Foo<'a,'b> {
+   |      ^^
+
+error[E0308]: method not compatible with trait
+  --> $DIR/matching-lifetimes.rs:14:5
+   |
+LL |     fn foo(x: Foo<'b,'a>) {
+   |     ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
+   |
+   = note: expected fn pointer `fn(Foo<'a, 'b>)`
+              found fn pointer `fn(Foo<'b, 'a>)`
+note: the lifetime `'a` as defined on the impl at 13:6...
+  --> $DIR/matching-lifetimes.rs:13:6
+   |
+LL | impl<'a,'b> Tr for Foo<'a,'b> {
+   |      ^^
+note: ...does not necessarily outlive the lifetime `'b` as defined on the impl at 13:9
+  --> $DIR/matching-lifetimes.rs:13:9
+   |
+LL | impl<'a,'b> Tr for Foo<'a,'b> {
+   |         ^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/method-private.rs b/src/test/ui/traits/method-private.rs
new file mode 100644 (file)
index 0000000..4cd1848
--- /dev/null
@@ -0,0 +1,20 @@
+mod inner {
+    pub trait Bar {
+        fn method(&self);
+    }
+
+    pub struct Foo;
+
+    impl Foo {
+        fn method(&self) {}
+    }
+
+    impl Bar for Foo {
+        fn method(&self) {}
+    }
+}
+
+fn main() {
+    let foo = inner::Foo;
+    foo.method(); //~ ERROR is private
+}
diff --git a/src/test/ui/traits/method-private.stderr b/src/test/ui/traits/method-private.stderr
new file mode 100644 (file)
index 0000000..99f330b
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0624]: associated function `method` is private
+  --> $DIR/method-private.rs:19:9
+   |
+LL |     foo.method();
+   |         ^^^^^^ private associated function
+   |
+   = help: items from traits can only be used if the trait is in scope
+help: the following trait is implemented but not in scope; perhaps add a `use` for it:
+   |
+LL | use inner::Bar;
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0624`.
diff --git a/src/test/ui/traits/multidispatch-bad.rs b/src/test/ui/traits/multidispatch-bad.rs
new file mode 100644 (file)
index 0000000..b625b96
--- /dev/null
@@ -0,0 +1,22 @@
+// Test that we detect an illegal combination of types.
+
+trait Convert<Target> {
+    fn convert(&self) -> Target;
+}
+
+impl Convert<u32> for i32 {
+    fn convert(&self) -> u32 {
+        *self as u32
+    }
+}
+
+fn test<T,U>(_: T, _: U)
+where T : Convert<U>
+{
+}
+
+fn a() {
+    test(22i32, 44i32); //~ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/multidispatch-bad.stderr b/src/test/ui/traits/multidispatch-bad.stderr
new file mode 100644 (file)
index 0000000..8d4813c
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+  --> $DIR/multidispatch-bad.rs:19:17
+   |
+LL |     test(22i32, 44i32);
+   |                 ^^^^^ expected `u32`, found `i32`
+   |
+help: change the type of the numeric literal from `i32` to `u32`
+   |
+LL |     test(22i32, 44u32);
+   |                 ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/multidispatch-convert-ambig-dest.rs b/src/test/ui/traits/multidispatch-convert-ambig-dest.rs
new file mode 100644 (file)
index 0000000..58cb69a
--- /dev/null
@@ -0,0 +1,30 @@
+// Check that we get an error in a multidisptach scenario where the
+// set of impls is ambiguous.
+
+trait Convert<Target> {
+    fn convert(&self) -> Target;
+}
+
+impl Convert<i8> for i32 {
+    fn convert(&self) -> i8 {
+        *self as i8
+    }
+}
+
+impl Convert<i16> for i32 {
+    fn convert(&self) -> i16 {
+        *self as i16
+    }
+}
+
+fn test<T,U>(_: T, _: U)
+where T : Convert<U>
+{
+}
+
+fn a() {
+    test(22, std::default::Default::default());
+    //~^ ERROR type annotations needed [E0282]
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr b/src/test/ui/traits/multidispatch-convert-ambig-dest.stderr
new file mode 100644 (file)
index 0000000..62f5f5a
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0282]: type annotations needed
+  --> $DIR/multidispatch-convert-ambig-dest.rs:26:5
+   |
+LL |     test(22, std::default::Default::default());
+   |     ^^^^ cannot infer type for type parameter `U` declared on the function `test`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/traits/multidispatch-infer-convert-target.rs b/src/test/ui/traits/multidispatch-infer-convert-target.rs
new file mode 100644 (file)
index 0000000..626e1ae
--- /dev/null
@@ -0,0 +1,36 @@
+// run-pass
+// Test that we can infer the Target based on the Self or vice versa.
+
+
+use std::mem;
+
+trait Convert<Target> {
+    fn convert(&self) -> Target;
+}
+
+impl Convert<u32> for i16 {
+    fn convert(&self) -> u32 {
+        *self as u32
+    }
+}
+
+impl Convert<i16> for u32 {
+    fn convert(&self) -> i16 {
+        *self as i16
+    }
+}
+
+fn test<T,U>(_: T, _: U, t_size: usize, u_size: usize)
+where T : Convert<U>
+{
+    assert_eq!(mem::size_of::<T>(), t_size);
+    assert_eq!(mem::size_of::<U>(), u_size);
+}
+
+fn main() {
+    // T = i16, U = u32
+    test(22_i16, Default::default(),  2, 4);
+
+    // T = u32, U = i16
+    test(22_u32, Default::default(), 4, 2);
+}
diff --git a/src/test/ui/traits/multiple-trait-bounds.rs b/src/test/ui/traits/multiple-trait-bounds.rs
deleted file mode 100644 (file)
index 868b334..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-fn f<T:PartialEq + PartialOrd>(_: T) {
-}
-
-pub fn main() {
-    f(3);
-}
diff --git a/src/test/ui/traits/object/auto-dedup-in-impl.rs b/src/test/ui/traits/object/auto-dedup-in-impl.rs
new file mode 100644 (file)
index 0000000..85698f1
--- /dev/null
@@ -0,0 +1,19 @@
+// Checks to make sure that `dyn Trait + Send` and `dyn Trait + Send + Send` are the same type.
+// Issue: #47010
+
+struct Struct;
+impl Trait for Struct {}
+trait Trait {}
+
+type Send1 = dyn Trait + Send;
+type Send2 = dyn Trait + Send + Send;
+
+fn main () {}
+
+impl dyn Trait + Send {
+    fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test`
+}
+
+impl dyn Trait + Send + Send {
+    fn test(&self) { println!("two"); }
+}
diff --git a/src/test/ui/traits/object/auto-dedup-in-impl.stderr b/src/test/ui/traits/object/auto-dedup-in-impl.stderr
new file mode 100644 (file)
index 0000000..5f13c78
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0592]: duplicate definitions with name `test`
+  --> $DIR/auto-dedup-in-impl.rs:14:5
+   |
+LL |     fn test(&self) { println!("one"); }
+   |     ^^^^^^^^^^^^^^ duplicate definitions for `test`
+...
+LL |     fn test(&self) { println!("two"); }
+   |     -------------- other definition for `test`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/traits/object/auto-dedup.rs b/src/test/ui/traits/object/auto-dedup.rs
new file mode 100644 (file)
index 0000000..39d25eb
--- /dev/null
@@ -0,0 +1,46 @@
+// run-pass
+
+#![allow(unused_assignments)]
+
+// Test that duplicate auto trait bounds in trait objects don't create new types.
+#[allow(unused_assignments)]
+use std::marker::Send as SendAlias;
+
+// A dummy trait for the non-auto trait.
+trait Trait {}
+
+// A dummy struct to implement `Trait` and `Send`.
+struct Struct;
+
+impl Trait for Struct {}
+
+// These three functions should be equivalent.
+fn takes_dyn_trait_send(_: Box<dyn Trait + Send>) {}
+fn takes_dyn_trait_send_send(_: Box<dyn Trait + Send + Send>) {}
+fn takes_dyn_trait_send_sendalias(_: Box<dyn Trait + Send + SendAlias>) {}
+
+impl dyn Trait + Send + Send {
+    fn do_nothing(&self) {}
+}
+
+fn main() {
+    // 1. Moving into a variable with more `Send`s and back.
+    let mut dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
+    let dyn_trait_send_send: Box<dyn Trait + Send + Send> = dyn_trait_send;
+    dyn_trait_send = dyn_trait_send_send;
+
+    // 2. Calling methods with different number of `Send`s.
+    let dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
+    takes_dyn_trait_send_send(dyn_trait_send);
+
+    let dyn_trait_send_send = Box::new(Struct) as Box<dyn Trait + Send + Send>;
+    takes_dyn_trait_send(dyn_trait_send_send);
+
+    // 3. Aliases to the trait are transparent.
+    let dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
+    takes_dyn_trait_send_sendalias(dyn_trait_send);
+
+    // 4. Calling an impl that duplicates an auto trait.
+    let dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
+    dyn_trait_send.do_nothing();
+}
diff --git a/src/test/ui/traits/object/bounds-cycle-1.rs b/src/test/ui/traits/object/bounds-cycle-1.rs
new file mode 100644 (file)
index 0000000..3146764
--- /dev/null
@@ -0,0 +1,24 @@
+// Check that we don't have a cycle when we try to normalize `Self::U` in the
+// bound below.
+
+// check-pass
+
+trait Is {
+    type T;
+}
+
+impl<U> Is for U {
+    type T = U;
+}
+
+trait Obj {
+    type U: Is<T = Self::U>;
+}
+
+fn is_obj<T: ?Sized + Obj>(_: &T) {}
+
+fn f(x: &dyn Obj<U = i32>) {
+    is_obj(x)
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/object/bounds-cycle-2.rs b/src/test/ui/traits/object/bounds-cycle-2.rs
new file mode 100644 (file)
index 0000000..4c1df38
--- /dev/null
@@ -0,0 +1,28 @@
+// Check that we don't have a cycle when we try to normalize `Self::V` in the
+// bound below.
+
+// check-pass
+
+trait Is {
+    type T;
+}
+
+impl<U> Is for U {
+    type T = U;
+}
+
+trait Super {
+    type V;
+}
+
+trait Obj: Super {
+    type U: Is<T = Self::V>;
+}
+
+fn is_obj<T: ?Sized + Obj>(_: &T) {}
+
+fn f(x: &dyn Obj<U = i32, V = i32>) {
+    is_obj(x)
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/object/bounds-cycle-3.rs b/src/test/ui/traits/object/bounds-cycle-3.rs
new file mode 100644 (file)
index 0000000..55726a5
--- /dev/null
@@ -0,0 +1,25 @@
+// Check that we don't have a cycle when we try to normalize `Self::V` in the
+// bound below.
+
+// check-pass
+
+trait Is {
+    type T;
+}
+
+impl<U> Is for U {
+    type T = U;
+}
+
+trait Obj {
+    type U: Is<T = Self::V>;
+    type V;
+}
+
+fn is_obj<T: ?Sized + Obj>(_: &T) {}
+
+fn f(x: &dyn Obj<U = i32, V = i32>) {
+    is_obj(x)
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/object/bounds-cycle-4.rs b/src/test/ui/traits/object/bounds-cycle-4.rs
new file mode 100644 (file)
index 0000000..f83cb75
--- /dev/null
@@ -0,0 +1,25 @@
+// Check that we don't have a cycle when we try to normalize `Self::U` in the
+// bound below. Make sure that having a lifetime on the trait object doesn't break things
+
+// check-pass
+
+trait Is {
+    type T;
+}
+
+impl<U> Is for U {
+    type T = U;
+}
+
+trait Obj<'a> {
+    type U: Is<T = Self::V>;
+    type V;
+}
+
+fn is_obj<'a, T: ?Sized + Obj<'a>>(_: &T) {}
+
+fn f<'a>(x: &dyn Obj<'a, U = i32, V = i32>) {
+    is_obj(x)
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/object/exclusion.rs b/src/test/ui/traits/object/exclusion.rs
new file mode 100644 (file)
index 0000000..0b8b0e2
--- /dev/null
@@ -0,0 +1,19 @@
+// run-pass
+trait Future: 'static {
+    // The requirement for Self: Sized must prevent instantiation of
+    // Future::forget in vtables, otherwise there's an infinite type
+    // recursion through <Map<...> as Future>::forget.
+    fn forget(self) where Self: Sized {
+        Box::new(Map(self)) as Box<dyn Future>;
+    }
+}
+
+struct Map<A>(A);
+impl<A: Future> Future for Map<A> {}
+
+pub struct Promise;
+impl Future for Promise {}
+
+fn main() {
+    Promise.forget();
+}
diff --git a/src/test/ui/traits/object/generics.rs b/src/test/ui/traits/object/generics.rs
new file mode 100644 (file)
index 0000000..c187543
--- /dev/null
@@ -0,0 +1,43 @@
+// run-pass
+// test for #8664
+
+#![feature(box_syntax)]
+
+use std::marker;
+
+pub trait Trait2<A> {
+    fn doit(&self) -> A;
+}
+
+pub struct Impl<A1, A2, A3> {
+    m1: marker::PhantomData<(A1,A2,A3)>,
+    /*
+     * With A2 we get the ICE:
+     * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1',
+     * src/librustc/middle/subst.rs:58
+     */
+    t: Box<dyn Trait2<A2>+'static>
+}
+
+impl<A1, A2, A3> Impl<A1, A2, A3> {
+    pub fn step(&self) {
+        self.t.doit();
+    }
+}
+
+// test for #8601
+
+enum Type<T> { Constant(T) }
+
+trait Trait<K,V> {
+    fn method(&self, _: Type<(K,V)>) -> isize;
+}
+
+impl<V> Trait<u8,V> for () {
+    fn method(&self, _x: Type<(u8,V)>) -> isize { 0 }
+}
+
+pub fn main() {
+    let a = box () as Box<dyn Trait<u8, u8>>;
+    assert_eq!(a.method(Type::Constant((1, 2))), 0);
+}
diff --git a/src/test/ui/traits/object/lifetime-first.rs b/src/test/ui/traits/object/lifetime-first.rs
new file mode 100644 (file)
index 0000000..33757cb
--- /dev/null
@@ -0,0 +1,13 @@
+// run-pass
+use std::fmt::Display;
+
+static BYTE: u8 = 33;
+
+fn main() {
+    let x: &(dyn 'static + Display) = &BYTE;
+    let y: Box<dyn 'static + Display> = Box::new(BYTE);
+    let xstr = format!("{}", x);
+    let ystr = format!("{}", y);
+    assert_eq!(xstr, "33");
+    assert_eq!(ystr, "33");
+}
diff --git a/src/test/ui/traits/object/macro-matcher.rs b/src/test/ui/traits/object/macro-matcher.rs
new file mode 100644 (file)
index 0000000..9109787
--- /dev/null
@@ -0,0 +1,12 @@
+// `ty` matcher accepts trait object types
+
+macro_rules! m {
+    ($t: ty) => ( let _: $t; )
+}
+
+fn main() {
+    m!(dyn Copy + Send + 'static);
+    //~^ ERROR the trait `Copy` cannot be made into an object
+    m!(dyn 'static + Send);
+    m!(dyn 'static +); //~ ERROR at least one trait is required for an object type
+}
diff --git a/src/test/ui/traits/object/macro-matcher.stderr b/src/test/ui/traits/object/macro-matcher.stderr
new file mode 100644 (file)
index 0000000..6d1e236
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/macro-matcher.rs:11:8
+   |
+LL |     m!(dyn 'static +);
+   |        ^^^^^^^^^^^^^
+
+error[E0038]: the trait `Copy` cannot be made into an object
+  --> $DIR/macro-matcher.rs:8:8
+   |
+LL |     m!(dyn Copy + Send + 'static);
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object
+   |
+   = note: the trait cannot be made into an object because it requires `Self: Sized`
+   = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0038, E0224.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/object/safety.rs b/src/test/ui/traits/object/safety.rs
new file mode 100644 (file)
index 0000000..f43d332
--- /dev/null
@@ -0,0 +1,17 @@
+// Check that static methods are not object-safe.
+
+trait Tr {
+    fn foo();
+    fn bar(&self) { }
+}
+
+struct St;
+
+impl Tr for St {
+    fn foo() {}
+}
+
+fn main() {
+    let _: &dyn Tr = &St; //~ ERROR E0038
+    //~^ ERROR E0038
+}
diff --git a/src/test/ui/traits/object/safety.stderr b/src/test/ui/traits/object/safety.stderr
new file mode 100644 (file)
index 0000000..6784689
--- /dev/null
@@ -0,0 +1,49 @@
+error[E0038]: the trait `Tr` cannot be made into an object
+  --> $DIR/safety.rs:15:22
+   |
+LL |     let _: &dyn Tr = &St;
+   |                      ^^^ `Tr` cannot be made into an object
+   |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/safety.rs:4:8
+   |
+LL | trait Tr {
+   |       -- this trait cannot be made into an object...
+LL |     fn foo();
+   |        ^^^ ...because associated function `foo` has no `self` parameter
+   = note: required because of the requirements on the impl of `CoerceUnsized<&dyn Tr>` for `&St`
+   = note: required by cast to type `&dyn Tr`
+help: consider turning `foo` into a method by giving it a `&self` argument
+   |
+LL |     fn foo(&self);
+   |            ^^^^^
+help: alternatively, consider constraining `foo` so it does not apply to trait objects
+   |
+LL |     fn foo() where Self: Sized;
+   |              ^^^^^^^^^^^^^^^^^
+
+error[E0038]: the trait `Tr` cannot be made into an object
+  --> $DIR/safety.rs:15:12
+   |
+LL |     let _: &dyn Tr = &St;
+   |            ^^^^^^^ `Tr` cannot be made into an object
+   |
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/safety.rs:4:8
+   |
+LL | trait Tr {
+   |       -- this trait cannot be made into an object...
+LL |     fn foo();
+   |        ^^^ ...because associated function `foo` has no `self` parameter
+help: consider turning `foo` into a method by giving it a `&self` argument
+   |
+LL |     fn foo(&self);
+   |            ^^^^^
+help: alternatively, consider constraining `foo` so it does not apply to trait objects
+   |
+LL |     fn foo() where Self: Sized;
+   |              ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/object/supertrait-lifetime-bound.rs b/src/test/ui/traits/object/supertrait-lifetime-bound.rs
new file mode 100644 (file)
index 0000000..9d83472
--- /dev/null
@@ -0,0 +1,16 @@
+// check-pass
+
+use std::any::Any;
+
+trait A<T>: Any {
+    fn m(&self) {}
+}
+
+impl<S, T: 'static> A<S> for T {}
+
+fn call_obj<'a>() {
+    let obj: &dyn A<&'a ()> = &();
+    obj.m();
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/object/vs-lifetime-2.rs b/src/test/ui/traits/object/vs-lifetime-2.rs
new file mode 100644 (file)
index 0000000..0b33dc7
--- /dev/null
@@ -0,0 +1,11 @@
+// A few contrived examples where lifetime should (or should not) be parsed as an object type.
+// Lifetimes parsed as types are still rejected later by semantic checks.
+
+// `'static` is a lifetime, `'static +` is a type, `'a` is a type
+fn g() where
+    'static: 'static,
+    dyn 'static +: 'static + Copy,
+    //~^ ERROR at least one trait is required for an object type
+{}
+
+fn main() {}
diff --git a/src/test/ui/traits/object/vs-lifetime-2.stderr b/src/test/ui/traits/object/vs-lifetime-2.stderr
new file mode 100644 (file)
index 0000000..9b8e793
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/vs-lifetime-2.rs:7:5
+   |
+LL |     dyn 'static +: 'static + Copy,
+   |     ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0224`.
diff --git a/src/test/ui/traits/object/vs-lifetime.rs b/src/test/ui/traits/object/vs-lifetime.rs
new file mode 100644 (file)
index 0000000..e49d276
--- /dev/null
@@ -0,0 +1,17 @@
+// A few contrived examples where lifetime should (or should not) be parsed as an object type.
+// Lifetimes parsed as types are still rejected later by semantic checks.
+
+struct S<'a, T>(&'a u8, T);
+
+fn main() {
+    // `'static` is a lifetime argument, `'static +` is a type argument
+    let _: S<'static, u8>;
+    let _: S<'static, dyn 'static +>;
+    //~^ at least one trait is required for an object type
+    let _: S<'static, 'static>;
+    //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+    //~| ERROR this struct takes 1 type argument but 0 type arguments were supplied
+    let _: S<dyn 'static +, 'static>;
+    //~^ ERROR type provided when a lifetime was expected
+    //~| ERROR at least one trait is required for an object type
+}
diff --git a/src/test/ui/traits/object/vs-lifetime.stderr b/src/test/ui/traits/object/vs-lifetime.stderr
new file mode 100644 (file)
index 0000000..6673472
--- /dev/null
@@ -0,0 +1,52 @@
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/vs-lifetime.rs:9:23
+   |
+LL |     let _: S<'static, dyn 'static +>;
+   |                       ^^^^^^^^^^^^^
+
+error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
+  --> $DIR/vs-lifetime.rs:11:12
+   |
+LL |     let _: S<'static, 'static>;
+   |            ^        --------- help: remove this lifetime argument
+   |            |
+   |            expected 1 lifetime argument
+   |
+note: struct defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/vs-lifetime.rs:4:8
+   |
+LL | struct S<'a, T>(&'a u8, T);
+   |        ^ --
+
+error[E0107]: this struct takes 1 type argument but 0 type arguments were supplied
+  --> $DIR/vs-lifetime.rs:11:12
+   |
+LL |     let _: S<'static, 'static>;
+   |            ^ expected 1 type argument
+   |
+note: struct defined here, with 1 type parameter: `T`
+  --> $DIR/vs-lifetime.rs:4:8
+   |
+LL | struct S<'a, T>(&'a u8, T);
+   |        ^     -
+help: add missing type argument
+   |
+LL |     let _: S<'static, 'static, T>;
+   |                              ^^^
+
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/vs-lifetime.rs:14:14
+   |
+LL |     let _: S<dyn 'static +, 'static>;
+   |              ^^^^^^^^^^^^^
+
+error[E0747]: type provided when a lifetime was expected
+  --> $DIR/vs-lifetime.rs:14:14
+   |
+LL |     let _: S<dyn 'static +, 'static>;
+   |              ^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0107, E0224, E0747.
+For more information about an error, try `rustc --explain E0107`.
diff --git a/src/test/ui/traits/object/with-lifetime-bound.rs b/src/test/ui/traits/object/with-lifetime-bound.rs
new file mode 100644 (file)
index 0000000..05aab5e
--- /dev/null
@@ -0,0 +1,34 @@
+// run-pass
+// Uncovered during work on new scoping rules for safe destructors
+// as an important use case to support properly.
+
+
+pub struct E<'a> {
+    pub f: &'a u8,
+}
+impl<'b> E<'b> {
+    pub fn m(&self) -> &'b u8 { self.f }
+}
+
+pub struct P<'c> {
+    pub g: &'c u8,
+}
+pub trait M {
+    fn n(&self) -> u8;
+}
+impl<'d> M for P<'d> {
+    fn n(&self) -> u8 { *self.g }
+}
+
+fn extension<'e>(x: &'e E<'e>) -> Box<dyn M+'e> {
+    loop {
+        let p = P { g: x.m() };
+        return Box::new(p) as Box<dyn M+'e>;
+    }
+}
+
+fn main() {
+    let w = E { f: &10 };
+    let o = extension(&w);
+    assert_eq!(o.n(), 10);
+}
diff --git a/src/test/ui/traits/object/with-self-in-projection-output-bad.rs b/src/test/ui/traits/object/with-self-in-projection-output-bad.rs
new file mode 100644 (file)
index 0000000..f34fa80
--- /dev/null
@@ -0,0 +1,50 @@
+// Regression test for #56288. Checks that if a supertrait defines an associated type
+// projection that references `Self`, then that associated type must still be explicitly
+// specified in the `dyn Trait` variant, since we don't know what `Self` is anymore.
+
+trait Base {
+    type Output;
+}
+
+trait Helper: Base<Output=<Self as Helper>::Target> {
+    type Target;
+}
+
+impl Base for u32
+{
+    type Output = i32;
+}
+
+impl Helper for u32
+{
+    type Target = i32;
+}
+
+trait ConstI32 {
+    type Out;
+}
+
+impl<T: ?Sized> ConstI32 for T {
+    type Out = i32;
+}
+
+// Test that you still need to manually give a projection type if the Output type
+// is normalizable.
+trait NormalizableHelper:
+    Base<Output=<Self as ConstI32>::Out>
+{
+    type Target;
+}
+
+impl NormalizableHelper for u32
+{
+    type Target = i32;
+}
+
+fn main() {
+    let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32);
+    //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
+
+    let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
+    //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
+}
diff --git a/src/test/ui/traits/object/with-self-in-projection-output-bad.stderr b/src/test/ui/traits/object/with-self-in-projection-output-bad.stderr
new file mode 100644 (file)
index 0000000..45978a8
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified
+  --> $DIR/with-self-in-projection-output-bad.rs:45:21
+   |
+LL |     type Output;
+   |     ------------ `Output` defined here
+...
+LL |     let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32);
+   |                     ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper<Target=i32, Output = Type>`
+
+error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified
+  --> $DIR/with-self-in-projection-output-bad.rs:48:21
+   |
+LL |     type Output;
+   |     ------------ `Output` defined here
+...
+LL |     let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
+   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `NormalizableHelper<Target=i32, Output = Type>`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0191`.
diff --git a/src/test/ui/traits/object/with-self-in-projection-output-good.rs b/src/test/ui/traits/object/with-self-in-projection-output-good.rs
new file mode 100644 (file)
index 0000000..d1b7bf6
--- /dev/null
@@ -0,0 +1,28 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+// Regression test related to #56288. Check that a supertrait projection (of
+// `Output`) that references `Self` can be ok if it is referencing a projection (of
+// `Self::Target`, in this case). Note that we still require the user to manually
+// specify both `Target` and `Output` for now.
+
+trait Base {
+    type Output;
+}
+
+trait Helper: Base<Output=<Self as Helper>::Target> {
+    type Target;
+}
+
+impl Base for u32
+{
+    type Output = i32;
+}
+
+impl Helper for u32
+{
+    type Target = i32;
+}
+
+fn main() {
+    let _x: Box<dyn Helper<Target=i32, Output=i32>> = Box::new(2u32);
+}
diff --git a/src/test/ui/traits/object/with-self-in-projection-output-repeated-supertrait.rs b/src/test/ui/traits/object/with-self-in-projection-output-repeated-supertrait.rs
new file mode 100644 (file)
index 0000000..39e8171
--- /dev/null
@@ -0,0 +1,51 @@
+// build-pass (FIXME(62277): could be check-pass?)
+
+// FIXME(eddyb) shorten the name so windows doesn't choke on it.
+#![crate_name = "trait_test"]
+
+// Regression test related to #56288. Check that a supertrait projection (of
+// `Output`) that references `Self` is ok if there is another occurrence of
+// the same supertrait that specifies the projection explicitly, even if
+// the projection's associated type is not explicitly specified in the object type.
+//
+// Note that in order for this to compile, we need the `Self`-referencing projection
+// to normalize fairly directly to a concrete type, otherwise the trait resolver
+// will hate us.
+//
+// There is a test in `trait-object-with-self-in-projection-output-bad.rs` that
+// having a normalizing, but `Self`-containing projection does not *by itself*
+// allow you to avoid writing the projected type (`Output`, in this example)
+// explicitly.
+
+trait ConstI32 {
+    type Out;
+}
+
+impl<T: ?Sized> ConstI32 for T {
+    type Out = i32;
+}
+
+trait Base {
+    type Output;
+}
+
+trait NormalizingHelper: Base<Output=<Self as ConstI32>::Out> + Base<Output=i32> {
+    type Target;
+}
+
+impl Base for u32
+{
+    type Output = i32;
+}
+
+impl NormalizingHelper for u32
+{
+    type Target = i32;
+}
+
+fn main() {
+    // Make sure this works both with and without the associated type
+    // being specified.
+    let _x: Box<dyn NormalizingHelper<Target=i32>> = Box::new(2u32);
+    let _y: Box<dyn NormalizingHelper<Target=i32, Output=i32>> = Box::new(2u32);
+}
diff --git a/src/test/ui/traits/param-without-lifetime-constraint.rs b/src/test/ui/traits/param-without-lifetime-constraint.rs
new file mode 100644 (file)
index 0000000..a79b74d
--- /dev/null
@@ -0,0 +1,20 @@
+struct Article {
+    proof_reader: ProofReader,
+}
+
+struct ProofReader {
+    name: String,
+}
+
+pub trait HaveRelationship<To> {
+    fn get_relation(&self) -> To;
+}
+
+impl HaveRelationship<&ProofReader> for Article {
+    fn get_relation(&self) -> &ProofReader {
+    //~^ ERROR `impl` item signature doesn't match `trait` item signature
+        &self.proof_reader
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/param-without-lifetime-constraint.stderr b/src/test/ui/traits/param-without-lifetime-constraint.stderr
new file mode 100644 (file)
index 0000000..763fb51
--- /dev/null
@@ -0,0 +1,19 @@
+error: `impl` item signature doesn't match `trait` item signature
+  --> $DIR/param-without-lifetime-constraint.rs:14:5
+   |
+LL |     fn get_relation(&self) -> To;
+   |     ----------------------------- expected `fn(&Article) -> &ProofReader`
+...
+LL |     fn get_relation(&self) -> &ProofReader {
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
+   |
+   = note: expected `fn(&Article) -> &ProofReader`
+              found `fn(&Article) -> &ProofReader`
+help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
+  --> $DIR/param-without-lifetime-constraint.rs:10:31
+   |
+LL |     fn get_relation(&self) -> To;
+   |                               ^^ consider borrowing this type parameter in the trait
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/traits/parameterized-trait-with-bounds.rs b/src/test/ui/traits/parameterized-trait-with-bounds.rs
deleted file mode 100644 (file)
index 832d4f6..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-#![allow(dead_code)]
-
-
-trait A<T> { fn get(self) -> T; }
-trait B<T, U> { fn get(self) -> (T,U); }
-trait C<'a, U> { fn get(self) -> &'a U; }
-
-mod foo {
-    pub trait D<'a, T> { fn get(self) -> &'a T; }
-}
-
-fn foo1<T>(_: &(dyn A<T> + Send)) {}
-fn foo2<T>(_: Box<dyn A<T> + Send + Sync>) {}
-fn foo3<T>(_: Box<dyn B<isize, usize> + 'static>) {}
-fn foo4<'a, T>(_: Box<dyn C<'a, T> + 'static + Send>) {}
-fn foo5<'a, T>(_: Box<dyn foo::D<'a, T> + 'static + Send>) {}
-
-pub fn main() {}
diff --git a/src/test/ui/traits/parameterized-with-bounds.rs b/src/test/ui/traits/parameterized-with-bounds.rs
new file mode 100644 (file)
index 0000000..832d4f6
--- /dev/null
@@ -0,0 +1,21 @@
+// run-pass
+// pretty-expanded FIXME #23616
+
+#![allow(dead_code)]
+
+
+trait A<T> { fn get(self) -> T; }
+trait B<T, U> { fn get(self) -> (T,U); }
+trait C<'a, U> { fn get(self) -> &'a U; }
+
+mod foo {
+    pub trait D<'a, T> { fn get(self) -> &'a T; }
+}
+
+fn foo1<T>(_: &(dyn A<T> + Send)) {}
+fn foo2<T>(_: Box<dyn A<T> + Send + Sync>) {}
+fn foo3<T>(_: Box<dyn B<isize, usize> + 'static>) {}
+fn foo4<'a, T>(_: Box<dyn C<'a, T> + 'static + Send>) {}
+fn foo5<'a, T>(_: Box<dyn foo::D<'a, T> + 'static + Send>) {}
+
+pub fn main() {}
diff --git a/src/test/ui/traits/principal-less-objects.rs b/src/test/ui/traits/principal-less-objects.rs
new file mode 100644 (file)
index 0000000..82c76eb
--- /dev/null
@@ -0,0 +1,42 @@
+// run-pass
+// Check that trait objects without a principal codegen properly.
+
+use std::sync::atomic::{AtomicUsize, Ordering};
+use std::mem;
+
+// Array is to make sure the size is not exactly pointer-size, so
+// we can be sure we are measuring the right size in the
+// `size_of_val` test.
+struct SetOnDrop<'a>(&'a AtomicUsize, [u8; 64]);
+impl<'a> Drop for SetOnDrop<'a> {
+    fn drop(&mut self) {
+        self.0.store(self.0.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
+    }
+}
+
+trait TypeEq<V: ?Sized> {}
+impl<T: ?Sized> TypeEq<T> for T {}
+fn assert_types_eq<U: ?Sized, V: ?Sized>() where U: TypeEq<V> {}
+
+fn main() {
+    // Check that different ways of writing the same type are equal.
+    assert_types_eq::<dyn Sync, dyn Sync + Sync>();
+    assert_types_eq::<dyn Sync + Send, dyn Send + Sync>();
+    assert_types_eq::<dyn Sync + Send + Sync, dyn Send + Sync>();
+
+    // Check that codegen works.
+    //
+    // Using `AtomicUsize` here because `Cell<u32>` is not `Sync`, and
+    // so can't be made into a `Box<dyn Sync>`.
+    let c = AtomicUsize::new(0);
+    {
+        let d: Box<dyn Sync> = Box::new(SetOnDrop(&c, [0; 64]));
+
+        assert_eq!(mem::size_of_val(&*d),
+                   mem::size_of::<SetOnDrop>());
+        assert_eq!(mem::align_of_val(&*d),
+                   mem::align_of::<SetOnDrop>());
+        assert_eq!(c.load(Ordering::Relaxed), 0);
+    }
+    assert_eq!(c.load(Ordering::Relaxed), 1);
+}
diff --git a/src/test/ui/traits/principal-less-trait-objects.rs b/src/test/ui/traits/principal-less-trait-objects.rs
deleted file mode 100644 (file)
index 82c76eb..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// run-pass
-// Check that trait objects without a principal codegen properly.
-
-use std::sync::atomic::{AtomicUsize, Ordering};
-use std::mem;
-
-// Array is to make sure the size is not exactly pointer-size, so
-// we can be sure we are measuring the right size in the
-// `size_of_val` test.
-struct SetOnDrop<'a>(&'a AtomicUsize, [u8; 64]);
-impl<'a> Drop for SetOnDrop<'a> {
-    fn drop(&mut self) {
-        self.0.store(self.0.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
-    }
-}
-
-trait TypeEq<V: ?Sized> {}
-impl<T: ?Sized> TypeEq<T> for T {}
-fn assert_types_eq<U: ?Sized, V: ?Sized>() where U: TypeEq<V> {}
-
-fn main() {
-    // Check that different ways of writing the same type are equal.
-    assert_types_eq::<dyn Sync, dyn Sync + Sync>();
-    assert_types_eq::<dyn Sync + Send, dyn Send + Sync>();
-    assert_types_eq::<dyn Sync + Send + Sync, dyn Send + Sync>();
-
-    // Check that codegen works.
-    //
-    // Using `AtomicUsize` here because `Cell<u32>` is not `Sync`, and
-    // so can't be made into a `Box<dyn Sync>`.
-    let c = AtomicUsize::new(0);
-    {
-        let d: Box<dyn Sync> = Box::new(SetOnDrop(&c, [0; 64]));
-
-        assert_eq!(mem::size_of_val(&*d),
-                   mem::size_of::<SetOnDrop>());
-        assert_eq!(mem::align_of_val(&*d),
-                   mem::align_of::<SetOnDrop>());
-        assert_eq!(c.load(Ordering::Relaxed), 0);
-    }
-    assert_eq!(c.load(Ordering::Relaxed), 1);
-}
diff --git a/src/test/ui/traits/privacy.rs b/src/test/ui/traits/privacy.rs
new file mode 100644 (file)
index 0000000..17a2e05
--- /dev/null
@@ -0,0 +1,24 @@
+// build-pass (FIXME(62277): could be check-pass?)
+#![allow(dead_code)]
+mod foo {
+    pub use self::bar::T;
+    mod bar {
+        pub trait T {
+            fn f(&self) {}
+        }
+        impl T for () {}
+    }
+}
+
+fn g() {
+    use foo::T;
+    ().f(); // Check that this does not trigger a privacy error
+}
+
+fn f() {
+    let error = ::std::thread::spawn(|| {}).join().unwrap_err();
+    error.type_id(); // Regression test for #21670
+}
+
+
+fn main() {}
diff --git a/src/test/ui/traits/region-pointer-simple.rs b/src/test/ui/traits/region-pointer-simple.rs
new file mode 100644 (file)
index 0000000..0456ca9
--- /dev/null
@@ -0,0 +1,21 @@
+// run-pass
+trait Foo {
+    fn f(&self) -> isize;
+}
+
+struct A {
+    x: isize
+}
+
+impl Foo for A {
+    fn f(&self) -> isize {
+        println!("Today's number is {}", self.x);
+        return self.x;
+    }
+}
+
+pub fn main() {
+    let a = A { x: 3 };
+    let b = (&a) as &dyn Foo;
+    assert_eq!(b.f(), 3);
+}
diff --git a/src/test/ui/traits/reservation-impl/coherence-conflict.rs b/src/test/ui/traits/reservation-impl/coherence-conflict.rs
new file mode 100644 (file)
index 0000000..fa4a309
--- /dev/null
@@ -0,0 +1,14 @@
+// check that reservation impls are accounted for in negative reasoning.
+
+#![feature(rustc_attrs)]
+
+trait MyTrait {}
+#[rustc_reservation_impl="this impl is reserved"]
+impl MyTrait for () {}
+
+trait OtherTrait {}
+impl OtherTrait for () {}
+impl<T: MyTrait> OtherTrait for T {}
+//~^ ERROR conflicting implementations
+
+fn main() {}
diff --git a/src/test/ui/traits/reservation-impl/coherence-conflict.stderr b/src/test/ui/traits/reservation-impl/coherence-conflict.stderr
new file mode 100644 (file)
index 0000000..1a227a8
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0119]: conflicting implementations of trait `OtherTrait` for type `()`:
+  --> $DIR/coherence-conflict.rs:11:1
+   |
+LL | impl OtherTrait for () {}
+   | ---------------------- first implementation here
+LL | impl<T: MyTrait> OtherTrait for T {}
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
+   |
+   = note: this impl is reserved
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/traits/reservation-impl/no-use.rs b/src/test/ui/traits/reservation-impl/no-use.rs
new file mode 100644 (file)
index 0000000..65a55d9
--- /dev/null
@@ -0,0 +1,12 @@
+// check that reservation impls can't be used as normal impls in positive reasoning.
+
+#![feature(rustc_attrs)]
+
+trait MyTrait { fn foo(&self); }
+#[rustc_reservation_impl = "foo"]
+impl MyTrait for () { fn foo(&self) {} }
+
+fn main() {
+    <() as MyTrait>::foo(&());
+    //~^ ERROR the trait bound `(): MyTrait` is not satisfied
+}
diff --git a/src/test/ui/traits/reservation-impl/no-use.stderr b/src/test/ui/traits/reservation-impl/no-use.stderr
new file mode 100644 (file)
index 0000000..fb4a443
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `(): MyTrait` is not satisfied
+  --> $DIR/no-use.rs:10:26
+   |
+LL | trait MyTrait { fn foo(&self); }
+   |                 -------------- required by `MyTrait::foo`
+...
+LL |     <() as MyTrait>::foo(&());
+   |                          ^^^ the trait `MyTrait` is not implemented for `()`
+   |
+   = help: the following implementations were found:
+             <() as MyTrait>
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/reservation-impl/non-lattice-ok.rs b/src/test/ui/traits/reservation-impl/non-lattice-ok.rs
new file mode 100644 (file)
index 0000000..f14589c
--- /dev/null
@@ -0,0 +1,59 @@
+// build-pass
+
+// Check that a reservation impl does not force other impls to follow
+// a lattice discipline.
+
+// Why did we ever want to do this?
+//
+// We want to eventually add a `impl<T> From<!> for T` impl. That impl conflicts
+// with existing impls - at least the `impl<T> From<T> for T` impl. There are
+// 2 ways we thought of for dealing with that conflict:
+//
+// 1. Using specialization and doing some handling for the
+// overlap. The current thought is to require ["intersection
+// impls"][ii], specialization", which means providing an
+// (higher-priority) impl for the intersection of every 2 conflicting
+// impls that determines what happens in the intersection case. That's
+// the first thing we thought about - see e.g.
+// https://github.com/rust-lang/rust/issues/57012#issuecomment-452150775
+//
+// 2. The other way is to notice that `impl From<!> for T` is basically a
+// marker trait since its only method is uninhabited, and allow for "marker
+// trait overlap", where the conflict "doesn't matter" because it can't
+// actually cause any ambiguity.
+//
+// Now it turned out lattice specialization doesn't work it, because an
+// `impl<T> From<T> for Smaht<T>` would require a `impl From<!> for Smaht<!>`,
+// breaking backwards-compatibility in a fairly painful way. So if we want to
+// go with a known approach, we should go with a "marker trait overlap"-style
+// approach.
+//
+// [ii]: http://smallcultfollowing.com/babysteps/blog/2016/09/24/intersection-impls/
+
+#![feature(rustc_attrs, never_type)]
+
+trait MyTrait {}
+
+impl MyTrait for ! {}
+
+trait MyFrom<T> {
+    fn my_from(x: T) -> Self;
+}
+
+// Given the "normal" impls for From
+#[rustc_reservation_impl="this impl is reserved"]
+impl<T> MyFrom<!> for T {
+    fn my_from(x: !) -> Self { match x {} }
+}
+
+impl<T> MyFrom<T> for T {
+    fn my_from(x: T) -> Self { x }
+}
+
+// ... we *do* want to allow this common pattern, of `From<!> for MySmaht<T>`
+struct MySmaht<T>(T);
+impl<T> MyFrom<T> for MySmaht<T> {
+    fn my_from(x: T) -> Self { MySmaht(x) }
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/reservation-impl/ok.rs b/src/test/ui/traits/reservation-impl/ok.rs
new file mode 100644 (file)
index 0000000..611c8d8
--- /dev/null
@@ -0,0 +1,28 @@
+// run-pass
+
+// rpass test for reservation impls. Not 100% required because `From` uses them,
+// but still.
+
+#![feature(rustc_attrs)]
+
+use std::mem;
+
+trait MyTrait<S> {
+    fn foo(&self, s: S) -> usize;
+}
+
+#[rustc_reservation_impl = "foo"]
+impl<T> MyTrait<u64> for T {
+    fn foo(&self, _x: u64) -> usize { 0 }
+}
+
+// reservation impls don't create coherence conflicts, even with
+// non-chain overlap.
+impl<S> MyTrait<S> for u32 {
+    fn foo(&self, _x: S) -> usize { mem::size_of::<S>() }
+}
+
+fn main() {
+    // ...and the non-reservation impl gets picked.XS
+    assert_eq!(0u32.foo(0u64), mem::size_of::<u64>());
+}
diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.rs
deleted file mode 100644 (file)
index fa4a309..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// check that reservation impls are accounted for in negative reasoning.
-
-#![feature(rustc_attrs)]
-
-trait MyTrait {}
-#[rustc_reservation_impl="this impl is reserved"]
-impl MyTrait for () {}
-
-trait OtherTrait {}
-impl OtherTrait for () {}
-impl<T: MyTrait> OtherTrait for T {}
-//~^ ERROR conflicting implementations
-
-fn main() {}
diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr b/src/test/ui/traits/reservation-impls/reservation-impl-coherence-conflict.stderr
deleted file mode 100644 (file)
index d76d3a9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0119]: conflicting implementations of trait `OtherTrait` for type `()`:
-  --> $DIR/reservation-impl-coherence-conflict.rs:11:1
-   |
-LL | impl OtherTrait for () {}
-   | ---------------------- first implementation here
-LL | impl<T: MyTrait> OtherTrait for T {}
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
-   |
-   = note: this impl is reserved
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.rs
deleted file mode 100644 (file)
index 65a55d9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// check that reservation impls can't be used as normal impls in positive reasoning.
-
-#![feature(rustc_attrs)]
-
-trait MyTrait { fn foo(&self); }
-#[rustc_reservation_impl = "foo"]
-impl MyTrait for () { fn foo(&self) {} }
-
-fn main() {
-    <() as MyTrait>::foo(&());
-    //~^ ERROR the trait bound `(): MyTrait` is not satisfied
-}
diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr b/src/test/ui/traits/reservation-impls/reservation-impl-no-use.stderr
deleted file mode 100644 (file)
index 794faff..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0277]: the trait bound `(): MyTrait` is not satisfied
-  --> $DIR/reservation-impl-no-use.rs:10:26
-   |
-LL | trait MyTrait { fn foo(&self); }
-   |                 -------------- required by `MyTrait::foo`
-...
-LL |     <() as MyTrait>::foo(&());
-   |                          ^^^ the trait `MyTrait` is not implemented for `()`
-   |
-   = help: the following implementations were found:
-             <() as MyTrait>
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs
deleted file mode 100644 (file)
index f14589c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// build-pass
-
-// Check that a reservation impl does not force other impls to follow
-// a lattice discipline.
-
-// Why did we ever want to do this?
-//
-// We want to eventually add a `impl<T> From<!> for T` impl. That impl conflicts
-// with existing impls - at least the `impl<T> From<T> for T` impl. There are
-// 2 ways we thought of for dealing with that conflict:
-//
-// 1. Using specialization and doing some handling for the
-// overlap. The current thought is to require ["intersection
-// impls"][ii], specialization", which means providing an
-// (higher-priority) impl for the intersection of every 2 conflicting
-// impls that determines what happens in the intersection case. That's
-// the first thing we thought about - see e.g.
-// https://github.com/rust-lang/rust/issues/57012#issuecomment-452150775
-//
-// 2. The other way is to notice that `impl From<!> for T` is basically a
-// marker trait since its only method is uninhabited, and allow for "marker
-// trait overlap", where the conflict "doesn't matter" because it can't
-// actually cause any ambiguity.
-//
-// Now it turned out lattice specialization doesn't work it, because an
-// `impl<T> From<T> for Smaht<T>` would require a `impl From<!> for Smaht<!>`,
-// breaking backwards-compatibility in a fairly painful way. So if we want to
-// go with a known approach, we should go with a "marker trait overlap"-style
-// approach.
-//
-// [ii]: http://smallcultfollowing.com/babysteps/blog/2016/09/24/intersection-impls/
-
-#![feature(rustc_attrs, never_type)]
-
-trait MyTrait {}
-
-impl MyTrait for ! {}
-
-trait MyFrom<T> {
-    fn my_from(x: T) -> Self;
-}
-
-// Given the "normal" impls for From
-#[rustc_reservation_impl="this impl is reserved"]
-impl<T> MyFrom<!> for T {
-    fn my_from(x: !) -> Self { match x {} }
-}
-
-impl<T> MyFrom<T> for T {
-    fn my_from(x: T) -> Self { x }
-}
-
-// ... we *do* want to allow this common pattern, of `From<!> for MySmaht<T>`
-struct MySmaht<T>(T);
-impl<T> MyFrom<T> for MySmaht<T> {
-    fn my_from(x: T) -> Self { MySmaht(x) }
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-ok.rs
deleted file mode 100644 (file)
index 611c8d8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// run-pass
-
-// rpass test for reservation impls. Not 100% required because `From` uses them,
-// but still.
-
-#![feature(rustc_attrs)]
-
-use std::mem;
-
-trait MyTrait<S> {
-    fn foo(&self, s: S) -> usize;
-}
-
-#[rustc_reservation_impl = "foo"]
-impl<T> MyTrait<u64> for T {
-    fn foo(&self, _x: u64) -> usize { 0 }
-}
-
-// reservation impls don't create coherence conflicts, even with
-// non-chain overlap.
-impl<S> MyTrait<S> for u32 {
-    fn foo(&self, _x: S) -> usize { mem::size_of::<S>() }
-}
-
-fn main() {
-    // ...and the non-reservation impl gets picked.XS
-    assert_eq!(0u32.foo(0u64), mem::size_of::<u64>());
-}
diff --git a/src/test/ui/traits/resolution-in-overloaded-op.rs b/src/test/ui/traits/resolution-in-overloaded-op.rs
new file mode 100644 (file)
index 0000000..a9bacc3
--- /dev/null
@@ -0,0 +1,11 @@
+// #12402 Operator overloading only considers the method name, not which trait is implemented
+
+trait MyMul<Rhs, Res> {
+    fn mul(&self, rhs: &Rhs) -> Res;
+}
+
+fn foo<T: MyMul<f64, f64>>(a: &T, b: f64) -> f64 {
+    a * b //~ ERROR cannot multiply `&T` by `f64`
+}
+
+fn main() {}
diff --git a/src/test/ui/traits/resolution-in-overloaded-op.stderr b/src/test/ui/traits/resolution-in-overloaded-op.stderr
new file mode 100644 (file)
index 0000000..6a641ed
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0369]: cannot multiply `&T` by `f64`
+  --> $DIR/resolution-in-overloaded-op.rs:8:7
+   |
+LL |     a * b
+   |     - ^ - f64
+   |     |
+   |     &T
+   |
+help: consider further restricting this bound
+   |
+LL | fn foo<T: MyMul<f64, f64> + std::ops::Mul<Output = f64>>(a: &T, b: f64) -> f64 {
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0369`.
diff --git a/src/test/ui/traits/safety-fn-body.rs b/src/test/ui/traits/safety-fn-body.rs
new file mode 100644 (file)
index 0000000..df52774
--- /dev/null
@@ -0,0 +1,16 @@
+// Check that an unsafe impl does not imply that unsafe actions are
+// legal in the methods.
+
+unsafe trait UnsafeTrait : Sized {
+    fn foo(self) { }
+}
+
+unsafe impl UnsafeTrait for *mut isize {
+    fn foo(self) {
+        // Unsafe actions are not made legal by taking place in an unsafe trait:
+        *self += 1;
+        //~^ ERROR E0133
+    }
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/safety-fn-body.stderr b/src/test/ui/traits/safety-fn-body.stderr
new file mode 100644 (file)
index 0000000..4f784a0
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
+  --> $DIR/safety-fn-body.rs:11:9
+   |
+LL |         *self += 1;
+   |         ^^^^^^^^^^ dereference of raw pointer
+   |
+   = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/traits/safety-inherent-impl.rs b/src/test/ui/traits/safety-inherent-impl.rs
new file mode 100644 (file)
index 0000000..50e15f0
--- /dev/null
@@ -0,0 +1,9 @@
+// Check that inherent impls cannot be unsafe.
+
+struct SomeStruct;
+
+unsafe impl SomeStruct { //~ ERROR inherent impls cannot be unsafe
+    fn foo(self) { }
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/safety-inherent-impl.stderr b/src/test/ui/traits/safety-inherent-impl.stderr
new file mode 100644 (file)
index 0000000..1c8f43f
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0197]: inherent impls cannot be unsafe
+  --> $DIR/safety-inherent-impl.rs:5:13
+   |
+LL | unsafe impl SomeStruct {
+   | ------      ^^^^^^^^^^ inherent impl for this type
+   | |
+   | unsafe because of this
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0197`.
diff --git a/src/test/ui/traits/safety-ok-cc.rs b/src/test/ui/traits/safety-ok-cc.rs
new file mode 100644 (file)
index 0000000..099ba80
--- /dev/null
@@ -0,0 +1,24 @@
+// run-pass
+// aux-build:trait_safety_lib.rs
+
+// Simple smoke test that unsafe traits can be compiled across crates.
+
+
+extern crate trait_safety_lib as lib;
+
+use lib::Foo;
+
+struct Bar { x: isize }
+unsafe impl Foo for Bar {
+    fn foo(&self) -> isize { self.x }
+}
+
+fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
+
+fn main() {
+    let x: isize = 22;
+    assert_eq!(22, take_foo(&x));
+
+    let x: Bar = Bar { x: 23 };
+    assert_eq!(23, take_foo(&x));
+}
diff --git a/src/test/ui/traits/safety-ok.rs b/src/test/ui/traits/safety-ok.rs
new file mode 100644 (file)
index 0000000..d456a78
--- /dev/null
@@ -0,0 +1,18 @@
+// run-pass
+// Simple smoke test that unsafe traits can be compiled etc.
+
+
+unsafe trait Foo {
+    fn foo(&self) -> isize;
+}
+
+unsafe impl Foo for isize {
+    fn foo(&self) -> isize { *self }
+}
+
+fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
+
+fn main() {
+    let x: isize = 22;
+    assert_eq!(22, take_foo(&x));
+}
diff --git a/src/test/ui/traits/safety-trait-impl-cc.rs b/src/test/ui/traits/safety-trait-impl-cc.rs
new file mode 100644 (file)
index 0000000..6f125e5
--- /dev/null
@@ -0,0 +1,15 @@
+// aux-build:trait_safety_lib.rs
+
+// Check that unsafe traits require unsafe impls and that inherent
+// impls cannot be unsafe.
+
+extern crate trait_safety_lib as lib;
+
+struct Bar;
+impl lib::Foo for Bar { //~ ERROR requires an `unsafe impl` declaration
+    fn foo(&self) -> isize {
+        panic!();
+    }
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/safety-trait-impl-cc.stderr b/src/test/ui/traits/safety-trait-impl-cc.stderr
new file mode 100644 (file)
index 0000000..5a0f8d3
--- /dev/null
@@ -0,0 +1,13 @@
+error[E0200]: the trait `Foo` requires an `unsafe impl` declaration
+  --> $DIR/safety-trait-impl-cc.rs:9:1
+   |
+LL | / impl lib::Foo for Bar {
+LL | |     fn foo(&self) -> isize {
+LL | |         panic!();
+LL | |     }
+LL | | }
+   | |_^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0200`.
diff --git a/src/test/ui/traits/safety-trait-impl.rs b/src/test/ui/traits/safety-trait-impl.rs
new file mode 100644 (file)
index 0000000..45258b7
--- /dev/null
@@ -0,0 +1,18 @@
+// Check that unsafe traits require unsafe impls and that inherent
+// impls cannot be unsafe.
+
+trait SafeTrait {
+    fn foo(&self) { }
+}
+
+unsafe trait UnsafeTrait {
+    fn foo(&self) { }
+}
+
+unsafe impl UnsafeTrait for u8 { } // OK
+
+impl UnsafeTrait for u16 { } //~ ERROR requires an `unsafe impl` declaration
+
+unsafe impl SafeTrait for u32 { } //~ ERROR the trait `SafeTrait` is not unsafe
+
+fn main() { }
diff --git a/src/test/ui/traits/safety-trait-impl.stderr b/src/test/ui/traits/safety-trait-impl.stderr
new file mode 100644 (file)
index 0000000..fc0f6c6
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0200]: the trait `UnsafeTrait` requires an `unsafe impl` declaration
+  --> $DIR/safety-trait-impl.rs:14:1
+   |
+LL | impl UnsafeTrait for u16 { }
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0199]: implementing the trait `SafeTrait` is not unsafe
+  --> $DIR/safety-trait-impl.rs:16:1
+   |
+LL | unsafe impl SafeTrait for u32 { }
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0199, E0200.
+For more information about an error, try `rustc --explain E0199`.
diff --git a/src/test/ui/traits/static-method-generic-inference.rs b/src/test/ui/traits/static-method-generic-inference.rs
new file mode 100644 (file)
index 0000000..759416d
--- /dev/null
@@ -0,0 +1,28 @@
+// Issue #3902. We are (at least currently) unable to infer `Self`
+// based on `T`, even though there is only a single impl, because of
+// the possibility of associated types and other things (basically: no
+// constraints on `Self` here at all).
+
+mod base {
+    pub trait HasNew<T> {
+        fn new() -> T;
+        fn dummy(&self) { }
+    }
+
+    pub struct Foo {
+        dummy: (),
+    }
+
+    impl HasNew<Foo> for Foo {
+        fn new() -> Foo {
+            Foo { dummy: () }
+        }
+    }
+}
+
+pub fn foo() {
+    let _f: base::Foo = base::HasNew::new();
+    //~^ ERROR type annotations needed
+}
+
+fn main() { }
diff --git a/src/test/ui/traits/static-method-generic-inference.stderr b/src/test/ui/traits/static-method-generic-inference.stderr
new file mode 100644 (file)
index 0000000..2b9ce73
--- /dev/null
@@ -0,0 +1,14 @@
+error[E0283]: type annotations needed
+  --> $DIR/static-method-generic-inference.rs:24:25
+   |
+LL |         fn new() -> T;
+   |         -------------- required by `HasNew::new`
+...
+LL |     let _f: base::Foo = base::HasNew::new();
+   |                         ^^^^^^^^^^^^^^^^^ cannot infer type
+   |
+   = note: cannot satisfy `_: HasNew<Foo>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/src/test/ui/traits/static-method-overwriting.rs b/src/test/ui/traits/static-method-overwriting.rs
new file mode 100644 (file)
index 0000000..f669ffa
--- /dev/null
@@ -0,0 +1,34 @@
+// run-pass
+#![allow(dead_code)]
+mod base {
+    pub trait HasNew {
+        fn new() -> Self;
+    }
+
+    pub struct Foo {
+        dummy: (),
+    }
+
+    impl ::base::HasNew for Foo {
+        fn new() -> Foo {
+            println!("Foo");
+            Foo { dummy: () }
+        }
+    }
+
+    pub struct Bar {
+        dummy: (),
+    }
+
+    impl ::base::HasNew for Bar {
+        fn new() -> Bar {
+            println!("Bar");
+            Bar { dummy: () }
+        }
+    }
+}
+
+pub fn main() {
+    let _f: base::Foo = base::HasNew::new();
+    let _b: base::Bar = base::HasNew::new();
+}
diff --git a/src/test/ui/traits/static-outlives-a-where-clause.rs b/src/test/ui/traits/static-outlives-a-where-clause.rs
new file mode 100644 (file)
index 0000000..f0c2c10
--- /dev/null
@@ -0,0 +1,23 @@
+// run-pass
+
+trait Foo<'a> {
+    fn xyz(self);
+}
+impl<'a, T> Foo<'a> for T where 'static: 'a {
+    fn xyz(self) {}
+}
+
+trait Bar {
+    fn uvw(self);
+}
+impl<T> Bar for T where for<'a> T: Foo<'a> {
+    fn uvw(self) { self.xyz(); }
+}
+
+fn foo<T>(t: T) where T: Bar {
+    t.uvw();
+}
+
+fn main() {
+    foo(0);
+}
diff --git a/src/test/ui/traits/suggest-deferences/issue-39029.fixed b/src/test/ui/traits/suggest-deferences/issue-39029.fixed
new file mode 100644 (file)
index 0000000..a1abf66
--- /dev/null
@@ -0,0 +1,18 @@
+// run-rustfix
+use std::net::TcpListener;
+
+struct NoToSocketAddrs(String);
+
+impl std::ops::Deref for NoToSocketAddrs {
+    type Target = String;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+fn main() {
+    let _works = TcpListener::bind("some string");
+    let bad = NoToSocketAddrs("bad".to_owned());
+    let _errors = TcpListener::bind(&*bad);
+    //~^ ERROR the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/issue-39029.rs b/src/test/ui/traits/suggest-deferences/issue-39029.rs
new file mode 100644 (file)
index 0000000..90d0971
--- /dev/null
@@ -0,0 +1,18 @@
+// run-rustfix
+use std::net::TcpListener;
+
+struct NoToSocketAddrs(String);
+
+impl std::ops::Deref for NoToSocketAddrs {
+    type Target = String;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+fn main() {
+    let _works = TcpListener::bind("some string");
+    let bad = NoToSocketAddrs("bad".to_owned());
+    let _errors = TcpListener::bind(&bad);
+    //~^ ERROR the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/issue-39029.stderr b/src/test/ui/traits/suggest-deferences/issue-39029.stderr
new file mode 100644 (file)
index 0000000..1005231
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
+  --> $DIR/issue-39029.rs:16:37
+   |
+LL |     let _errors = TcpListener::bind(&bad);
+   |                                     ^^^^
+   |                                     |
+   |                                     the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs`
+   |                                     help: consider adding dereference here: `&*bad`
+   | 
+  ::: $SRC_DIR/std/src/net/tcp.rs:LL:COL
+   |
+LL |     pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<TcpListener> {
+   |                    ------------- required by this bound in `TcpListener::bind`
+   |
+   = note: required because of the requirements on the impl of `ToSocketAddrs` for `&NoToSocketAddrs`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/suggest-deferences/issue-62530.fixed b/src/test/ui/traits/suggest-deferences/issue-62530.fixed
new file mode 100644 (file)
index 0000000..406caaa
--- /dev/null
@@ -0,0 +1,15 @@
+// run-rustfix
+fn takes_str(_x: &str) {}
+
+fn takes_type_parameter<T>(_x: T) where T: SomeTrait {}
+
+trait SomeTrait {}
+impl SomeTrait for &'_ str {}
+impl SomeTrait for char {}
+
+fn main() {
+    let string = String::new();
+    takes_str(&string);             // Ok
+    takes_type_parameter(&*string);  // Error
+    //~^ ERROR the trait bound `&String: SomeTrait` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/issue-62530.rs b/src/test/ui/traits/suggest-deferences/issue-62530.rs
new file mode 100644 (file)
index 0000000..53846be
--- /dev/null
@@ -0,0 +1,15 @@
+// run-rustfix
+fn takes_str(_x: &str) {}
+
+fn takes_type_parameter<T>(_x: T) where T: SomeTrait {}
+
+trait SomeTrait {}
+impl SomeTrait for &'_ str {}
+impl SomeTrait for char {}
+
+fn main() {
+    let string = String::new();
+    takes_str(&string);             // Ok
+    takes_type_parameter(&string);  // Error
+    //~^ ERROR the trait bound `&String: SomeTrait` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/issue-62530.stderr b/src/test/ui/traits/suggest-deferences/issue-62530.stderr
new file mode 100644 (file)
index 0000000..4f1165b
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `&String: SomeTrait` is not satisfied
+  --> $DIR/issue-62530.rs:13:26
+   |
+LL | fn takes_type_parameter<T>(_x: T) where T: SomeTrait {}
+   |                                            --------- required by this bound in `takes_type_parameter`
+...
+LL |     takes_type_parameter(&string);  // Error
+   |                          ^^^^^^^
+   |                          |
+   |                          the trait `SomeTrait` is not implemented for `&String`
+   |                          help: consider adding dereference here: `&*string`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/suggest-deferences/multiple-0.fixed b/src/test/ui/traits/suggest-deferences/multiple-0.fixed
new file mode 100644 (file)
index 0000000..b7160b7
--- /dev/null
@@ -0,0 +1,36 @@
+// run-rustfix
+use std::ops::Deref;
+
+trait Happy {}
+struct LDM;
+impl Happy for &LDM {}
+
+struct Foo(LDM);
+struct Bar(Foo);
+struct Baz(Bar);
+impl Deref for Foo {
+    type Target = LDM;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl Deref for Bar {
+    type Target = Foo;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl Deref for Baz {
+    type Target = Bar;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+fn foo<T>(_: T) where T: Happy {}
+
+fn main() {
+    let baz = Baz(Bar(Foo(LDM)));
+    foo(&***baz);
+    //~^ ERROR the trait bound `&Baz: Happy` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/multiple-0.rs b/src/test/ui/traits/suggest-deferences/multiple-0.rs
new file mode 100644 (file)
index 0000000..9ac5517
--- /dev/null
@@ -0,0 +1,36 @@
+// run-rustfix
+use std::ops::Deref;
+
+trait Happy {}
+struct LDM;
+impl Happy for &LDM {}
+
+struct Foo(LDM);
+struct Bar(Foo);
+struct Baz(Bar);
+impl Deref for Foo {
+    type Target = LDM;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl Deref for Bar {
+    type Target = Foo;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl Deref for Baz {
+    type Target = Bar;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+fn foo<T>(_: T) where T: Happy {}
+
+fn main() {
+    let baz = Baz(Bar(Foo(LDM)));
+    foo(&baz);
+    //~^ ERROR the trait bound `&Baz: Happy` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/multiple-0.stderr b/src/test/ui/traits/suggest-deferences/multiple-0.stderr
new file mode 100644 (file)
index 0000000..f76c73c
--- /dev/null
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `&Baz: Happy` is not satisfied
+  --> $DIR/multiple-0.rs:34:9
+   |
+LL | fn foo<T>(_: T) where T: Happy {}
+   |                          ----- required by this bound in `foo`
+...
+LL |     foo(&baz);
+   |         ^^^^
+   |         |
+   |         the trait `Happy` is not implemented for `&Baz`
+   |         help: consider adding dereference here: `&***baz`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/suggest-deferences/multiple-1.rs b/src/test/ui/traits/suggest-deferences/multiple-1.rs
new file mode 100644 (file)
index 0000000..91c6c79
--- /dev/null
@@ -0,0 +1,54 @@
+use std::ops::{Deref, DerefMut};
+
+trait Happy {}
+struct LDM;
+impl Happy for &mut LDM {}
+
+struct Foo(LDM);
+struct Bar(Foo);
+struct Baz(Bar);
+impl Deref for Foo {
+    type Target = LDM;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl Deref for Bar {
+    type Target = Foo;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl Deref for Baz {
+    type Target = Bar;
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+impl DerefMut for Foo {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.0
+    }
+}
+impl DerefMut for Bar {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.0
+    }
+}
+impl DerefMut for Baz {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.0
+    }
+}
+
+
+fn foo<T>(_: T) where T: Happy {}
+
+fn main() {
+    // Currently the compiler doesn't try to suggest dereferences for situations
+    // where DerefMut involves. So this test is meant to ensure compiler doesn't
+    // generate incorrect help message.
+    let mut baz = Baz(Bar(Foo(LDM)));
+    foo(&mut baz);
+    //~^ ERROR the trait bound `&mut Baz: Happy` is not satisfied
+}
diff --git a/src/test/ui/traits/suggest-deferences/multiple-1.stderr b/src/test/ui/traits/suggest-deferences/multiple-1.stderr
new file mode 100644 (file)
index 0000000..f98cc54
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `&mut Baz: Happy` is not satisfied
+  --> $DIR/multiple-1.rs:52:9
+   |
+LL | fn foo<T>(_: T) where T: Happy {}
+   |                          ----- required by this bound in `foo`
+...
+LL |     foo(&mut baz);
+   |         ^^^^^^^^ the trait `Happy` is not implemented for `&mut Baz`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/suggest-where-clause.rs b/src/test/ui/traits/suggest-where-clause.rs
new file mode 100644 (file)
index 0000000..46d047a
--- /dev/null
@@ -0,0 +1,36 @@
+use std::mem;
+
+struct Misc<T:?Sized>(T);
+
+fn check<T: Iterator, U: ?Sized>() {
+    // suggest a where-clause, if needed
+    mem::size_of::<U>();
+    //~^ ERROR the size for values of type
+
+    mem::size_of::<Misc<U>>();
+    //~^ ERROR the size for values of type
+
+    // ... even if T occurs as a type parameter
+
+    <u64 as From<T>>::from;
+    //~^ ERROR `u64: From<T>` is not satisfied
+
+    <u64 as From<<T as Iterator>::Item>>::from;
+    //~^ ERROR `u64: From<<T as Iterator>::Item>` is not satisfied
+
+    // ... but not if there are inference variables
+
+    <Misc<_> as From<T>>::from;
+    //~^ ERROR `Misc<_>: From<T>` is not satisfied
+
+    // ... and also not if the error is not related to the type
+
+    mem::size_of::<[T]>();
+    //~^ ERROR the size for values of type
+
+    mem::size_of::<[&U]>();
+    //~^ ERROR the size for values of type
+}
+
+fn main() {
+}
diff --git a/src/test/ui/traits/suggest-where-clause.stderr b/src/test/ui/traits/suggest-where-clause.stderr
new file mode 100644 (file)
index 0000000..b50017a
--- /dev/null
@@ -0,0 +1,83 @@
+error[E0277]: the size for values of type `U` cannot be known at compilation time
+  --> $DIR/suggest-where-clause.rs:7:20
+   |
+LL | fn check<T: Iterator, U: ?Sized>() {
+   |                       - this type parameter needs to be `Sized`
+LL |     // suggest a where-clause, if needed
+LL |     mem::size_of::<U>();
+   |                    ^ doesn't have a size known at compile-time
+   | 
+  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
+   |
+LL | pub const fn size_of<T>() -> usize {
+   |                      - required by this bound in `std::mem::size_of`
+
+error[E0277]: the size for values of type `U` cannot be known at compilation time
+  --> $DIR/suggest-where-clause.rs:10:5
+   |
+LL | fn check<T: Iterator, U: ?Sized>() {
+   |                       - this type parameter needs to be `Sized`
+...
+LL |     mem::size_of::<Misc<U>>();
+   |     ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   | 
+  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
+   |
+LL | pub const fn size_of<T>() -> usize {
+   |                      - required by this bound in `std::mem::size_of`
+   |
+   = note: required because it appears within the type `Misc<U>`
+
+error[E0277]: the trait bound `u64: From<T>` is not satisfied
+  --> $DIR/suggest-where-clause.rs:15:5
+   |
+LL |     <u64 as From<T>>::from;
+   |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `u64`
+   |
+   = note: required by `from`
+
+error[E0277]: the trait bound `u64: From<<T as Iterator>::Item>` is not satisfied
+  --> $DIR/suggest-where-clause.rs:18:5
+   |
+LL |     <u64 as From<<T as Iterator>::Item>>::from;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
+   |
+   = note: required by `from`
+
+error[E0277]: the trait bound `Misc<_>: From<T>` is not satisfied
+  --> $DIR/suggest-where-clause.rs:23:5
+   |
+LL |     <Misc<_> as From<T>>::from;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>`
+   |
+   = note: required by `from`
+
+error[E0277]: the size for values of type `[T]` cannot be known at compilation time
+  --> $DIR/suggest-where-clause.rs:28:20
+   |
+LL |     mem::size_of::<[T]>();
+   |                    ^^^ doesn't have a size known at compile-time
+   | 
+  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
+   |
+LL | pub const fn size_of<T>() -> usize {
+   |                      - required by this bound in `std::mem::size_of`
+   |
+   = help: the trait `Sized` is not implemented for `[T]`
+
+error[E0277]: the size for values of type `[&U]` cannot be known at compilation time
+  --> $DIR/suggest-where-clause.rs:31:5
+   |
+LL |     mem::size_of::<[&U]>();
+   |     ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   | 
+  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
+   |
+LL | pub const fn size_of<T>() -> usize {
+   |                      - required by this bound in `std::mem::size_of`
+   |
+   = help: the trait `Sized` is not implemented for `[&U]`
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/superdefault-generics.rs b/src/test/ui/traits/superdefault-generics.rs
new file mode 100644 (file)
index 0000000..e862c0e
--- /dev/null
@@ -0,0 +1,39 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(non_snake_case)]
+
+// There is some other borrowck bug, so we make the stuff not mut.
+
+
+use std::ops::Add;
+
+trait Positioned<S> {
+  fn SetX(&mut self, _: S);
+  fn X(&self) -> S;
+}
+
+trait Movable<S: Add<Output=S>>: Positioned<S> {
+  fn translate(&mut self, dx: S) {
+    let x = self.X() + dx;
+    self.SetX(x);
+  }
+}
+
+struct Point<S> { x: S, y: S }
+
+impl<S: Clone> Positioned<S> for Point<S> {
+    fn SetX(&mut self, x: S) {
+        self.x = x;
+    }
+    fn X(&self) -> S {
+        self.x.clone()
+    }
+}
+
+impl<S: Clone + Add<Output=S>> Movable<S> for Point<S> {}
+
+pub fn main() {
+    let mut p = Point{ x: 1, y: 2};
+    p.translate(3);
+    assert_eq!(p.X(), 4);
+}
diff --git a/src/test/ui/traits/supertrait-default-generics.rs b/src/test/ui/traits/supertrait-default-generics.rs
deleted file mode 100644 (file)
index e862c0e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(non_snake_case)]
-
-// There is some other borrowck bug, so we make the stuff not mut.
-
-
-use std::ops::Add;
-
-trait Positioned<S> {
-  fn SetX(&mut self, _: S);
-  fn X(&self) -> S;
-}
-
-trait Movable<S: Add<Output=S>>: Positioned<S> {
-  fn translate(&mut self, dx: S) {
-    let x = self.X() + dx;
-    self.SetX(x);
-  }
-}
-
-struct Point<S> { x: S, y: S }
-
-impl<S: Clone> Positioned<S> for Point<S> {
-    fn SetX(&mut self, x: S) {
-        self.x = x;
-    }
-    fn X(&self) -> S {
-        self.x.clone()
-    }
-}
-
-impl<S: Clone + Add<Output=S>> Movable<S> for Point<S> {}
-
-pub fn main() {
-    let mut p = Point{ x: 1, y: 2};
-    p.translate(3);
-    assert_eq!(p.X(), 4);
-}
diff --git a/src/test/ui/traits/syntax-polarity.rs b/src/test/ui/traits/syntax-polarity.rs
new file mode 100644 (file)
index 0000000..c809f9e
--- /dev/null
@@ -0,0 +1,21 @@
+// run-pass
+#![allow(dead_code)]
+// pretty-expanded FIXME #23616
+
+#![feature(negative_impls)]
+
+struct TestType;
+
+impl TestType {}
+
+trait TestTrait {}
+
+impl !Send for TestType {}
+
+struct TestType2<T>(T);
+
+impl<T> TestType2<T> {}
+
+impl<T> !Send for TestType2<T> {}
+
+fn main() {}
diff --git a/src/test/ui/traits/syntax-trait-polarity.rs b/src/test/ui/traits/syntax-trait-polarity.rs
deleted file mode 100644 (file)
index c809f9e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// pretty-expanded FIXME #23616
-
-#![feature(negative_impls)]
-
-struct TestType;
-
-impl TestType {}
-
-trait TestTrait {}
-
-impl !Send for TestType {}
-
-struct TestType2<T>(T);
-
-impl<T> TestType2<T> {}
-
-impl<T> !Send for TestType2<T> {}
-
-fn main() {}
diff --git a/src/test/ui/traits/test-2.rs b/src/test/ui/traits/test-2.rs
new file mode 100644 (file)
index 0000000..a337731
--- /dev/null
@@ -0,0 +1,16 @@
+#![feature(box_syntax)]
+
+#[allow(non_camel_case_types)]
+trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
+impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah<X>(&self) {} }
+impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} }
+
+fn main() {
+    10.dup::<i32>();
+    //~^ ERROR this associated function takes 0 type arguments but 1 type argument was supplied
+    10.blah::<i32, i32>();
+    //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied
+    (box 10 as Box<dyn bar>).dup();
+    //~^ ERROR E0038
+    //~| ERROR E0038
+}
diff --git a/src/test/ui/traits/test-2.stderr b/src/test/ui/traits/test-2.stderr
new file mode 100644 (file)
index 0000000..12b55c3
--- /dev/null
@@ -0,0 +1,68 @@
+error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
+  --> $DIR/test-2.rs:9:8
+   |
+LL |     10.dup::<i32>();
+   |        ^^^------- help: remove these generics
+   |        |
+   |        expected 0 type arguments
+   |
+note: associated function defined here, with 0 type parameters
+  --> $DIR/test-2.rs:4:16
+   |
+LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
+   |                ^^^
+
+error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied
+  --> $DIR/test-2.rs:11:8
+   |
+LL |     10.blah::<i32, i32>();
+   |        ^^^^      ----- help: remove this type argument
+   |        |
+   |        expected 1 type argument
+   |
+note: associated function defined here, with 1 type parameter: `X`
+  --> $DIR/test-2.rs:4:39
+   |
+LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
+   |                                       ^^^^ -
+
+error[E0038]: the trait `bar` cannot be made into an object
+  --> $DIR/test-2.rs:13:16
+   |
+LL |     (box 10 as Box<dyn bar>).dup();
+   |                ^^^^^^^^^^^^ `bar` cannot be made into an object
+   |
+   = help: consider moving `dup` to another trait
+   = help: consider moving `blah` to another trait
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/test-2.rs:4:30
+   |
+LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
+   |       ---                    ^^^^     ^^^^ ...because method `blah` has generic type parameters
+   |       |                      |
+   |       |                      ...because method `dup` references the `Self` type in its return type
+   |       this trait cannot be made into an object...
+
+error[E0038]: the trait `bar` cannot be made into an object
+  --> $DIR/test-2.rs:13:6
+   |
+LL |     (box 10 as Box<dyn bar>).dup();
+   |      ^^^^^^ `bar` cannot be made into an object
+   |
+   = help: consider moving `dup` to another trait
+   = help: consider moving `blah` to another trait
+note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
+  --> $DIR/test-2.rs:4:30
+   |
+LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
+   |       ---                    ^^^^     ^^^^ ...because method `blah` has generic type parameters
+   |       |                      |
+   |       |                      ...because method `dup` references the `Self` type in its return type
+   |       this trait cannot be made into an object...
+   = note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn bar>>` for `Box<{integer}>`
+   = note: required by cast to type `Box<dyn bar>`
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0038, E0107.
+For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/test.rs b/src/test/ui/traits/test.rs
new file mode 100644 (file)
index 0000000..72fc66f
--- /dev/null
@@ -0,0 +1,6 @@
+#[allow(non_camel_case_types)]
+trait foo { fn foo(&self); }
+
+impl isize for usize { fn foo(&self) {} } //~ ERROR trait
+
+fn main() {}
diff --git a/src/test/ui/traits/test.stderr b/src/test/ui/traits/test.stderr
new file mode 100644 (file)
index 0000000..668228a
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0404]: expected trait, found builtin type `isize`
+  --> $DIR/test.rs:4:6
+   |
+LL | impl isize for usize { fn foo(&self) {} }
+   |      ^^^^^ not a trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0404`.
diff --git a/src/test/ui/traits/to-str.rs b/src/test/ui/traits/to-str.rs
new file mode 100644 (file)
index 0000000..9670edb
--- /dev/null
@@ -0,0 +1,36 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+
+trait to_str {
+    fn to_string_(&self) -> String;
+}
+
+impl to_str for isize {
+    fn to_string_(&self) -> String { self.to_string() }
+}
+
+impl<T:to_str> to_str for Vec<T> {
+    fn to_string_(&self) -> String {
+        format!("[{}]",
+                self.iter()
+                    .map(|e| e.to_string_())
+                    .collect::<Vec<String>>()
+                    .join(", "))
+    }
+}
+
+pub fn main() {
+    assert_eq!(1.to_string_(), "1".to_string());
+    assert_eq!((vec![2, 3, 4]).to_string_(), "[2, 3, 4]".to_string());
+
+    fn indirect<T:to_str>(x: T) -> String {
+        format!("{}!", x.to_string_())
+    }
+    assert_eq!(indirect(vec![10, 20]), "[10, 20]!".to_string());
+
+    fn indirect2<T:to_str>(x: T) -> String {
+        indirect(x)
+    }
+    assert_eq!(indirect2(vec![1]), "[1]!".to_string());
+}
diff --git a/src/test/ui/traits/trait-alias-ambiguous.rs b/src/test/ui/traits/trait-alias-ambiguous.rs
deleted file mode 100644 (file)
index 28409e0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#![feature(trait_alias)]
-
-mod inner {
-    pub trait A { fn foo(&self); }
-    pub trait B { fn foo(&self); }
-
-    impl A for u8 {
-        fn foo(&self) {}
-    }
-    impl B for u8 {
-        fn foo(&self) {}
-    }
-
-    pub trait C = A + B;
-}
-
-use inner::C;
-
-fn main() {
-    let t = 1u8;
-    t.foo(); //~ ERROR E0034
-
-    inner::A::foo(&t); // ok
-}
diff --git a/src/test/ui/traits/trait-alias-ambiguous.stderr b/src/test/ui/traits/trait-alias-ambiguous.stderr
deleted file mode 100644 (file)
index f692e92..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-error[E0034]: multiple applicable items in scope
-  --> $DIR/trait-alias-ambiguous.rs:21:7
-   |
-LL |     t.foo();
-   |       ^^^ multiple `foo` found
-   |
-note: candidate #1 is defined in an impl of the trait `A` for the type `u8`
-  --> $DIR/trait-alias-ambiguous.rs:8:9
-   |
-LL |         fn foo(&self) {}
-   |         ^^^^^^^^^^^^^
-note: candidate #2 is defined in an impl of the trait `B` for the type `u8`
-  --> $DIR/trait-alias-ambiguous.rs:11:9
-   |
-LL |         fn foo(&self) {}
-   |         ^^^^^^^^^^^^^
-help: disambiguate the associated function for candidate #1
-   |
-LL |     A::foo(&t);
-   |     ^^^^^^^^^^
-help: disambiguate the associated function for candidate #2
-   |
-LL |     B::foo(&t);
-   |     ^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0034`.
diff --git a/src/test/ui/traits/trait-alias-import-cross-crate.rs b/src/test/ui/traits/trait-alias-import-cross-crate.rs
deleted file mode 100644 (file)
index 975542a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// run-pass
-// aux-build:trait_alias.rs
-
-#![feature(trait_alias)]
-
-extern crate trait_alias;
-
-// Import only the alias, not the real trait.
-use trait_alias::{Greet, Hi};
-
-fn main() {
-    let hi = Hi;
-    hi.hello(); // From `Hello`, via `Greet` alias.
-}
diff --git a/src/test/ui/traits/trait-alias-import.rs b/src/test/ui/traits/trait-alias-import.rs
deleted file mode 100644 (file)
index 802a8f1..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// run-pass
-
-#![feature(trait_alias)]
-
-mod inner {
-    pub trait Foo {
-        fn foo(&self);
-    }
-
-    pub struct Qux;
-
-    impl Foo for Qux {
-        fn foo(&self) {}
-    }
-
-    pub trait Bar = Foo;
-}
-
-mod two {
-    pub trait A {
-        fn foo();
-    }
-
-    impl A for u8 {
-        fn foo() {}
-    }
-}
-
-// Import only the alias, not the `Foo` trait.
-use inner::{Bar, Qux};
-
-// Declaring an alias also brings in aliased methods.
-trait Two = two::A;
-
-fn main() {
-    let q = Qux;
-    q.foo(); // From Bar.
-
-    u8::foo(); // From A.
-}
diff --git a/src/test/ui/traits/trait-alias/auxiliary/trait_alias.rs b/src/test/ui/traits/trait-alias/auxiliary/trait_alias.rs
deleted file mode 100644 (file)
index 9e56b87..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#![feature(trait_alias)]
-
-pub trait SendSync = Send + Sync;
diff --git a/src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs b/src/test/ui/traits/trait-alias/issue-60021-assoc-method-resolve.rs
deleted file mode 100644 (file)
index 5e27ed3..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// check-pass
-
-#![feature(trait_alias)]
-
-trait SomeTrait {
-    fn map(&self) {}
-}
-
-impl<T> SomeTrait for Option<T> {}
-
-trait SomeAlias = SomeTrait;
-
-fn main() {
-    let x = Some(123);
-    // This should resolve to the trait impl for Option
-    Option::map(x, |z| z);
-    // This should resolve to the trait impl for SomeTrait
-    SomeTrait::map(&x);
-}
diff --git a/src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs b/src/test/ui/traits/trait-alias/issue-72415-assoc-const-resolve.rs
deleted file mode 100644 (file)
index e49125d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// check-pass
-
-#![feature(trait_alias)]
-
-trait Bounded { const MAX: Self; }
-
-impl Bounded for u32 {
-    // This should correctly resolve to the associated const in the inherent impl of u32.
-    const MAX: Self = u32::MAX;
-}
-
-trait Num = Bounded + Copy;
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/issue-75983.rs b/src/test/ui/traits/trait-alias/issue-75983.rs
deleted file mode 100644 (file)
index f9a7f36..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// check-pass
-
-#![feature(trait_alias)]
-
-struct Bar;
-trait Foo {}
-impl Foo for Bar {}
-
-trait Baz = Foo where Bar: Foo;
-
-fn new() -> impl Baz {
-    Bar
-}
-
-fn main() {
-    let _ = new();
-}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-bounds.rs b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs
deleted file mode 100644 (file)
index b97eb38..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// run-pass
-
-#![feature(trait_alias)]
-
-use std::marker::PhantomData;
-
-trait Empty {}
-trait EmptyAlias = Empty;
-trait CloneDefault = Clone + Default;
-trait SendSyncAlias = Send + Sync;
-trait WhereSendAlias = where Self: Send;
-trait SendEqAlias<T> = Send where T: PartialEq<Self>;
-trait I32Iterator = Iterator<Item = i32>;
-
-#[allow(dead_code)]
-struct Foo<T: SendSyncAlias>(PhantomData<T>);
-#[allow(dead_code)]
-struct Bar<T>(PhantomData<T>) where T: SendSyncAlias;
-
-impl dyn EmptyAlias {}
-
-impl<T: SendSyncAlias> Empty for T {}
-
-fn a<T: CloneDefault>() -> (T, T) {
-    let one = T::default();
-    let two = one.clone();
-    (one, two)
-}
-
-fn b(x: &impl SendEqAlias<i32>) -> bool {
-    22_i32 == *x
-}
-
-fn c<T: I32Iterator>(x: &mut T) -> Option<i32> {
-    x.next()
-}
-
-fn d<T: SendSyncAlias>() {
-    is_send_and_sync::<T>();
-}
-
-fn is_send_and_sync<T: Send + Sync>() {}
-
-fn main() {
-    let both = a::<i32>();
-    assert_eq!(both.0, 0);
-    assert_eq!(both.1, 0);
-    let both: (i32, i32) = a();
-    assert_eq!(both.0, 0);
-    assert_eq!(both.1, 0);
-
-    assert!(b(&22));
-
-    assert_eq!(c(&mut vec![22].into_iter()), Some(22));
-
-    d::<i32>();
-}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.rs b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.rs
deleted file mode 100644 (file)
index 14edfdd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// aux-build:trait_alias.rs
-
-#![feature(trait_alias)]
-
-extern crate trait_alias;
-
-use std::rc::Rc;
-use trait_alias::SendSync;
-
-fn use_alias<T: SendSync>() {}
-
-fn main() {
-    use_alias::<u32>();
-    use_alias::<Rc<u32>>();
-    //~^ ERROR `Rc<u32>` cannot be sent between threads safely [E0277]
-    //~^^ ERROR `Rc<u32>` cannot be shared between threads safely [E0277]
-}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr
deleted file mode 100644 (file)
index 60a4a46..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0277]: `Rc<u32>` cannot be sent between threads safely
-  --> $DIR/trait-alias-cross-crate.rs:14:17
-   |
-LL | fn use_alias<T: SendSync>() {}
-   |                 -------- required by this bound in `use_alias`
-...
-LL |     use_alias::<Rc<u32>>();
-   |                 ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
-   |
-   = help: the trait `Send` is not implemented for `Rc<u32>`
-
-error[E0277]: `Rc<u32>` cannot be shared between threads safely
-  --> $DIR/trait-alias-cross-crate.rs:14:17
-   |
-LL | fn use_alias<T: SendSync>() {}
-   |                 -------- required by this bound in `use_alias`
-...
-LL |     use_alias::<Rc<u32>>();
-   |                 ^^^^^^^ `Rc<u32>` cannot be shared between threads safely
-   |
-   = help: the trait `Sync` is not implemented for `Rc<u32>`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-impl.rs b/src/test/ui/traits/trait-alias/trait-alias-impl.rs
deleted file mode 100644 (file)
index 6e35793..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#![feature(trait_alias)]
-
-trait DefaultAlias = Default;
-
-impl DefaultAlias for () {} //~ ERROR expected trait, found trait alias
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-impl.stderr b/src/test/ui/traits/trait-alias/trait-alias-impl.stderr
deleted file mode 100644 (file)
index 301db4f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0404]: expected trait, found trait alias `DefaultAlias`
-  --> $DIR/trait-alias-impl.rs:5:6
-   |
-LL | impl DefaultAlias for () {}
-   |      ^^^^^^^^^^^^ not a trait
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0404`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs b/src/test/ui/traits/trait-alias/trait-alias-maybe-bound.rs
deleted file mode 100644 (file)
index 284baa4..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// build-pass (FIXME(62277): could be check-pass?)
-
-// Test that `dyn ... + ?Sized + ...` resulting from the expansion of trait aliases is okay.
-
-#![feature(trait_alias)]
-
-trait Foo {}
-
-trait S = ?Sized;
-
-// Nest a couple of levels deep:
-trait _0 = S;
-trait _1 = _0;
-
-// Straight list expansion:
-type _T0 = dyn _1 + Foo;
-
-// In second position:
-type _T1 = dyn Foo + _1;
-
-// ... and with an auto trait:
-type _T2 = dyn Foo + Send + _1;
-
-// Twice:
-trait _2 = _1 + _1;
-
-type _T3 = dyn _2 + Foo;
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs
deleted file mode 100644 (file)
index 88feb89..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// The purpose of this test is to demonstrate that duplicating object safe traits
-// that are not auto traits is rejected with trait aliases even though one could
-// reasonably accept this.
-
-#![feature(trait_alias)]
-
-use std::marker::Unpin;
-
-// Some arbitrary object-safe trait:
-trait Obj {}
-
-// Nest a few levels deep:
-trait _0 = Obj;
-trait _1 = _0;
-
-type _T00 = dyn _0 + _0;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T01 = dyn _1 + _0;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T02 = dyn _1 + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T03 = dyn Obj + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T04 = dyn _1 + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Nest some more and in weird ways:
-
-trait _2 = _0 + _1;
-trait _3 = Obj;
-trait _4 = _3;
-
-type _T10 = dyn _2 + _3;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T11 = dyn _3 + _2;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T12 = dyn Obj + _2;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T13 = dyn _2 + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T14 = dyn _1 + _3;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T15 = dyn _3 + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T16 = dyn _1 + _4;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T17 = dyn _4 + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Include auto traits:
-
-trait _5 = Obj + Send;
-
-type _T20 = dyn _5 + _5;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T21 = dyn Obj + _5;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T22 = dyn _5 + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T23 = dyn _5 + Send + Sync + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Also nest:
-
-trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
-
-type _T30 = dyn _6;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T31 = dyn _6 + Send;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T32 = dyn Send + _6;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Nest some more:
-
-trait _7 = _5 + Sync;
-trait _8 = Unpin + _7;
-
-type _T40 = dyn _8 + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T41 = dyn Obj + _8;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T42 = dyn _8 + _4;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T43 = dyn _4 + _8;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T44 = dyn _4 + Send + Sync + _8;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Take higher ranked types into account.
-
-// Note that `'a` and `'b` are intentionally different to make sure we consider
-// them semantically the same.
-trait ObjL<'l> {}
-trait _9 = for<'a> ObjL<'a>;
-trait _10 = for<'b> ObjL<'b>;
-type _T50 = dyn _9 + _10;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-trait ObjT<T> {}
-trait _11 = ObjT<for<'a> fn(&'a u8)>;
-trait _12 = ObjT<for<'b> fn(&'b u8)>;
-type _T60 = dyn _11 + _12;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr
deleted file mode 100644 (file)
index b297d54..0000000
+++ /dev/null
@@ -1,527 +0,0 @@
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:16:22
-   |
-LL | trait _0 = Obj;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-...
-LL | type _T00 = dyn _0 + _0;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:19:22
-   |
-LL | trait _0 = Obj;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | type _T01 = dyn _1 + _0;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:22:22
-   |
-LL | trait _0 = Obj;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _1 = _0;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-...
-LL | type _T02 = dyn _1 + _1;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:25:23
-   |
-LL | trait _0 = Obj;
-   |            --- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | type _T03 = dyn Obj + _1;
-   |                 ---   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:28:22
-   |
-LL | trait _0 = Obj;
-   |            --- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | type _T04 = dyn _1 + Obj;
-   |                 --   ^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:37:17
-   |
-LL | trait _0 = Obj;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _2 = _0 + _1;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T10 = dyn _2 + _3;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:40:22
-   |
-LL | trait _0 = Obj;
-   |            --- additional non-auto trait
-...
-LL | trait _2 = _0 + _1;
-   |            -- referenced here (additional use)
-LL | trait _3 = Obj;
-   |            --- first non-auto trait
-...
-LL | type _T11 = dyn _3 + _2;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:43:23
-   |
-LL | trait _0 = Obj;
-   |            --- additional non-auto trait
-...
-LL | trait _2 = _0 + _1;
-   |            -- referenced here (additional use)
-...
-LL | type _T12 = dyn Obj + _2;
-   |                 ---   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:46:17
-   |
-LL | trait _0 = Obj;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _2 = _0 + _1;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T13 = dyn _2 + Obj;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:49:22
-   |
-LL | trait _0 = Obj;
-   |            --- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _3 = Obj;
-   |            --- additional non-auto trait
-...
-LL | type _T14 = dyn _1 + _3;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:52:22
-   |
-LL | trait _0 = Obj;
-   |            --- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _3 = Obj;
-   |            --- first non-auto trait
-...
-LL | type _T15 = dyn _3 + _1;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:55:22
-   |
-LL | trait _0 = Obj;
-   |            --- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _3 = Obj;
-   |            --- additional non-auto trait
-LL | trait _4 = _3;
-   |            -- referenced here (additional use)
-...
-LL | type _T16 = dyn _1 + _4;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:58:22
-   |
-LL | trait _0 = Obj;
-   |            --- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _3 = Obj;
-   |            --- first non-auto trait
-LL | trait _4 = _3;
-   |            -- referenced here (first use)
-...
-LL | type _T17 = dyn _4 + _1;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:65:22
-   |
-LL | trait _5 = Obj + Send;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | 
-LL | type _T20 = dyn _5 + _5;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:68:23
-   |
-LL | trait _5 = Obj + Send;
-   |            --- additional non-auto trait
-...
-LL | type _T21 = dyn Obj + _5;
-   |                 ---   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:71:22
-   |
-LL | trait _5 = Obj + Send;
-   |            --- first non-auto trait
-...
-LL | type _T22 = dyn _5 + Obj;
-   |                 --   ^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:74:36
-   |
-LL | trait _5 = Obj + Send;
-   |            --- first non-auto trait
-...
-LL | type _T23 = dyn _5 + Send + Sync + Obj;
-   |                 --                 ^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:81:17
-   |
-LL | trait _5 = Obj + Send;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-...
-LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-LL | 
-LL | type _T30 = dyn _6;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:84:17
-   |
-LL | trait _5 = Obj + Send;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-...
-LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T31 = dyn _6 + Send;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:87:24
-   |
-LL | trait _5 = Obj + Send;
-   |            ---
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-...
-LL | trait _6 = _5 + _5; // ==> Obj + Send + Obj + Send
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T32 = dyn Send + _6;
-   |                        ^^
-   |                        |
-   |                        trait alias used in trait object type (additional use)
-   |                        trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:95:22
-   |
-LL | trait _5 = Obj + Send;
-   |            --- first non-auto trait
-...
-LL | trait _7 = _5 + Sync;
-   |            -- referenced here (first use)
-LL | trait _8 = Unpin + _7;
-   |                    -- referenced here (first use)
-LL | 
-LL | type _T40 = dyn _8 + Obj;
-   |                 --   ^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:98:23
-   |
-LL | trait _5 = Obj + Send;
-   |            --- additional non-auto trait
-...
-LL | trait _7 = _5 + Sync;
-   |            -- referenced here (additional use)
-LL | trait _8 = Unpin + _7;
-   |                    -- referenced here (additional use)
-...
-LL | type _T41 = dyn Obj + _8;
-   |                 ---   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:101:22
-   |
-LL | trait _3 = Obj;
-   |            --- additional non-auto trait
-LL | trait _4 = _3;
-   |            -- referenced here (additional use)
-...
-LL | trait _5 = Obj + Send;
-   |            --- first non-auto trait
-...
-LL | trait _7 = _5 + Sync;
-   |            -- referenced here (first use)
-LL | trait _8 = Unpin + _7;
-   |                    -- referenced here (first use)
-...
-LL | type _T42 = dyn _8 + _4;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:104:22
-   |
-LL | trait _3 = Obj;
-   |            --- first non-auto trait
-LL | trait _4 = _3;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Obj + Send;
-   |            --- additional non-auto trait
-...
-LL | trait _7 = _5 + Sync;
-   |            -- referenced here (additional use)
-LL | trait _8 = Unpin + _7;
-   |                    -- referenced here (additional use)
-...
-LL | type _T43 = dyn _4 + _8;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:107:36
-   |
-LL | trait _3 = Obj;
-   |            --- first non-auto trait
-LL | trait _4 = _3;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Obj + Send;
-   |            --- additional non-auto trait
-...
-LL | trait _7 = _5 + Sync;
-   |            -- referenced here (additional use)
-LL | trait _8 = Unpin + _7;
-   |                    -- referenced here (additional use)
-...
-LL | type _T44 = dyn _4 + Send + Sync + _8;
-   |                 --                 ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:117:22
-   |
-LL | trait _9 = for<'a> ObjL<'a>;
-   |            ---------------- first non-auto trait
-LL | trait _10 = for<'b> ObjL<'b>;
-   |             ---------------- additional non-auto trait
-LL | type _T50 = dyn _9 + _10;
-   |                 --   ^^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: for<'a> ObjL<'a> + for<'b> ObjL<'b> {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-duplicates.rs:123:23
-   |
-LL | trait _11 = ObjT<for<'a> fn(&'a u8)>;
-   |             ------------------------ first non-auto trait
-LL | trait _12 = ObjT<for<'b> fn(&'b u8)>;
-   |             ------------------------ additional non-auto trait
-LL | type _T60 = dyn _11 + _12;
-   |                 ---   ^^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)> {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error: aborting due to 27 previous errors
-
-For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs b/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.rs
deleted file mode 100644 (file)
index 4dad8c0..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-// The purpose of this test is to demonstrate that trait alias expansion
-// preserves the rule that `dyn Trait` may only reference one non-auto trait.
-
-#![feature(trait_alias)]
-
-use std::marker::Unpin;
-
-// Some arbitrary object-safe traits:
-trait ObjA {}
-trait ObjB {}
-
-// Nest a few levels deep:
-trait _0 = ObjA;
-trait _1 = _0;
-
-type _T00 = dyn _0 + ObjB;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T01 = dyn ObjB + _0;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T02 = dyn ObjB + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T03 = dyn _1 + ObjB;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Nest some more and in weird ways:
-
-trait _2 = ObjB;
-trait _3 = _2;
-trait _4 = _3;
-
-type _T10 = dyn _2 + _3;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T11 = dyn _3 + _2;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T12 = dyn _2 + _4;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T13 = dyn _4 + _2;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Include auto traits:
-
-trait _5 = Sync + ObjB + Send;
-
-type _T20 = dyn _5 + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T21 = dyn _1 + _5;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T22 = dyn _5 + ObjA;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T23 = dyn ObjA + _5;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T24 = dyn Send + _5 + _1 + Sync;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T25 = dyn _1 + Sync + _5 + Send;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T26 = dyn Sync + Send + _5 + ObjA;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T27 = dyn Send + Sync + ObjA + _5;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Also nest:
-
-trait _6 = _1 + _5;
-trait _7 = _6;
-trait _8 = _7;
-
-type _T30 = dyn _6;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T31 = dyn _6 + Send;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T32 = dyn Send + _6;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T33 = dyn _8;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T34 = dyn _8 + Send;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T35 = dyn Send + _8;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Nest some more:
-
-trait _9 = _5 + Sync;
-trait _10 = Unpin + _9;
-
-type _T40 = dyn _10 + ObjA;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T41 = dyn ObjA + _10;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T42 = dyn _10 + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T43 = dyn Send + _10 + Sync + ObjA;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T44 = dyn ObjA + _10 + Send + Sync;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _T45 = dyn Sync + Send + _10 + _1;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr b/src/test/ui/traits/trait-alias/trait-alias-no-extra-traits.stderr
deleted file mode 100644 (file)
index 1d7b3fa..0000000
+++ /dev/null
@@ -1,579 +0,0 @@
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:16:22
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-...
-LL | type _T00 = dyn _0 + ObjB;
-   |                 --   ^^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:19:24
-   |
-LL | trait _0 = ObjA;
-   |            ---- additional non-auto trait
-...
-LL | type _T01 = dyn ObjB + _0;
-   |                 ----   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:22:24
-   |
-LL | trait _0 = ObjA;
-   |            ---- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | type _T02 = dyn ObjB + _1;
-   |                 ----   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:25:22
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | type _T03 = dyn _1 + ObjB;
-   |                 --   ^^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:34:22
-   |
-LL | trait _2 = ObjB;
-   |            ----
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _3 = _2;
-   |            -- referenced here (additional use)
-...
-LL | type _T10 = dyn _2 + _3;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:37:22
-   |
-LL | trait _2 = ObjB;
-   |            ----
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _3 = _2;
-   |            -- referenced here (first use)
-...
-LL | type _T11 = dyn _3 + _2;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:40:22
-   |
-LL | trait _2 = ObjB;
-   |            ----
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _3 = _2;
-   |            -- referenced here (additional use)
-LL | trait _4 = _3;
-   |            -- referenced here (additional use)
-...
-LL | type _T12 = dyn _2 + _4;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:43:22
-   |
-LL | trait _2 = ObjB;
-   |            ----
-   |            |
-   |            additional non-auto trait
-   |            first non-auto trait
-LL | trait _3 = _2;
-   |            -- referenced here (first use)
-LL | trait _4 = _3;
-   |            -- referenced here (first use)
-...
-LL | type _T13 = dyn _4 + _2;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:50:22
-   |
-LL | trait _0 = ObjA;
-   |            ---- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-LL | 
-LL | type _T20 = dyn _5 + _1;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:53:22
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | type _T21 = dyn _1 + _5;
-   |                 --   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:56:22
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | type _T22 = dyn _5 + ObjA;
-   |                 --   ^^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:59:24
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | type _T23 = dyn ObjA + _5;
-   |                 ----   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:62:29
-   |
-LL | trait _0 = ObjA;
-   |            ---- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | type _T24 = dyn Send + _5 + _1 + Sync;
-   |                        --   ^^ trait alias used in trait object type (additional use)
-   |                        |
-   |                        trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:65:29
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | type _T25 = dyn _1 + Sync + _5 + Send;
-   |                 --          ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:68:36
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | type _T26 = dyn Sync + Send + _5 + ObjA;
-   |                               --   ^^^^ additional non-auto trait
-   |                               |
-   |                               trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:71:38
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | type _T27 = dyn Send + Sync + ObjA + _5;
-   |                               ----   ^^ trait alias used in trait object type (additional use)
-   |                               |
-   |                               first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:80:17
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _6 = _1 + _5;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T30 = dyn _6;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:83:17
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _6 = _1 + _5;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T31 = dyn _6 + Send;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:86:24
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _6 = _1 + _5;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-...
-LL | type _T32 = dyn Send + _6;
-   |                        ^^
-   |                        |
-   |                        trait alias used in trait object type (additional use)
-   |                        trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:89:17
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _6 = _1 + _5;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-LL | trait _7 = _6;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-LL | trait _8 = _7;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-...
-LL | type _T33 = dyn _8;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:92:17
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _6 = _1 + _5;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-LL | trait _7 = _6;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-LL | trait _8 = _7;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-...
-LL | type _T34 = dyn _8 + Send;
-   |                 ^^
-   |                 |
-   |                 trait alias used in trait object type (additional use)
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:95:24
-   |
-LL | trait _0 = ObjA;
-   |            ---- first non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (first use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _6 = _1 + _5;
-   |            --   -- referenced here (additional use)
-   |            |
-   |            referenced here (first use)
-LL | trait _7 = _6;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-LL | trait _8 = _7;
-   |            --
-   |            |
-   |            referenced here (additional use)
-   |            referenced here (first use)
-...
-LL | type _T35 = dyn Send + _8;
-   |                        ^^
-   |                        |
-   |                        trait alias used in trait object type (additional use)
-   |                        trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:103:23
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | trait _9 = _5 + Sync;
-   |            -- referenced here (first use)
-LL | trait _10 = Unpin + _9;
-   |                     -- referenced here (first use)
-LL | 
-LL | type _T40 = dyn _10 + ObjA;
-   |                 ---   ^^^^ additional non-auto trait
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:106:24
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _9 = _5 + Sync;
-   |            -- referenced here (additional use)
-LL | trait _10 = Unpin + _9;
-   |                     -- referenced here (additional use)
-...
-LL | type _T41 = dyn ObjA + _10;
-   |                 ----   ^^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:109:23
-   |
-LL | trait _0 = ObjA;
-   |            ---- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | trait _9 = _5 + Sync;
-   |            -- referenced here (first use)
-LL | trait _10 = Unpin + _9;
-   |                     -- referenced here (first use)
-...
-LL | type _T42 = dyn _10 + _1;
-   |                 ---   ^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:112:37
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | trait _9 = _5 + Sync;
-   |            -- referenced here (first use)
-LL | trait _10 = Unpin + _9;
-   |                     -- referenced here (first use)
-...
-LL | type _T43 = dyn Send + _10 + Sync + ObjA;
-   |                        ---          ^^^^ additional non-auto trait
-   |                        |
-   |                        trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:115:24
-   |
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- additional non-auto trait
-...
-LL | trait _9 = _5 + Sync;
-   |            -- referenced here (additional use)
-LL | trait _10 = Unpin + _9;
-   |                     -- referenced here (additional use)
-...
-LL | type _T44 = dyn ObjA + _10 + Send + Sync;
-   |                 ----   ^^^ trait alias used in trait object type (additional use)
-   |                 |
-   |                 first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjA + ObjB {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/trait-alias-no-extra-traits.rs:118:37
-   |
-LL | trait _0 = ObjA;
-   |            ---- additional non-auto trait
-LL | trait _1 = _0;
-   |            -- referenced here (additional use)
-...
-LL | trait _5 = Sync + ObjB + Send;
-   |                   ---- first non-auto trait
-...
-LL | trait _9 = _5 + Sync;
-   |            -- referenced here (first use)
-LL | trait _10 = Unpin + _9;
-   |                     -- referenced here (first use)
-...
-LL | type _T45 = dyn Sync + Send + _10 + _1;
-   |                               ---   ^^ trait alias used in trait object type (additional use)
-   |                               |
-   |                               trait alias used in trait object type (first use)
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjB + ObjA {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error: aborting due to 28 previous errors
-
-For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-fail.rs b/src/test/ui/traits/trait-alias/trait-alias-object-fail.rs
deleted file mode 100644 (file)
index 5c753ff..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#![feature(trait_alias)]
-
-trait EqAlias = Eq;
-trait IteratorAlias = Iterator;
-
-fn main() {
-    let _: &dyn EqAlias = &123;
-    //~^ ERROR the trait `Eq` cannot be made into an object [E0038]
-    let _: &dyn IteratorAlias = &vec![123].into_iter();
-    //~^ ERROR must be specified
-}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr b/src/test/ui/traits/trait-alias/trait-alias-object-fail.stderr
deleted file mode 100644 (file)
index 1118a75..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0038]: the trait `Eq` cannot be made into an object
-  --> $DIR/trait-alias-object-fail.rs:7:13
-   |
-LL |     let _: &dyn EqAlias = &123;
-   |             ^^^^^^^^^^^ `Eq` cannot be made into an object
-   |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $SRC_DIR/core/src/cmp.rs:LL:COL
-   |
-LL | pub trait Eq: PartialEq<Self> {
-   |               ^^^^^^^^^^^^^^^ the trait cannot be made into an object because it uses `Self` as a type parameter
-
-error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified
-  --> $DIR/trait-alias-object-fail.rs:9:17
-   |
-LL |     let _: &dyn IteratorAlias = &vec![123].into_iter();
-   |                 ^^^^^^^^^^^^^ help: specify the associated type: `IteratorAlias<Item = Type>`
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0038, E0191.
-For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs b/src/test/ui/traits/trait-alias/trait-alias-object-wf.rs
deleted file mode 100644 (file)
index 1440f02..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-// check-pass
-
-// This test checks that trait objects involving trait aliases are well-formed.
-
-#![feature(trait_alias)]
-
-trait Obj {}
-
-trait _0 = Send + Sync;
-
-// Just auto traits:
-
-trait _1 = _0 + Send + Sync;
-
-use std::marker::Unpin;
-
-fn _f0() {
-    let _: Box<dyn _0>;
-    let _: Box<dyn _1>;
-    let _: Box<dyn Unpin + _1 + Send + Sync>;
-}
-
-// Include object safe traits:
-
-fn _f1() {
-    let _: Box<dyn Obj + _0>;
-    let _: Box<dyn Obj + _1>;
-    let _: Box<dyn Obj + _1 + _0>;
-}
-
-// And when the object safe trait is in a trait alias:
-
-trait _2 = Obj;
-
-fn _f2() {
-    let _: Box<dyn _2 + _0>;
-    let _: Box<dyn _2 + _1>;
-    let _: Box<dyn _2 + _1 + _0>;
-}
-
-// And it should also work when that trait is has auto traits to the right of it.
-
-trait _3 = Obj + Unpin;
-
-fn _f3() {
-    let _: Box<dyn _3 + _0>;
-    let _: Box<dyn _3 + _1>;
-    let _: Box<dyn _3 + _1 + _0>;
-}
-
-// Nest the trait deeply:
-
-trait _4 = _3;
-trait _5 = _4 + Sync + _0 + Send;
-trait _6 = _5 + Send + _1 + Sync;
-
-fn _f4() {
-    let _: Box<dyn _6 + _0>;
-    let _: Box<dyn _6 + _1>;
-    let _: Box<dyn _6 + _1 + _0>;
-}
-
-// Just nest the trait alone:
-
-trait _7 = _2;
-trait _8 = _7;
-trait _9 = _8;
-
-fn _f5() {
-    let _: Box<dyn _9>;
-}
-
-// First bound is auto trait:
-
-trait _10 = Send + Obj;
-trait _11 = Obj + Send;
-trait _12 = Sync + _11;
-trait _13 = Send + _12;
-
-fn f6() {
-    let _: Box<dyn _10>;
-    let _: Box<dyn _13>;
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-object.rs b/src/test/ui/traits/trait-alias/trait-alias-object.rs
deleted file mode 100644 (file)
index 12177cd..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-pass
-
-#![feature(trait_alias)]
-
-trait Foo = PartialEq<i32> + Send;
-trait Bar = Foo + Sync;
-
-trait I32Iterator = Iterator<Item = i32>;
-
-pub fn main() {
-    let a: &dyn Bar = &123;
-    assert!(*a == 123);
-    let b = Box::new(456) as Box<dyn Foo>;
-    assert!(*b == 456);
-
-    let c: &mut dyn I32Iterator = &mut vec![123].into_iter();
-    assert_eq!(c.next(), Some(123));
-}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-only-maybe-bound.rs b/src/test/ui/traits/trait-alias/trait-alias-only-maybe-bound.rs
deleted file mode 100644 (file)
index e4abf31..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test that `dyn ?Sized` (i.e., a trait object with only a maybe buond) is not allowed, when just
-// `?Sized` results from trait alias expansion.
-
-#![feature(trait_alias)]
-
-trait S = ?Sized;
-
-// Nest a couple of levels deep:
-trait _0 = S;
-trait _1 = _0;
-
-// Straight list expansion:
-type _T0 = dyn _1;
-//~^ ERROR at least one trait is required for an object type [E0224]
-
-// Twice:
-trait _2 = _1 + _1;
-
-type _T1 = dyn _2;
-//~^ ERROR at least one trait is required for an object type [E0224]
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-only-maybe-bound.stderr b/src/test/ui/traits/trait-alias/trait-alias-only-maybe-bound.stderr
deleted file mode 100644 (file)
index 594115d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/trait-alias-only-maybe-bound.rs:13:12
-   |
-LL | type _T0 = dyn _1;
-   |            ^^^^^^
-
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/trait-alias-only-maybe-bound.rs:19:12
-   |
-LL | type _T1 = dyn _2;
-   |            ^^^^^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0224`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.rs b/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.rs
deleted file mode 100644 (file)
index 039bbce..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![feature(trait_alias)]
-
-trait Foo {}
-auto trait A = Foo; //~ ERROR trait aliases cannot be `auto`
-unsafe trait B = Foo; //~ ERROR trait aliases cannot be `unsafe`
-
-trait C: Ord = Eq; //~ ERROR bounds are not allowed on trait aliases
-trait D: = Eq; //~ ERROR bounds are not allowed on trait aliases
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.stderr b/src/test/ui/traits/trait-alias/trait-alias-syntax-fail.stderr
deleted file mode 100644 (file)
index 18c2213..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-error: trait aliases cannot be `auto`
-  --> $DIR/trait-alias-syntax-fail.rs:4:1
-   |
-LL | auto trait A = Foo;
-   | ^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `auto`
-
-error: trait aliases cannot be `unsafe`
-  --> $DIR/trait-alias-syntax-fail.rs:5:1
-   |
-LL | unsafe trait B = Foo;
-   | ^^^^^^^^^^^^^^^^^^^^^ trait aliases cannot be `unsafe`
-
-error: bounds are not allowed on trait aliases
-  --> $DIR/trait-alias-syntax-fail.rs:7:8
-   |
-LL | trait C: Ord = Eq;
-   |        ^^^^^
-
-error: bounds are not allowed on trait aliases
-  --> $DIR/trait-alias-syntax-fail.rs:8:8
-   |
-LL | trait D: = Eq;
-   |        ^
-
-error: aborting due to 4 previous errors
-
diff --git a/src/test/ui/traits/trait-alias/trait-alias-syntax.rs b/src/test/ui/traits/trait-alias/trait-alias-syntax.rs
deleted file mode 100644 (file)
index 17557a5..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// run-pass
-
-#![feature(trait_alias)]
-
-trait SimpleAlias = Default;
-trait GenericAlias<T> = Iterator<Item = T>;
-trait Partial<T> = IntoIterator<Item = T>;
-trait SpecificAlias = GenericAlias<i32>;
-trait PartialEqRef<'a, T: 'a> = PartialEq<&'a T>;
-trait StaticAlias = 'static;
-
-trait Things<T> {}
-trait Romeo {}
-#[allow(dead_code)]
-struct The<T>(T);
-#[allow(dead_code)]
-struct Fore<T>(T);
-impl<T, U> Things<T> for The<U> {}
-impl<T> Romeo for Fore<T> {}
-
-trait WithWhere<Art, Thou> = Romeo + Romeo where Fore<(Art, Thou)>: Romeo;
-trait BareWhere<Wild, Are> = where The<Wild>: Things<Are>;
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-wf.rs b/src/test/ui/traits/trait-alias/trait-alias-wf.rs
deleted file mode 100644 (file)
index d10e2ab..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#![feature(trait_alias)]
-
-trait Foo {}
-trait A<T: Foo> {}
-trait B<T> = A<T>; //~ ERROR `T: Foo` is not satisfied
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr
deleted file mode 100644 (file)
index e0df763..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0277]: the trait bound `T: Foo` is not satisfied
-  --> $DIR/trait-alias-wf.rs:5:14
-   |
-LL | trait A<T: Foo> {}
-   |            --- required by this bound in `A`
-LL | trait B<T> = A<T>;
-   |              ^^^^ the trait `Foo` is not implemented for `T`
-   |
-help: consider restricting type parameter `T`
-   |
-LL | trait B<T: Foo> = A<T>;
-   |          ^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-alias/trait-alias.rs b/src/test/ui/traits/trait-alias/trait-alias.rs
deleted file mode 100644 (file)
index d8168f2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// run-pass
-
-#![feature(trait_alias)]
-
-pub trait Foo {}
-pub trait FooAlias = Foo;
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-as-struct-constructor.rs b/src/test/ui/traits/trait-as-struct-constructor.rs
deleted file mode 100644 (file)
index 13ebf9d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-trait TraitNotAStruct {}
-
-fn main() {
-    TraitNotAStruct{ value: 0 };
-    //~^ ERROR expected struct, variant or union type, found trait `TraitNotAStruct`
-}
diff --git a/src/test/ui/traits/trait-as-struct-constructor.stderr b/src/test/ui/traits/trait-as-struct-constructor.stderr
deleted file mode 100644 (file)
index e1d54fb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0574]: expected struct, variant or union type, found trait `TraitNotAStruct`
-  --> $DIR/trait-as-struct-constructor.rs:4:5
-   |
-LL |     TraitNotAStruct{ value: 0 };
-   |     ^^^^^^^^^^^^^^^ not a struct, variant or union type
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0574`.
diff --git a/src/test/ui/traits/trait-bounds-basic.rs b/src/test/ui/traits/trait-bounds-basic.rs
deleted file mode 100644 (file)
index 8c8a7eb..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(unconditional_recursion)]
-
-// pretty-expanded FIXME #23616
-
-trait Foo {
-}
-
-fn b(_x: Box<dyn Foo+Send>) {
-}
-
-fn c(x: Box<dyn Foo+Sync+Send>) {
-    e(x);
-}
-
-fn d(x: Box<dyn Foo+Send>) {
-    e(x);
-}
-
-fn e(x: Box<dyn Foo>) {
-    e(x);
-}
-
-pub fn main() { }
diff --git a/src/test/ui/traits/trait-bounds-impl-comparison-duplicates.rs b/src/test/ui/traits/trait-bounds-impl-comparison-duplicates.rs
deleted file mode 100644 (file)
index de6c2af..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// run-pass
-// Tests that type parameter bounds on an implementation need not match the
-// trait exactly, as long as the implementation doesn't demand *more* bounds
-// than the trait.
-
-// pretty-expanded FIXME #23616
-
-trait A {
-    fn foo<T: Eq + Ord>(&self);
-}
-
-impl A for isize {
-    fn foo<T: Ord>(&self) {} // Ord implies Eq, so this is ok.
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-bounds-in-arc.rs b/src/test/ui/traits/trait-bounds-in-arc.rs
deleted file mode 100644 (file)
index 941f66c..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-// run-pass
-#![allow(unused_must_use)]
-// Tests that a heterogeneous list of existential `dyn` types can be put inside an Arc
-// and shared between threads as long as all types fulfill Send.
-
-// ignore-emscripten no threads support
-
-#![feature(box_syntax)]
-
-use std::sync::Arc;
-use std::sync::mpsc::channel;
-use std::thread;
-
-trait Pet {
-    fn name(&self, blk: Box<dyn FnMut(&str)>);
-    fn num_legs(&self) -> usize;
-    fn of_good_pedigree(&self) -> bool;
-}
-
-struct Catte {
-    num_whiskers: usize,
-    name: String,
-}
-
-struct Dogge {
-    bark_decibels: usize,
-    tricks_known: usize,
-    name: String,
-}
-
-struct Goldfyshe {
-    swim_speed: usize,
-    name: String,
-}
-
-impl Pet for Catte {
-    fn name(&self, mut blk: Box<dyn FnMut(&str)>) { blk(&self.name) }
-    fn num_legs(&self) -> usize { 4 }
-    fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 }
-}
-impl Pet for Dogge {
-    fn name(&self, mut blk: Box<dyn FnMut(&str)>) { blk(&self.name) }
-    fn num_legs(&self) -> usize { 4 }
-    fn of_good_pedigree(&self) -> bool {
-        self.bark_decibels < 70 || self.tricks_known > 20
-    }
-}
-impl Pet for Goldfyshe {
-    fn name(&self, mut blk: Box<dyn FnMut(&str)>) { blk(&self.name) }
-    fn num_legs(&self) -> usize { 0 }
-    fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
-}
-
-pub fn main() {
-    let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_string() };
-    let dogge1 = Dogge {
-        bark_decibels: 100,
-        tricks_known: 42,
-        name: "alan_turing".to_string(),
-    };
-    let dogge2 = Dogge {
-        bark_decibels: 55,
-        tricks_known: 11,
-        name: "albert_einstein".to_string(),
-    };
-    let fishe = Goldfyshe {
-        swim_speed: 998,
-        name: "alec_guinness".to_string(),
-    };
-    let arc = Arc::new(vec![box catte  as Box<dyn Pet+Sync+Send>,
-                            box dogge1 as Box<dyn Pet+Sync+Send>,
-                            box fishe  as Box<dyn Pet+Sync+Send>,
-                            box dogge2 as Box<dyn Pet+Sync+Send>]);
-    let (tx1, rx1) = channel();
-    let arc1 = arc.clone();
-    let t1 = thread::spawn(move|| { check_legs(arc1); tx1.send(()); });
-    let (tx2, rx2) = channel();
-    let arc2 = arc.clone();
-    let t2 = thread::spawn(move|| { check_names(arc2); tx2.send(()); });
-    let (tx3, rx3) = channel();
-    let arc3 = arc.clone();
-    let t3 = thread::spawn(move|| { check_pedigree(arc3); tx3.send(()); });
-    rx1.recv();
-    rx2.recv();
-    rx3.recv();
-    t1.join();
-    t2.join();
-    t3.join();
-}
-
-fn check_legs(arc: Arc<Vec<Box<dyn Pet+Sync+Send>>>) {
-    let mut legs = 0;
-    for pet in arc.iter() {
-        legs += pet.num_legs();
-    }
-    assert!(legs == 12);
-}
-fn check_names(arc: Arc<Vec<Box<dyn Pet+Sync+Send>>>) {
-    for pet in arc.iter() {
-        pet.name(Box::new(|name| {
-            assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8);
-        }))
-    }
-}
-fn check_pedigree(arc: Arc<Vec<Box<dyn Pet+Sync+Send>>>) {
-    for pet in arc.iter() {
-        assert!(pet.of_good_pedigree());
-    }
-}
diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs b/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs
deleted file mode 100644 (file)
index 33c9f2f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-trait Foo {
-    fn dummy(&self) { }
-}
-
-// This should emit the less confusing error, not the more confusing one.
-
-fn foo(_x: Foo + Send) {
-    //~^ ERROR the size for values of type
-    //~| WARN trait objects without an explicit `dyn` are deprecated
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr
deleted file mode 100644 (file)
index 48eedc0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-warning: trait objects without an explicit `dyn` are deprecated
-  --> $DIR/trait-bounds-not-on-bare-trait.rs:7:12
-   |
-LL | fn foo(_x: Foo + Send) {
-   |            ^^^^^^^^^^ help: use `dyn`: `dyn Foo + Send`
-   |
-   = note: `#[warn(bare_trait_objects)]` on by default
-
-error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time
-  --> $DIR/trait-bounds-not-on-bare-trait.rs:7:8
-   |
-LL | fn foo(_x: Foo + Send) {
-   |        ^^ doesn't have a size known at compile-time
-   |
-   = help: the trait `Sized` is not implemented for `(dyn Foo + Send + 'static)`
-   = help: unsized fn params are gated as an unstable feature
-help: function arguments must have a statically known size, borrowed types always have a known size
-   |
-LL | fn foo(&_x: Foo + Send) {
-   |        ^
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-not-on-struct.rs b/src/test/ui/traits/trait-bounds-not-on-struct.rs
deleted file mode 100644 (file)
index 8633e9d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// We don't need those errors. Ideally we would silence them, but to do so we need to move the
-// lint from being an early-lint during parsing to a late-lint, because it needs to be aware of
-// the types involved.
-#![allow(bare_trait_objects)]
-
-struct Foo;
-
-fn foo(_x: Box<Foo + Send>) { } //~ ERROR expected trait, found struct `Foo`
-
-type TypeAlias<T> = Box<dyn Vec<T>>; //~ ERROR expected trait, found struct `Vec`
-
-struct A;
-fn a() -> A + 'static { //~ ERROR expected trait, found
-    A
-}
-fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) { //~ ERROR expected trait, found
-    panic!()
-}
-fn c() -> 'static + A { //~ ERROR expected trait, found
-    A
-}
-fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) { //~ ERROR expected trait, found
-    panic!()
-}
-fn e() -> 'static + A + 'static { //~ ERROR expected trait, found
-//~^ ERROR only a single explicit lifetime bound is permitted
-    A
-}
-fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) { //~ ERROR expected trait, found
-//~^ ERROR only a single explicit lifetime bound is permitted
-    panic!()
-}
-struct Traitor;
-trait Trait {}
-fn g() -> Traitor + 'static { //~ ERROR expected trait, found struct `Traitor`
-    A
-}
-fn main() {}
diff --git a/src/test/ui/traits/trait-bounds-not-on-struct.stderr b/src/test/ui/traits/trait-bounds-not-on-struct.stderr
deleted file mode 100644 (file)
index 0f97e3b..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-error[E0226]: only a single explicit lifetime bound is permitted
-  --> $DIR/trait-bounds-not-on-struct.rs:25:25
-   |
-LL | fn e() -> 'static + A + 'static {
-   |                         ^^^^^^^
-
-error[E0226]: only a single explicit lifetime bound is permitted
-  --> $DIR/trait-bounds-not-on-struct.rs:29:53
-   |
-LL | fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) {
-   |                                                     ^^
-
-error[E0404]: expected trait, found struct `Foo`
-  --> $DIR/trait-bounds-not-on-struct.rs:8:16
-   |
-LL | fn foo(_x: Box<Foo + Send>) { }
-   |                ^^^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:8:22
-   |
-LL | fn foo(_x: Box<Foo + Send>) { }
-   |                ---   ^^^^ ...because of this bound
-   |                |
-   |                expected this type to be a trait...
-
-error[E0404]: expected trait, found struct `Vec`
-  --> $DIR/trait-bounds-not-on-struct.rs:10:29
-   |
-LL | type TypeAlias<T> = Box<dyn Vec<T>>;
-   |                             ^^^^^^ not a trait
-
-error[E0404]: expected trait, found struct `A`
-  --> $DIR/trait-bounds-not-on-struct.rs:13:11
-   |
-LL | fn a() -> A + 'static {
-   |           ^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:13:15
-   |
-LL | fn a() -> A + 'static {
-   |           -   ^^^^^^^ ...because of this bound
-   |           |
-   |           expected this type to be a trait...
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn a() -> A {
-   |           --
-
-error[E0404]: expected trait, found enum `Result`
-  --> $DIR/trait-bounds-not-on-struct.rs:16:34
-   |
-LL | fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) {
-   |                                  ^^^^^^^^^^^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:16:48
-   |
-LL | fn b<'a,T,E>(iter: Iterator<Item=Result<T,E> + 'a>) {
-   |                                  -----------   ^^ ...because of this bound
-   |                                  |
-   |                                  expected this type to be a trait...
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn b<'a,T,E>(iter: Iterator<Item=Result<T,E>>) {
-   |                                            --
-
-error[E0404]: expected trait, found struct `A`
-  --> $DIR/trait-bounds-not-on-struct.rs:19:21
-   |
-LL | fn c() -> 'static + A {
-   |                     ^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:19:11
-   |
-LL | fn c() -> 'static + A {
-   |           ^^^^^^^   - expected this type to be a trait...
-   |           |
-   |           ...because of this bound
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn c() -> A {
-   |          --
-
-error[E0404]: expected trait, found enum `Result`
-  --> $DIR/trait-bounds-not-on-struct.rs:22:39
-   |
-LL | fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) {
-   |                                       ^^^^^^^^^^^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:22:34
-   |
-LL | fn d<'a,T,E>(iter: Iterator<Item='a + Result<T,E>>) {
-   |                                  ^^   ----------- expected this type to be a trait...
-   |                                  |
-   |                                  ...because of this bound
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn d<'a,T,E>(iter: Iterator<Item=Result<T,E>>) {
-   |                                 --
-
-error[E0404]: expected trait, found struct `A`
-  --> $DIR/trait-bounds-not-on-struct.rs:25:21
-   |
-LL | fn e() -> 'static + A + 'static {
-   |                     ^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:25:11
-   |
-LL | fn e() -> 'static + A + 'static {
-   |           ^^^^^^^   -   ^^^^^^^ ...because of these bounds
-   |                     |
-   |                     expected this type to be a trait...
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn e() -> A {
-   |          ---
-
-error[E0404]: expected trait, found enum `Result`
-  --> $DIR/trait-bounds-not-on-struct.rs:29:39
-   |
-LL | fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) {
-   |                                       ^^^^^^^^^^^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:29:34
-   |
-LL | fn f<'a,T,E>(iter: Iterator<Item='a + Result<T,E> + 'a>) {
-   |                                  ^^   -----------   ^^ ...because of these bounds
-   |                                       |
-   |                                       expected this type to be a trait...
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn f<'a,T,E>(iter: Iterator<Item=Result<T,E>>) {
-   |                                 --         --
-
-error[E0404]: expected trait, found struct `Traitor`
-  --> $DIR/trait-bounds-not-on-struct.rs:35:11
-   |
-LL | trait Trait {}
-   | ----------- similarly named trait `Trait` defined here
-LL | fn g() -> Traitor + 'static {
-   |           ^^^^^^^ not a trait
-   |
-help: `+` is used to constrain a "trait object" type with lifetimes or auto-traits; structs and enums can't be bound in that way
-  --> $DIR/trait-bounds-not-on-struct.rs:35:21
-   |
-LL | fn g() -> Traitor + 'static {
-   |           -------   ^^^^^^^ ...because of this bound
-   |           |
-   |           expected this type to be a trait...
-help: if you meant to use a type and not a trait here, remove the bounds
-   |
-LL | fn g() -> Traitor {
-   |                 --
-help: a trait with a similar name exists
-   |
-LL | fn g() -> Trait + 'static {
-   |           ^^^^^
-
-error: aborting due to 11 previous errors
-
-Some errors have detailed explanations: E0226, E0404.
-For more information about an error, try `rustc --explain E0226`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.rs
deleted file mode 100644 (file)
index 6a6fcf5..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-trait Trait {}
-
-struct Foo<T:Trait> {
-    x: T,
-}
-
-enum Bar<T:Trait> {
-    ABar(isize),
-    BBar(T),
-    CBar(usize),
-}
-
-fn explode(x: Foo<u32>) {}
-//~^ ERROR E0277
-
-fn kaboom(y: Bar<f32>) {}
-//~^ ERROR E0277
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr
deleted file mode 100644 (file)
index 6ca8ce0..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0277]: the trait bound `u32: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:13:15
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL | fn explode(x: Foo<u32>) {}
-   |               ^^^^^^^^ the trait `Trait` is not implemented for `u32`
-
-error[E0277]: the trait bound `f32: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:16:14
-   |
-LL | enum Bar<T:Trait> {
-   |            ----- required by this bound in `Bar`
-...
-LL | fn kaboom(y: Bar<f32>) {}
-   |              ^^^^^^^^ the trait `Trait` is not implemented for `f32`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.rs
deleted file mode 100644 (file)
index d379499..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-trait Trait {}
-
-struct Foo<T:Trait> {
-    x: T,
-}
-
-enum Bar<T:Trait> {
-    ABar(isize),
-    BBar(T),
-    CBar(usize),
-}
-
-trait PolyTrait<T>
-{
-    fn whatever(&self, t: T) {}
-}
-
-struct Struct;
-
-impl PolyTrait<Foo<u16>> for Struct {
-//~^ ERROR E0277
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr
deleted file mode 100644 (file)
index 87271e7..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0277]: the trait bound `u16: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-in-impls.rs:20:6
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL | impl PolyTrait<Foo<u16>> for Struct {
-   |      ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u16`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.rs
deleted file mode 100644 (file)
index 21c0ce8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-trait Trait {
-    fn dummy(&self) { }
-}
-
-struct Foo<T:Trait> {
-    x: T,
-}
-
-fn main() {
-    let foo = Foo {
-    //~^ ERROR E0277
-        x: 3
-    };
-
-    let baz: Foo<usize> = loop { };
-    //~^ ERROR E0277
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr
deleted file mode 100644 (file)
index df016a7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0277]: the trait bound `usize: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:15:14
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL |     let baz: Foo<usize> = loop { };
-   |              ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
-
-error[E0277]: the trait bound `{integer}: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:10:15
-   |
-LL | struct Foo<T:Trait> {
-   | ------------------- required by `Foo`
-...
-LL |     let foo = Foo {
-   |               ^^^ the trait `Trait` is not implemented for `{integer}`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-rpass.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-rpass.rs
deleted file mode 100644 (file)
index 4dc4fec..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(unused_variables)]
-// pretty-expanded FIXME #23616
-
-trait U {}
-trait T<X: U> { fn get(self) -> X; }
-
-trait S2<Y: U> {
-    fn m(x: Box<dyn T<Y>+'static>) {}
-}
-
-struct St<X: U> {
-    f: Box<dyn T<X>+'static>,
-}
-
-impl<X: U> St<X> {
-    fn blah() {}
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.rs
deleted file mode 100644 (file)
index df3f8b8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-trait Trait {
-    fn dummy(&self) { }
-}
-
-struct Foo<T:Trait> {
-    x: T,
-}
-
-static X: Foo<usize> = Foo {
-//~^ ERROR E0277
-    x: 1,
-};
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr
deleted file mode 100644 (file)
index 4b650e7..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0277]: the trait bound `usize: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-static.rs:9:11
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL | static X: Foo<usize> = Foo {
-   |           ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.rs
deleted file mode 100644 (file)
index 901a2c4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// aux-build:trait_bounds_on_structs_and_enums_xc.rs
-
-extern crate trait_bounds_on_structs_and_enums_xc;
-
-use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait};
-
-fn explode(x: Foo<usize>) {}
-//~^ ERROR E0277
-
-fn kaboom(y: Bar<f32>) {}
-//~^ ERROR E0277
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr
deleted file mode 100644 (file)
index 3e8c727..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-error[E0277]: the trait bound `usize: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-xc.rs:7:15
-   |
-LL | fn explode(x: Foo<usize>) {}
-   |               ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
-   | 
-  ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:5:18
-   |
-LL | pub struct Foo<T:Trait> {
-   |                  ----- required by this bound in `Foo`
-
-error[E0277]: the trait bound `f32: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-xc.rs:10:14
-   |
-LL | fn kaboom(y: Bar<f32>) {}
-   |              ^^^^^^^^ the trait `Trait` is not implemented for `f32`
-   | 
-  ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:9:16
-   |
-LL | pub enum Bar<T:Trait> {
-   |                ----- required by this bound in `Bar`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.rs
deleted file mode 100644 (file)
index 2a4ba96..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// aux-build:trait_bounds_on_structs_and_enums_xc.rs
-
-extern crate trait_bounds_on_structs_and_enums_xc;
-
-use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait};
-
-fn main() {
-    let foo = Foo {
-    //~^ ERROR E0277
-        x: 3
-    };
-    let bar: Bar<f64> = return;
-    //~^ ERROR E0277
-    let _ = bar;
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr
deleted file mode 100644 (file)
index 899e994..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0277]: the trait bound `f64: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-xc1.rs:12:14
-   |
-LL |     let bar: Bar<f64> = return;
-   |              ^^^^^^^^ the trait `Trait` is not implemented for `f64`
-   | 
-  ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:9:16
-   |
-LL | pub enum Bar<T:Trait> {
-   |                ----- required by this bound in `Bar`
-
-error[E0277]: the trait bound `{integer}: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums-xc1.rs:8:15
-   |
-LL |     let foo = Foo {
-   |               ^^^ the trait `Trait` is not implemented for `{integer}`
-   |
-   = note: required by `Foo`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums.rs b/src/test/ui/traits/trait-bounds-on-structs-and-enums.rs
deleted file mode 100644 (file)
index 024084f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-trait Trait {}
-
-struct Foo<T:Trait> {
-    x: T,
-}
-
-enum Bar<T:Trait> {
-    ABar(isize),
-    BBar(T),
-    CBar(usize),
-}
-
-impl<T> Foo<T> {
-//~^ ERROR `T: Trait` is not satisfied
-    fn uhoh() {}
-}
-
-struct Baz {
-    a: Foo<isize>, //~ ERROR E0277
-}
-
-enum Boo {
-    Quux(Bar<usize>), //~ ERROR E0277
-}
-
-struct Badness<U> {
-    b: Foo<U>, //~ ERROR E0277
-}
-
-enum MoreBadness<V> {
-    EvenMoreBadness(Bar<V>), //~ ERROR E0277
-}
-
-struct TupleLike(
-    Foo<i32>, //~ ERROR E0277
-);
-
-enum Enum {
-    DictionaryLike { field: Bar<u8> }, //~ ERROR E0277
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr
deleted file mode 100644 (file)
index d754983..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-error[E0277]: the trait bound `T: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:13:9
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL | impl<T> Foo<T> {
-   |         ^^^^^^ the trait `Trait` is not implemented for `T`
-   |
-help: consider restricting type parameter `T`
-   |
-LL | impl<T: Trait> Foo<T> {
-   |       ^^^^^^^
-
-error[E0277]: the trait bound `isize: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:19:8
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL |     a: Foo<isize>,
-   |        ^^^^^^^^^^ the trait `Trait` is not implemented for `isize`
-
-error[E0277]: the trait bound `usize: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:23:10
-   |
-LL | enum Bar<T:Trait> {
-   |            ----- required by this bound in `Bar`
-...
-LL |     Quux(Bar<usize>),
-   |          ^^^^^^^^^^ the trait `Trait` is not implemented for `usize`
-
-error[E0277]: the trait bound `U: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:27:8
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL |     b: Foo<U>,
-   |        ^^^^^^ the trait `Trait` is not implemented for `U`
-   |
-help: consider restricting type parameter `U`
-   |
-LL | struct Badness<U: Trait> {
-   |                 ^^^^^^^
-
-error[E0277]: the trait bound `V: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:31:21
-   |
-LL | enum Bar<T:Trait> {
-   |            ----- required by this bound in `Bar`
-...
-LL |     EvenMoreBadness(Bar<V>),
-   |                     ^^^^^^ the trait `Trait` is not implemented for `V`
-   |
-help: consider restricting type parameter `V`
-   |
-LL | enum MoreBadness<V: Trait> {
-   |                   ^^^^^^^
-
-error[E0277]: the trait bound `i32: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:35:5
-   |
-LL | struct Foo<T:Trait> {
-   |              ----- required by this bound in `Foo`
-...
-LL |     Foo<i32>,
-   |     ^^^^^^^^ the trait `Trait` is not implemented for `i32`
-
-error[E0277]: the trait bound `u8: Trait` is not satisfied
-  --> $DIR/trait-bounds-on-structs-and-enums.rs:39:29
-   |
-LL | enum Bar<T:Trait> {
-   |            ----- required by this bound in `Bar`
-...
-LL |     DictionaryLike { field: Bar<u8> },
-   |                             ^^^^^^^ the trait `Trait` is not implemented for `u8`
-
-error: aborting due to 7 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-recursion.rs b/src/test/ui/traits/trait-bounds-recursion.rs
deleted file mode 100644 (file)
index 0023ff6..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-trait I { fn i(&self) -> Self; }
-
-trait A<T:I> {
-    fn id(x:T) -> T { x.i() }
-}
-
-trait J<T> { fn j(&self) -> T; }
-
-trait B<T:J<T>> {
-    fn id(x:T) -> T { x.j() }
-}
-
-trait C {
-    fn id<T:J<T>>(x:T) -> T { x.j() }
-}
-
-pub fn main() { }
diff --git a/src/test/ui/traits/trait-bounds-same-crate-name.rs b/src/test/ui/traits/trait-bounds-same-crate-name.rs
deleted file mode 100644 (file)
index 1012edb..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-// aux-build:crate_a1.rs
-// aux-build:crate_a2.rs
-
-// Issue 22750
-// This tests the extra help message reported when a trait bound
-// is not met but the struct implements a trait with the same path.
-
-fn main() {
-    let foo = {
-        extern crate crate_a2 as a;
-        a::Foo
-    };
-
-    let implements_no_traits = {
-        extern crate crate_a2 as a;
-        a::DoesNotImplementTrait
-    };
-
-    let other_variant_implements_mismatched_trait = {
-        extern crate crate_a2 as a;
-        a::ImplementsWrongTraitConditionally { _marker: std::marker::PhantomData::<isize> }
-    };
-
-    let other_variant_implements_correct_trait = {
-        extern crate crate_a1 as a;
-        a::ImplementsTraitForUsize { _marker: std::marker::PhantomData::<isize> }
-    };
-
-    {
-        extern crate crate_a1 as a;
-        a::try_foo(foo);
-        //~^ ERROR E0277
-        //~| trait impl with same name found
-        //~| perhaps two different versions of crate `crate_a2`
-
-        // We don't want to see the "version mismatch" help message here
-        // because `implements_no_traits` has no impl for `Foo`
-        a::try_foo(implements_no_traits);
-        //~^ ERROR E0277
-
-        // We don't want to see the "version mismatch" help message here
-        // because `other_variant_implements_mismatched_trait`
-        // does not have an impl for its `<isize>` variant,
-        // only for its `<usize>` variant.
-        a::try_foo(other_variant_implements_mismatched_trait);
-        //~^ ERROR E0277
-
-        // We don't want to see the "version mismatch" help message here
-        // because `ImplementsTraitForUsize` only has
-        // impls for the correct trait where the path is not misleading.
-        a::try_foo(other_variant_implements_correct_trait);
-        //~^ ERROR E0277
-        //~| the following implementations were found:
-    }
-}
diff --git a/src/test/ui/traits/trait-bounds-same-crate-name.stderr b/src/test/ui/traits/trait-bounds-same-crate-name.stderr
deleted file mode 100644 (file)
index af5ba88..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-error[E0277]: the trait bound `Foo: main::a::Bar` is not satisfied
-  --> $DIR/trait-bounds-same-crate-name.rs:31:20
-   |
-LL |         a::try_foo(foo);
-   |                    ^^^ the trait `main::a::Bar` is not implemented for `Foo`
-   | 
-  ::: $DIR/auxiliary/crate_a1.rs:3:24
-   |
-LL | pub fn try_foo(x: impl Bar) {}
-   |                        --- required by this bound in `try_foo`
-   |
-help: trait impl with same name found
-  --> $DIR/auxiliary/crate_a2.rs:5:1
-   |
-LL | impl Bar for Foo {}
-   | ^^^^^^^^^^^^^^^^^^^
-   = note: perhaps two different versions of crate `crate_a2` are being used?
-
-error[E0277]: the trait bound `DoesNotImplementTrait: main::a::Bar` is not satisfied
-  --> $DIR/trait-bounds-same-crate-name.rs:38:20
-   |
-LL |         a::try_foo(implements_no_traits);
-   |                    ^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `DoesNotImplementTrait`
-   | 
-  ::: $DIR/auxiliary/crate_a1.rs:3:24
-   |
-LL | pub fn try_foo(x: impl Bar) {}
-   |                        --- required by this bound in `try_foo`
-
-error[E0277]: the trait bound `ImplementsWrongTraitConditionally<isize>: main::a::Bar` is not satisfied
-  --> $DIR/trait-bounds-same-crate-name.rs:45:20
-   |
-LL |         a::try_foo(other_variant_implements_mismatched_trait);
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsWrongTraitConditionally<isize>`
-   | 
-  ::: $DIR/auxiliary/crate_a1.rs:3:24
-   |
-LL | pub fn try_foo(x: impl Bar) {}
-   |                        --- required by this bound in `try_foo`
-   |
-help: trait impl with same name found
-  --> $DIR/auxiliary/crate_a2.rs:13:1
-   |
-LL | impl Bar for ImplementsWrongTraitConditionally<isize> {}
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: perhaps two different versions of crate `crate_a2` are being used?
-
-error[E0277]: the trait bound `ImplementsTraitForUsize<isize>: main::a::Bar` is not satisfied
-  --> $DIR/trait-bounds-same-crate-name.rs:51:20
-   |
-LL |         a::try_foo(other_variant_implements_correct_trait);
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `main::a::Bar` is not implemented for `ImplementsTraitForUsize<isize>`
-   | 
-  ::: $DIR/auxiliary/crate_a1.rs:3:24
-   |
-LL | pub fn try_foo(x: impl Bar) {}
-   |                        --- required by this bound in `try_foo`
-   |
-   = help: the following implementations were found:
-             <ImplementsTraitForUsize<usize> as main::a::Bar>
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-bounds-sugar.rs b/src/test/ui/traits/trait-bounds-sugar.rs
deleted file mode 100644 (file)
index 65b6f6f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Tests for "default" bounds inferred for traits with no bounds list.
-
-trait Foo {}
-
-fn a(_x: Box<dyn Foo + Send>) {
-}
-
-fn b(_x: &'static (dyn Foo + 'static)) {
-}
-
-fn c(x: Box<dyn Foo + Sync>) {
-    a(x); //~ ERROR mismatched types
-}
-
-fn d(x: &'static (dyn Foo + Sync)) {
-    b(x);
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-bounds-sugar.stderr b/src/test/ui/traits/trait-bounds-sugar.stderr
deleted file mode 100644 (file)
index 6bd335f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/trait-bounds-sugar.rs:12:7
-   |
-LL |     a(x);
-   |       ^ expected trait `Foo + Send`, found trait `Foo + Sync`
-   |
-   = note: expected struct `Box<(dyn Foo + Send + 'static)>`
-              found struct `Box<(dyn Foo + Sync + 'static)>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/trait-bounds.rs b/src/test/ui/traits/trait-bounds.rs
deleted file mode 100644 (file)
index 18382bb..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case)]
-
-trait connection {
-    fn read(&self) -> isize;
-}
-
-trait connection_factory<C:connection> {
-    fn create(&self) -> C;
-}
-
-type my_connection = ();
-type my_connection_factory = ();
-
-impl connection for () {
-    fn read(&self) -> isize { 43 }
-}
-
-impl connection_factory<my_connection> for my_connection_factory {
-    fn create(&self) -> my_connection { () }
-}
-
-pub fn main() {
-    let factory = ();
-    let connection = factory.create();
-    let result = connection.read();
-    assert_eq!(result, 43);
-}
diff --git a/src/test/ui/traits/trait-cache-issue-18209.rs b/src/test/ui/traits/trait-cache-issue-18209.rs
deleted file mode 100644 (file)
index 15676e4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-// Test that the cache results from the default method do not pollute
-// the cache for the later call in `load()`.
-//
-// See issue #18209.
-
-// pretty-expanded FIXME #23616
-
-pub trait Foo {
-    fn load_from() -> Box<Self>;
-    fn load() -> Box<Self> {
-        Foo::load_from()
-    }
-}
-
-pub fn load<M: Foo>() -> Box<M> {
-    Foo::load()
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-coercion-generic-bad.rs b/src/test/ui/traits/trait-coercion-generic-bad.rs
deleted file mode 100644 (file)
index 2e115c7..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-struct Struct {
-    person: &'static str
-}
-
-trait Trait<T> {
-    fn f(&self, x: T);
-}
-
-impl Trait<&'static str> for Struct {
-    fn f(&self, x: &'static str) {
-        println!("Hello, {}!", x);
-    }
-}
-
-fn main() {
-    let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
-    //~^ ERROR `Struct: Trait<isize>` is not satisfied
-    s.f(1);
-}
diff --git a/src/test/ui/traits/trait-coercion-generic-bad.stderr b/src/test/ui/traits/trait-coercion-generic-bad.stderr
deleted file mode 100644 (file)
index f2710de..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0277]: the trait bound `Struct: Trait<isize>` is not satisfied
-  --> $DIR/trait-coercion-generic-bad.rs:16:36
-   |
-LL |     let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" });
-   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<isize>` is not implemented for `Struct`
-   |
-   = help: the following implementations were found:
-             <Struct as Trait<&'static str>>
-   = note: required for the cast to the object type `dyn Trait<isize>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-coercion-generic-regions.rs b/src/test/ui/traits/trait-coercion-generic-regions.rs
deleted file mode 100644 (file)
index af478df..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-struct Struct {
-    person: &'static str
-}
-
-trait Trait<T> {
-    fn f(&self, x: T);
-}
-
-impl Trait<&'static str> for Struct {
-    fn f(&self, x: &'static str) {
-        println!("Hello, {}!", x);
-    }
-}
-
-fn main() {
-    let person = "Fred".to_string();
-    let person: &str = &person;  //~ ERROR `person` does not live long enough
-    let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person });
-}
diff --git a/src/test/ui/traits/trait-coercion-generic-regions.stderr b/src/test/ui/traits/trait-coercion-generic-regions.stderr
deleted file mode 100644 (file)
index d21b48e..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0597]: `person` does not live long enough
-  --> $DIR/trait-coercion-generic-regions.rs:17:24
-   |
-LL |     let person: &str = &person;
-   |                        ^^^^^^^
-   |                        |
-   |                        borrowed value does not live long enough
-   |                        assignment requires that `person` is borrowed for `'static`
-LL |     let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person });
-LL | }
-   | - `person` dropped here while still borrowed
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0597`.
diff --git a/src/test/ui/traits/trait-coercion-generic.rs b/src/test/ui/traits/trait-coercion-generic.rs
deleted file mode 100644 (file)
index bf4dda4..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-trait Trait<T> {
-    fn f(&self, x: T);
-}
-
-#[derive(Copy, Clone)]
-struct Struct {
-    x: isize,
-    y: isize,
-}
-
-impl Trait<&'static str> for Struct {
-    fn f(&self, x: &'static str) {
-        println!("Hi, {}!", x);
-    }
-}
-
-pub fn main() {
-    let a = Struct { x: 1, y: 2 };
-    let b: Box<dyn Trait<&'static str>> = Box::new(a);
-    b.f("Mary");
-    let c: &dyn Trait<&'static str> = &a;
-    c.f("Joe");
-}
diff --git a/src/test/ui/traits/trait-coercion.rs b/src/test/ui/traits/trait-coercion.rs
deleted file mode 100644 (file)
index cba33af..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(unused_mut)]
-#![allow(unused_variables)]
-#![feature(box_syntax)]
-
-use std::io::{self, Write};
-
-trait Trait {
-    fn f(&self);
-}
-
-#[derive(Copy, Clone)]
-struct Struct {
-    x: isize,
-    y: isize,
-}
-
-impl Trait for Struct {
-    fn f(&self) {
-        println!("Hi!");
-    }
-}
-
-fn foo(mut a: Box<dyn Write>) {}
-
-pub fn main() {
-    let a = Struct { x: 1, y: 2 };
-    let b: Box<dyn Trait> = Box::new(a);
-    b.f();
-    let c: &dyn Trait = &a;
-    c.f();
-
-    let out = io::stdout();
-    foo(Box::new(out));
-}
diff --git a/src/test/ui/traits/trait-composition-trivial.rs b/src/test/ui/traits/trait-composition-trivial.rs
deleted file mode 100644 (file)
index 90e5dcd..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-trait Foo {
-    fn foo(&self);
-}
-
-trait Bar : Foo {
-    fn bar(&self);
-}
-
-pub fn main() {}
diff --git a/src/test/ui/traits/trait-copy-guessing.rs b/src/test/ui/traits/trait-copy-guessing.rs
deleted file mode 100644 (file)
index f031dd9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// "guessing" in trait selection can affect `copy_or_move`. Check that this
-// is correctly handled. I am not sure what is the "correct" behaviour,
-// but we should at least not ICE.
-
-use std::mem;
-
-struct U([u8; 1337]);
-
-struct S<'a,T:'a>(&'a T);
-impl<'a, T> Clone for S<'a, T> { fn clone(&self) -> Self { S(self.0) } }
-/// This impl triggers inference "guessing" - S<_>: Copy => _ = U
-impl<'a> Copy for S<'a, Option<U>> {}
-
-fn assert_impls_fn<R,T: Fn()->R>(_: &T){}
-
-fn main() {
-    let n = None;
-    let e = S(&n);
-    let f = || {
-        // S being copy is critical for this to work
-        drop(e);
-        mem::size_of_val(e.0)
-    };
-    assert_impls_fn(&f);
-    assert_eq!(f(), 1337+1);
-
-    assert_eq!((|| {
-        // S being Copy is not critical here, but
-        // we check it anyway.
-        let n = None;
-        let e = S(&n);
-        let ret = mem::size_of_val(e.0);
-        drop(e);
-        ret
-    })(), 1337+1);
-}
diff --git a/src/test/ui/traits/trait-default-method-bound-subst.rs b/src/test/ui/traits/trait-default-method-bound-subst.rs
deleted file mode 100644 (file)
index 6a5d5c8..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-pass
-
-
-trait A<T> {
-    fn g<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
-}
-
-impl A<i32> for i32 { }
-impl<T> A<T> for u32 { }
-
-fn f<T, U, V: A<T>>(i: V, j: T, k: U) -> (T, U) {
-    i.g(j, k)
-}
-
-pub fn main () {
-    assert_eq!(f(0, 1, 2), (1, 2));
-    assert_eq!(f(0, 1, 2), (1, 2));
-}
diff --git a/src/test/ui/traits/trait-default-method-bound-subst2.rs b/src/test/ui/traits/trait-default-method-bound-subst2.rs
deleted file mode 100644 (file)
index 78eabba..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// run-pass
-
-
-trait A<T> {
-    fn g(&self, x: T) -> T { x }
-}
-
-impl A<isize> for isize { }
-
-fn f<T, V: A<T>>(i: V, j: T) -> T {
-    i.g(j)
-}
-
-pub fn main () {
-    assert_eq!(f(0, 2), 2);
-}
diff --git a/src/test/ui/traits/trait-default-method-bound-subst3.rs b/src/test/ui/traits/trait-default-method-bound-subst3.rs
deleted file mode 100644 (file)
index dd39dec..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// run-pass
-
-
-trait A {
-    fn g<T>(&self, x: T, y: T) -> (T, T) { (x, y) }
-}
-
-impl A for isize { }
-
-fn f<T, V: A>(i: V, j: T, k: T) -> (T, T) {
-    i.g(j, k)
-}
-
-pub fn main () {
-    assert_eq!(f(0, 1, 2), (1, 2));
-    assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8));
-}
diff --git a/src/test/ui/traits/trait-default-method-bound-subst4.rs b/src/test/ui/traits/trait-default-method-bound-subst4.rs
deleted file mode 100644 (file)
index ef13306..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-#![allow(unused_variables)]
-
-
-trait A<T> {
-    fn g(&self, x: usize) -> usize { x }
-    fn h(&self, x: T) { }
-}
-
-impl<T> A<T> for isize { }
-
-fn f<T, V: A<T>>(i: V, j: usize) -> usize {
-    i.g(j)
-}
-
-pub fn main () {
-    assert_eq!(f::<f64, isize>(0, 2), 2);
-    assert_eq!(f::<usize, isize>(0, 2), 2);
-}
diff --git a/src/test/ui/traits/trait-default-method-bound.rs b/src/test/ui/traits/trait-default-method-bound.rs
deleted file mode 100644 (file)
index 0855a9d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// run-pass
-
-
-trait A {
-    fn g(&self) -> isize { 10 }
-}
-
-impl A for isize { }
-
-fn f<T:A>(i: T) {
-    assert_eq!(i.g(), 10);
-}
-
-pub fn main () {
-    f(0);
-}
diff --git a/src/test/ui/traits/trait-default-method-xc-2.rs b/src/test/ui/traits/trait-default-method-xc-2.rs
deleted file mode 100644 (file)
index 5fa1a6c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// run-pass
-// aux-build:trait_default_method_xc_aux.rs
-// aux-build:trait_default_method_xc_aux_2.rs
-
-
-
-extern crate trait_default_method_xc_aux as aux;
-extern crate trait_default_method_xc_aux_2 as aux2;
-use aux::A;
-use aux2::{a_struct, welp};
-
-
-pub fn main () {
-
-    let a = a_struct { x: 0 };
-    let b = a_struct { x: 1 };
-
-    assert_eq!(0.g(), 10);
-    assert_eq!(a.g(), 10);
-    assert_eq!(a.h(), 11);
-    assert_eq!(b.g(), 10);
-    assert_eq!(b.h(), 11);
-    assert_eq!(A::lurr(&a, &b), 21);
-
-    welp(&0);
-}
diff --git a/src/test/ui/traits/trait-default-method-xc.rs b/src/test/ui/traits/trait-default-method-xc.rs
deleted file mode 100644 (file)
index 3c20a64..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(non_camel_case_types)]
-
-// aux-build:trait_default_method_xc_aux.rs
-
-
-extern crate trait_default_method_xc_aux as aux;
-use aux::{A, TestEquality, Something};
-use aux::B;
-
-fn f<T: aux::A>(i: T) {
-    assert_eq!(i.g(), 10);
-}
-
-fn welp<T>(i: isize, _x: &T) -> isize {
-    i.g()
-}
-
-mod stuff {
-    pub struct thing { pub x: isize }
-}
-
-impl A for stuff::thing {
-    fn f(&self) -> isize { 10 }
-}
-
-fn g<T, U, V: B<T>>(i: V, j: T, k: U) -> (T, U) {
-    i.thing(j, k)
-}
-
-fn eq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
-    lhs.test_eq(rhs)
-}
-fn neq<T: TestEquality>(lhs: &T, rhs: &T) -> bool {
-    lhs.test_neq(rhs)
-}
-
-
-impl TestEquality for stuff::thing {
-    fn test_eq(&self, rhs: &stuff::thing) -> bool {
-        //self.x.test_eq(&rhs.x)
-        eq(&self.x, &rhs.x)
-    }
-}
-
-
-pub fn main() {
-    // Some tests of random things
-    f(0);
-
-    assert_eq!(A::lurr(&0, &1), 21);
-
-    let a = stuff::thing { x: 0 };
-    let b = stuff::thing { x: 1 };
-    let c = Something { x: 1 };
-
-    assert_eq!(0.g(), 10);
-    assert_eq!(a.g(), 10);
-    assert_eq!(a.h(), 11);
-    assert_eq!(c.h(), 11);
-
-    assert_eq!(0.thing(3.14f64, 1), (3.14f64, 1));
-    assert_eq!(B::staticthing(&0, 3.14f64, 1), (3.14f64, 1));
-    assert_eq!(B::<f64>::staticthing::<isize>(&0, 3.14, 1), (3.14, 1));
-
-    assert_eq!(g(0, 3.14f64, 1), (3.14f64, 1));
-    assert_eq!(g(false, 3.14f64, 1), (3.14, 1));
-
-
-    // Trying out a real one
-    assert!(12.test_neq(&10));
-    assert!(!10.test_neq(&10));
-    assert!(a.test_neq(&b));
-    assert!(!a.test_neq(&a));
-
-    assert!(neq(&12, &10));
-    assert!(!neq(&10, &10));
-    assert!(neq(&a, &b));
-    assert!(!neq(&a, &a));
-}
diff --git a/src/test/ui/traits/trait-duplicate-methods.rs b/src/test/ui/traits/trait-duplicate-methods.rs
deleted file mode 100644 (file)
index 1f9bdf5..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-trait Foo {
-    fn orange(&self);
-    fn orange(&self); //~ ERROR the name `orange` is defined multiple times
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-duplicate-methods.stderr b/src/test/ui/traits/trait-duplicate-methods.stderr
deleted file mode 100644 (file)
index 7cba4cb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0428]: the name `orange` is defined multiple times
-  --> $DIR/trait-duplicate-methods.rs:3:5
-   |
-LL |     fn orange(&self);
-   |     ----------------- previous definition of the value `orange` here
-LL |     fn orange(&self);
-   |     ^^^^^^^^^^^^^^^^^ `orange` redefined here
-   |
-   = note: `orange` must be defined only once in the value namespace of this trait
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0428`.
diff --git a/src/test/ui/traits/trait-false-ambiguity-where-clause-builtin-bound.rs b/src/test/ui/traits/trait-false-ambiguity-where-clause-builtin-bound.rs
deleted file mode 100644 (file)
index 3413db6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// run-pass
-// Test that we do not error out because of a (False) ambiguity
-// between the builtin rules for Sized and the where clause. Issue
-// #20959.
-
-// pretty-expanded FIXME #23616
-
-fn foo<K>(x: Option<K>)
-    where Option<K> : Sized
-{
-    let _y = x;
-}
-
-fn main() {
-    foo(Some(22));
-}
diff --git a/src/test/ui/traits/trait-generic.rs b/src/test/ui/traits/trait-generic.rs
deleted file mode 100644 (file)
index 80efe1c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-
-
-trait to_str {
-    fn to_string_(&self) -> String;
-}
-impl to_str for isize {
-    fn to_string_(&self) -> String { self.to_string() }
-}
-impl to_str for String {
-    fn to_string_(&self) -> String { self.clone() }
-}
-impl to_str for () {
-    fn to_string_(&self) -> String { "()".to_string() }
-}
-
-trait map<T> {
-    fn map<U, F>(&self, f: F) -> Vec<U> where F: FnMut(&T) -> U;
-}
-impl<T> map<T> for Vec<T> {
-    fn map<U, F>(&self, mut f: F) -> Vec<U> where F: FnMut(&T) -> U {
-        let mut r = Vec::new();
-        for i in self {
-            r.push(f(i));
-        }
-        r
-    }
-}
-
-fn foo<U, T: map<U>>(x: T) -> Vec<String> {
-    x.map(|_e| "hi".to_string() )
-}
-fn bar<U:to_str,T:map<U>>(x: T) -> Vec<String> {
-    x.map(|_e| _e.to_string_() )
-}
-
-pub fn main() {
-    assert_eq!(foo(vec![1]), ["hi".to_string()]);
-    assert_eq!(bar::<isize, Vec<isize> >(vec![4, 5]), ["4".to_string(), "5".to_string()]);
-    assert_eq!(bar::<String, Vec<String> >(vec!["x".to_string(), "y".to_string()]),
-               ["x".to_string(), "y".to_string()]);
-    assert_eq!(bar::<(), Vec<()>>(vec![()]), ["()".to_string()]);
-}
diff --git a/src/test/ui/traits/trait-impl-1.rs b/src/test/ui/traits/trait-impl-1.rs
deleted file mode 100644 (file)
index d22ac72..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Test calling methods on an impl for a bare trait. This test checks that the
-// trait impl is only applied to a trait object, not concrete types which implement
-// the trait.
-
-trait T {}
-
-impl<'a> dyn T + 'a {
-    fn foo(&self) {}
-}
-
-impl T for i32 {}
-
-fn main() {
-    let x = &42i32;
-    x.foo(); //~ERROR: no method named `foo` found
-}
diff --git a/src/test/ui/traits/trait-impl-1.stderr b/src/test/ui/traits/trait-impl-1.stderr
deleted file mode 100644 (file)
index da0936e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0599]: no method named `foo` found for reference `&i32` in the current scope
-  --> $DIR/trait-impl-1.rs:15:7
-   |
-LL |     x.foo();
-   |       ^^^ method not found in `&i32`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/traits/trait-impl-2.rs b/src/test/ui/traits/trait-impl-2.rs
deleted file mode 100644 (file)
index 804ffec..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(non_snake_case)]
-
-// pretty-expanded FIXME #23616
-
-pub mod Foo {
-    pub trait Trait {
-        fn foo(&self);
-    }
-}
-
-mod Bar {
-    impl<'a> dyn (::Foo::Trait) + 'a {
-        fn bar(&self) { self.foo() }
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-impl-can-not-have-untraitful-items.rs b/src/test/ui/traits/trait-impl-can-not-have-untraitful-items.rs
deleted file mode 100644 (file)
index 0c88544..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-trait A { }
-
-impl A for isize {
-    const BAR: () = (); //~ ERROR const `BAR` is not a member of trait `A`
-    type Baz = (); //~ ERROR type `Baz` is not a member of trait `A`
-    fn foo(&self) { } //~ ERROR method `foo` is not a member of trait `A`
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-impl-can-not-have-untraitful-items.stderr b/src/test/ui/traits/trait-impl-can-not-have-untraitful-items.stderr
deleted file mode 100644 (file)
index 0abed79..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0438]: const `BAR` is not a member of trait `A`
-  --> $DIR/trait-impl-can-not-have-untraitful-items.rs:4:5
-   |
-LL |     const BAR: () = ();
-   |     ^^^^^^^^^^^^^^^^^^^ not a member of trait `A`
-
-error[E0437]: type `Baz` is not a member of trait `A`
-  --> $DIR/trait-impl-can-not-have-untraitful-items.rs:5:5
-   |
-LL |     type Baz = ();
-   |     ^^^^^^^^^^^^^^ not a member of trait `A`
-
-error[E0407]: method `foo` is not a member of trait `A`
-  --> $DIR/trait-impl-can-not-have-untraitful-items.rs:6:5
-   |
-LL |     fn foo(&self) { }
-   |     ^^^^^^^^^^^^^^^^^ not a member of trait `A`
-
-error: aborting due to 3 previous errors
-
-Some errors have detailed explanations: E0407, E0437, E0438.
-For more information about an error, try `rustc --explain E0407`.
diff --git a/src/test/ui/traits/trait-impl-different-num-params.rs b/src/test/ui/traits/trait-impl-different-num-params.rs
deleted file mode 100644 (file)
index 5340062..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-trait Foo {
-    fn bar(&self, x: usize) -> Self;
-}
-impl Foo for isize {
-    fn bar(&self) -> isize {
-        //~^ ERROR method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 2
-        *self
-    }
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-impl-different-num-params.stderr b/src/test/ui/traits/trait-impl-different-num-params.stderr
deleted file mode 100644 (file)
index 5ab9361..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0050]: method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 2
-  --> $DIR/trait-impl-different-num-params.rs:5:12
-   |
-LL |     fn bar(&self, x: usize) -> Self;
-   |            --------------- trait requires 2 parameters
-...
-LL |     fn bar(&self) -> isize {
-   |            ^^^^^ expected 2 parameters, found 1
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0050`.
diff --git a/src/test/ui/traits/trait-impl-for-module.rs b/src/test/ui/traits/trait-impl-for-module.rs
deleted file mode 100644 (file)
index 9004627..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-mod a {
-}
-
-trait A {
-}
-
-impl A for a { //~ ERROR expected type, found module
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-impl-for-module.stderr b/src/test/ui/traits/trait-impl-for-module.stderr
deleted file mode 100644 (file)
index cd2713a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0573]: expected type, found module `a`
-  --> $DIR/trait-impl-for-module.rs:7:12
-   |
-LL | trait A {
-   | ------- similarly named trait `A` defined here
-...
-LL | impl A for a {
-   |            ^ help: a trait with a similar name exists: `A`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0573`.
diff --git a/src/test/ui/traits/trait-impl-method-mismatch.rs b/src/test/ui/traits/trait-impl-method-mismatch.rs
deleted file mode 100644 (file)
index 683b1c1..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-trait Mumbo {
-    fn jumbo(&self, x: &usize) -> usize;
-}
-
-impl Mumbo for usize {
-    // Cannot have a larger effect than the trait:
-    unsafe fn jumbo(&self, x: &usize) { *self + *x; }
-    //~^ ERROR method `jumbo` has an incompatible type for trait
-    //~| expected fn pointer `fn
-    //~| found fn pointer `unsafe fn
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-impl-method-mismatch.stderr b/src/test/ui/traits/trait-impl-method-mismatch.stderr
deleted file mode 100644 (file)
index 52e4918..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0053]: method `jumbo` has an incompatible type for trait
-  --> $DIR/trait-impl-method-mismatch.rs:7:5
-   |
-LL |     fn jumbo(&self, x: &usize) -> usize;
-   |     ------------------------------------ type in trait
-...
-LL |     unsafe fn jumbo(&self, x: &usize) { *self + *x; }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn
-   |
-   = note: expected fn pointer `fn(&usize, &usize) -> usize`
-              found fn pointer `unsafe fn(&usize, &usize)`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0053`.
diff --git a/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs b/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs
deleted file mode 100644 (file)
index 05b9db9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Check that when we test the supertrait we ensure consistent use of
-// lifetime parameters. In this case, implementing T2<'a,'b> requires
-// an impl of T1<'a>, but we have an impl of T1<'b>.
-
-trait T1<'x> {
-    fn x(&self) -> &'x isize;
-}
-
-trait T2<'x, 'y> : T1<'x> {
-    fn y(&self) -> &'y isize;
-}
-
-struct S<'a, 'b> {
-    a: &'a isize,
-    b: &'b isize
-}
-
-impl<'a,'b> T1<'b> for S<'a, 'b> {
-    fn x(&self) -> &'b isize {
-        self.b
-    }
-}
-
-impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime
-    fn y(&self) -> &'b isize {
-        self.b
-    }
-}
-
-pub fn main() {
-}
diff --git a/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr b/src/test/ui/traits/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr
deleted file mode 100644 (file)
index 46aa7db..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
-  --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
-   |
-LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
-   |             ^^^^^^^^^^
-   |
-note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 24:6...
-  --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:6
-   |
-LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
-   |      ^^
-note: ...but the lifetime must also be valid for the lifetime `'b` as defined on the impl at 24:9...
-  --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:9
-   |
-LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
-   |         ^^
-note: ...so that the types are compatible
-  --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
-   |
-LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
-   |             ^^^^^^^^^^
-   = note: expected `T1<'a>`
-              found `T1<'_>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0495`.
diff --git a/src/test/ui/traits/trait-impl.rs b/src/test/ui/traits/trait-impl.rs
deleted file mode 100644 (file)
index 14796ce..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// run-pass
-// Test calling methods on an impl for a bare trait.
-
-// aux-build:traitimpl.rs
-
-extern crate traitimpl;
-use traitimpl::Bar;
-
-static mut COUNT: usize = 1;
-
-trait T {
-    fn t(&self) {}
-}
-
-impl<'a> dyn T+'a {
-    fn foo(&self) {
-        unsafe { COUNT *= 2; }
-    }
-    fn bar() {
-        unsafe { COUNT *= 3; }
-    }
-}
-
-impl T for isize {}
-
-struct Foo;
-impl<'a> Bar<'a> for Foo {}
-
-fn main() {
-    let x: &dyn T = &42;
-
-    x.foo();
-    T::foo(x);
-    T::bar();
-
-    unsafe { assert_eq!(COUNT, 12); }
-
-    // Cross-crait case
-    let x: &dyn Bar = &Foo;
-    x.bar();
-}
diff --git a/src/test/ui/traits/trait-inheritance-auto-xc-2.rs b/src/test/ui/traits/trait-inheritance-auto-xc-2.rs
deleted file mode 100644 (file)
index 62c3ce8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-// aux-build:trait_inheritance_auto_xc_2_aux.rs
-
-
-extern crate trait_inheritance_auto_xc_2_aux as aux;
-
-// aux defines impls of Foo, Bar and Baz for A
-use aux::{Foo, Bar, Baz, A};
-
-// We want to extend all Foo, Bar, Bazes to Quuxes
-pub trait Quux: Foo + Bar + Baz { }
-impl<T:Foo + Bar + Baz> Quux for T { }
-
-fn f<T:Quux>(a: &T) {
-    assert_eq!(a.f(), 10);
-    assert_eq!(a.g(), 20);
-    assert_eq!(a.h(), 30);
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    f(a);
-}
diff --git a/src/test/ui/traits/trait-inheritance-auto-xc.rs b/src/test/ui/traits/trait-inheritance-auto-xc.rs
deleted file mode 100644 (file)
index e8e6510..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// aux-build:trait_inheritance_auto_xc_aux.rs
-
-
-extern crate trait_inheritance_auto_xc_aux as aux;
-
-use aux::{Foo, Bar, Baz, Quux};
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-impl Baz for A { fn h(&self) -> isize { 30 } }
-
-fn f<T:Quux>(a: &T) {
-    assert_eq!(a.f(), 10);
-    assert_eq!(a.g(), 20);
-    assert_eq!(a.h(), 30);
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    f(a);
-}
diff --git a/src/test/ui/traits/trait-inheritance-auto.rs b/src/test/ui/traits/trait-inheritance-auto.rs
deleted file mode 100644 (file)
index 0be67a5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// Testing that this impl turns A into a Quux, because
-// A is already a Foo Bar Baz
-
-impl<T:Foo + Bar + Baz> Quux for T { }
-
-trait Foo { fn f(&self) -> isize; }
-trait Bar { fn g(&self) -> isize; }
-trait Baz { fn h(&self) -> isize; }
-
-trait Quux: Foo + Bar + Baz { }
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-impl Baz for A { fn h(&self) -> isize { 30 } }
-
-fn f<T:Quux>(a: &T) {
-    assert_eq!(a.f(), 10);
-    assert_eq!(a.g(), 20);
-    assert_eq!(a.h(), 30);
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    f(a);
-}
diff --git a/src/test/ui/traits/trait-inheritance-call-bound-inherited.rs b/src/test/ui/traits/trait-inheritance-call-bound-inherited.rs
deleted file mode 100644 (file)
index 37c2ff6..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait Foo { fn f(&self) -> isize; }
-trait Bar : Foo { fn g(&self) -> isize; }
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-
-// Call a function on Foo, given a T: Bar
-fn gg<T:Bar>(a: &T) -> isize {
-    a.f()
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    assert_eq!(gg(a), 10);
-}
diff --git a/src/test/ui/traits/trait-inheritance-call-bound-inherited2.rs b/src/test/ui/traits/trait-inheritance-call-bound-inherited2.rs
deleted file mode 100644 (file)
index 8576d29..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait Foo { fn f(&self) -> isize; }
-trait Bar : Foo { fn g(&self) -> isize; }
-trait Baz : Bar { fn h(&self) -> isize; }
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-impl Baz for A { fn h(&self) -> isize { 30 } }
-
-// Call a function on Foo, given a T: Baz,
-// which is inherited via Bar
-fn gg<T:Baz>(a: &T) -> isize {
-    a.f()
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    assert_eq!(gg(a), 10);
-}
diff --git a/src/test/ui/traits/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/ui/traits/trait-inheritance-cast-without-call-to-supertrait.rs
deleted file mode 100644 (file)
index 25159c1..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// Testing that we can cast to a subtrait and call subtrait
-// methods. Not testing supertrait methods
-
-
-trait Foo {
-    fn f(&self) -> isize;
-}
-
-trait Bar : Foo {
-    fn g(&self) -> isize;
-}
-
-struct A {
-    x: isize
-}
-
-impl Foo for A {
-    fn f(&self) -> isize { 10 }
-}
-
-impl Bar for A {
-    fn g(&self) -> isize { 20 }
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    let afoo = a as &dyn Foo;
-    let abar = a as &dyn Bar;
-    assert_eq!(afoo.f(), 10);
-    assert_eq!(abar.g(), 20);
-}
diff --git a/src/test/ui/traits/trait-inheritance-cast.rs b/src/test/ui/traits/trait-inheritance-cast.rs
deleted file mode 100644 (file)
index 9070b9d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// Testing that supertrait methods can be called on subtrait object types
-
-
-trait Foo {
-    fn f(&self) -> isize;
-}
-
-trait Bar : Foo {
-    fn g(&self) -> isize;
-}
-
-struct A {
-    x: isize
-}
-
-impl Foo for A {
-    fn f(&self) -> isize { 10 }
-}
-
-impl Bar for A {
-    fn g(&self) -> isize { 20 }
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    let afoo = a as &dyn Foo;
-    let abar = a as &dyn Bar;
-    assert_eq!(afoo.f(), 10);
-    assert_eq!(abar.g(), 20);
-    assert_eq!(abar.f(), 10);
-}
diff --git a/src/test/ui/traits/trait-inheritance-cross-trait-call-xc.rs b/src/test/ui/traits/trait-inheritance-cross-trait-call-xc.rs
deleted file mode 100644 (file)
index dbefb22..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-// aux-build:trait_xc_call_aux.rs
-
-
-extern crate trait_xc_call_aux as aux;
-
-use aux::Foo;
-
-trait Bar : Foo {
-    fn g(&self) -> isize;
-}
-
-impl Bar for aux::A {
-    fn g(&self) -> isize { self.f() }
-}
-
-pub fn main() {
-    let a = &aux::A { x: 3 };
-    assert_eq!(a.g(), 10);
-}
diff --git a/src/test/ui/traits/trait-inheritance-cross-trait-call.rs b/src/test/ui/traits/trait-inheritance-cross-trait-call.rs
deleted file mode 100644 (file)
index 512c928..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait Foo { fn f(&self) -> isize; }
-trait Bar : Foo { fn g(&self) -> isize; }
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-
-impl Bar for A {
-    // Testing that this impl can call the impl of Foo
-    fn g(&self) -> isize { self.f() }
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    assert_eq!(a.g(), 10);
-}
diff --git a/src/test/ui/traits/trait-inheritance-diamond.rs b/src/test/ui/traits/trait-inheritance-diamond.rs
deleted file mode 100644 (file)
index 32ad0fb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// B and C both require A, so D does as well, twice, but that's just fine
-
-
-trait A { fn a(&self) -> isize; }
-trait B: A { fn b(&self) -> isize; }
-trait C: A { fn c(&self) -> isize; }
-trait D: B + C { fn d(&self) -> isize; }
-
-struct S { bogus: () }
-
-impl A for S { fn a(&self) -> isize { 10 } }
-impl B for S { fn b(&self) -> isize { 20 } }
-impl C for S { fn c(&self) -> isize { 30 } }
-impl D for S { fn d(&self) -> isize { 40 } }
-
-fn f<T:D>(x: &T) {
-    assert_eq!(x.a(), 10);
-    assert_eq!(x.b(), 20);
-    assert_eq!(x.c(), 30);
-    assert_eq!(x.d(), 40);
-}
-
-pub fn main() {
-    let value = &S { bogus: () };
-    f(value);
-}
diff --git a/src/test/ui/traits/trait-inheritance-multiple-inheritors.rs b/src/test/ui/traits/trait-inheritance-multiple-inheritors.rs
deleted file mode 100644 (file)
index 77ecbd8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait A { fn a(&self) -> isize; }
-trait B: A { fn b(&self) -> isize; }
-trait C: A { fn c(&self) -> isize; }
-
-struct S { bogus: () }
-
-impl A for S { fn a(&self) -> isize { 10 } }
-impl B for S { fn b(&self) -> isize { 20 } }
-impl C for S { fn c(&self) -> isize { 30 } }
-
-// Both B and C inherit from A
-fn f<T:B + C>(x: &T) {
-    assert_eq!(x.a(), 10);
-    assert_eq!(x.b(), 20);
-    assert_eq!(x.c(), 30);
-}
-
-pub fn main() {
-    f(&S { bogus: () })
-}
diff --git a/src/test/ui/traits/trait-inheritance-multiple-params.rs b/src/test/ui/traits/trait-inheritance-multiple-params.rs
deleted file mode 100644 (file)
index 8ff5ba5..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait A { fn a(&self) -> isize; }
-trait B: A { fn b(&self) -> isize; }
-trait C: A { fn c(&self) -> isize; }
-
-struct S { bogus: () }
-
-impl A for S { fn a(&self) -> isize { 10 } }
-impl B for S { fn b(&self) -> isize { 20 } }
-impl C for S { fn c(&self) -> isize { 30 } }
-
-// Multiple type params, multiple levels of inheritance
-fn f<X:A,Y:B,Z:C>(x: &X, y: &Y, z: &Z) {
-    assert_eq!(x.a(), 10);
-    assert_eq!(y.a(), 10);
-    assert_eq!(y.b(), 20);
-    assert_eq!(z.a(), 10);
-    assert_eq!(z.c(), 30);
-}
-
-pub fn main() {
-    let s = &S { bogus: () };
-    f(s, s, s);
-}
diff --git a/src/test/ui/traits/trait-inheritance-num.rs b/src/test/ui/traits/trait-inheritance-num.rs
deleted file mode 100644 (file)
index 3d63d78..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(unused_variables)]
-// pretty-expanded FIXME #23616
-
-pub trait NumExt: PartialEq + PartialOrd {}
-
-pub trait FloatExt: NumExt {}
-
-fn greater_than_one<T: NumExt>(n: &T) -> bool { loop {} }
-fn greater_than_one_float<T: FloatExt>(n: &T) -> bool { loop {} }
-
-pub fn main() {}
diff --git a/src/test/ui/traits/trait-inheritance-num0.rs b/src/test/ui/traits/trait-inheritance-num0.rs
deleted file mode 100644 (file)
index cee5254..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// Extending Num and using inherited static methods
-
-// pretty-expanded FIXME #23616
-
-use std::cmp::PartialOrd;
-
-pub trait NumCast: Sized {
-    fn from(i: i32) -> Option<Self>;
-}
-
-pub trait Num {
-    fn from_int(i: isize) -> Self;
-    fn gt(&self, other: &Self) -> bool;
-}
-
-pub trait NumExt: NumCast + PartialOrd { }
-
-fn greater_than_one<T:NumExt>(n: &T) -> bool {
-    n.gt(&NumCast::from(1).unwrap())
-}
-
-pub fn main() {}
diff --git a/src/test/ui/traits/trait-inheritance-num1.rs b/src/test/ui/traits/trait-inheritance-num1.rs
deleted file mode 100644 (file)
index 663dd3a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// pretty-expanded FIXME #23616
-
-pub trait NumCast: Sized {
-    fn from(i: i32) -> Option<Self>;
-}
-
-pub trait NumExt: NumCast + PartialOrd { }
-
-fn greater_than_one<T:NumExt>(n: &T) -> bool {
-    *n > NumCast::from(1).unwrap()
-}
-
-pub fn main() {}
diff --git a/src/test/ui/traits/trait-inheritance-num2.rs b/src/test/ui/traits/trait-inheritance-num2.rs
deleted file mode 100644 (file)
index b713c66..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// run-pass
-// A more complex example of numeric extensions
-
-pub trait TypeExt {}
-
-impl TypeExt for u8 {}
-impl TypeExt for u16 {}
-impl TypeExt for u32 {}
-impl TypeExt for u64 {}
-impl TypeExt for usize {}
-
-impl TypeExt for i8 {}
-impl TypeExt for i16 {}
-impl TypeExt for i32 {}
-impl TypeExt for i64 {}
-impl TypeExt for isize {}
-
-impl TypeExt for f32 {}
-impl TypeExt for f64 {}
-
-
-pub trait NumExt: TypeExt + PartialEq + PartialOrd {}
-
-impl NumExt for u8 {}
-impl NumExt for u16 {}
-impl NumExt for u32 {}
-impl NumExt for u64 {}
-impl NumExt for usize {}
-
-impl NumExt for i8 {}
-impl NumExt for i16 {}
-impl NumExt for i32 {}
-impl NumExt for i64 {}
-impl NumExt for isize {}
-
-impl NumExt for f32 {}
-impl NumExt for f64 {}
-
-
-pub trait UnSignedExt: NumExt {}
-
-impl UnSignedExt for u8 {}
-impl UnSignedExt for u16 {}
-impl UnSignedExt for u32 {}
-impl UnSignedExt for u64 {}
-impl UnSignedExt for usize {}
-
-
-pub trait SignedExt: NumExt {}
-
-impl SignedExt for i8 {}
-impl SignedExt for i16 {}
-impl SignedExt for i32 {}
-impl SignedExt for i64 {}
-impl SignedExt for isize {}
-
-impl SignedExt for f32 {}
-impl SignedExt for f64 {}
-
-
-pub trait IntegerExt: NumExt {}
-
-impl IntegerExt for u8 {}
-impl IntegerExt for u16 {}
-impl IntegerExt for u32 {}
-impl IntegerExt for u64 {}
-impl IntegerExt for usize {}
-
-impl IntegerExt for i8 {}
-impl IntegerExt for i16 {}
-impl IntegerExt for i32 {}
-impl IntegerExt for i64 {}
-impl IntegerExt for isize {}
-
-
-pub trait FloatExt: NumExt {}
-
-impl FloatExt for f32 {}
-impl FloatExt for f64 {}
-
-
-fn test_float_ext<T:FloatExt>(n: T) { println!("{}", n < n) }
-
-pub fn main() {
-    test_float_ext(1f32);
-}
diff --git a/src/test/ui/traits/trait-inheritance-num3.rs b/src/test/ui/traits/trait-inheritance-num3.rs
deleted file mode 100644 (file)
index c40be6f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-pub trait NumCast: Sized {
-    fn from(i: i32) -> Option<Self>;
-}
-
-pub trait NumExt: PartialEq + PartialOrd + NumCast {}
-
-impl NumExt for f32 {}
-impl NumCast for f32 {
-    fn from(i: i32) -> Option<f32> { Some(i as f32) }
-}
-
-fn num_eq_one<T: NumExt>(n: T) {
-    println!("{}", n == NumCast::from(1).unwrap())
-}
-
-pub fn main() {
-    num_eq_one(1f32); // you need to actually use the function to trigger the ICE
-}
diff --git a/src/test/ui/traits/trait-inheritance-num5.rs b/src/test/ui/traits/trait-inheritance-num5.rs
deleted file mode 100644 (file)
index f478618..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// run-pass
-// pretty-expanded FIXME #23616
-
-pub trait NumCast: Sized {
-    fn from(i: i32) -> Option<Self>;
-}
-
-pub trait NumExt: PartialEq + NumCast {}
-
-impl NumExt for f32 {}
-impl NumExt for isize {}
-
-impl NumCast for f32 {
-    fn from(i: i32) -> Option<f32> { Some(i as f32) }
-}
-impl NumCast for isize {
-    fn from(i: i32) -> Option<isize> { Some(i as isize) }
-}
-
-fn num_eq_one<T:NumExt>() -> T {
-    NumCast::from(1).unwrap()
-}
-
-pub fn main() {
-    num_eq_one::<isize>(); // you need to actually use the function to trigger the ICE
-}
diff --git a/src/test/ui/traits/trait-inheritance-overloading-simple.rs b/src/test/ui/traits/trait-inheritance-overloading-simple.rs
deleted file mode 100644 (file)
index c306aa2..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-use std::cmp::PartialEq;
-
-trait MyNum : PartialEq { }
-
-#[derive(Debug)]
-struct MyInt { val: isize }
-
-impl PartialEq for MyInt {
-    fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
-    fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
-}
-
-impl MyNum for MyInt {}
-
-fn f<T:MyNum>(x: T, y: T) -> bool {
-    return x == y;
-}
-
-fn mi(v: isize) -> MyInt { MyInt { val: v } }
-
-pub fn main() {
-    let (x, y, z) = (mi(3), mi(5), mi(3));
-    assert!(x != y);
-    assert_eq!(x, z);
-}
diff --git a/src/test/ui/traits/trait-inheritance-overloading-xc-exe.rs b/src/test/ui/traits/trait-inheritance-overloading-xc-exe.rs
deleted file mode 100644 (file)
index 2a9acfd..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-// aux-build:trait_inheritance_overloading_xc.rs
-
-
-extern crate trait_inheritance_overloading_xc;
-use trait_inheritance_overloading_xc::{MyNum, MyInt};
-
-fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
-    return (x.clone() + y.clone(), x.clone() - y.clone(), x * y);
-}
-
-fn mi(v: isize) -> MyInt { MyInt { val: v } }
-
-pub fn main() {
-    let (x, y) = (mi(3), mi(5));
-    let (a, b, c) = f(x, y);
-    assert_eq!(a, mi(8));
-    assert_eq!(b, mi(-2));
-    assert_eq!(c, mi(15));
-}
diff --git a/src/test/ui/traits/trait-inheritance-overloading.rs b/src/test/ui/traits/trait-inheritance-overloading.rs
deleted file mode 100644 (file)
index 083643e..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// run-pass
-use std::cmp::PartialEq;
-use std::ops::{Add, Sub, Mul};
-
-trait MyNum : Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + PartialEq + Clone { }
-
-#[derive(Clone, Debug)]
-struct MyInt { val: isize }
-
-impl Add for MyInt {
-    type Output = MyInt;
-
-    fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) }
-}
-
-impl Sub for MyInt {
-    type Output = MyInt;
-
-    fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) }
-}
-
-impl Mul for MyInt {
-    type Output = MyInt;
-
-    fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) }
-}
-
-impl PartialEq for MyInt {
-    fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
-    fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
-}
-
-impl MyNum for MyInt {}
-
-fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
-    return (x.clone() + y.clone(), x.clone() - y.clone(), x * y);
-}
-
-fn mi(v: isize) -> MyInt { MyInt { val: v } }
-
-pub fn main() {
-    let (x, y) = (mi(3), mi(5));
-    let (a, b, c) = f(x, y);
-    assert_eq!(a, mi(8));
-    assert_eq!(b, mi(-2));
-    assert_eq!(c, mi(15));
-}
diff --git a/src/test/ui/traits/trait-inheritance-self-in-supertype.rs b/src/test/ui/traits/trait-inheritance-self-in-supertype.rs
deleted file mode 100644 (file)
index e8a2bd7..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// run-pass
-// Test for issue #4183: use of Self in supertraits.
-
-pub static FUZZY_EPSILON: f64 = 0.1;
-
-pub trait FuzzyEq<Eps> {
-    fn fuzzy_eq(&self, other: &Self) -> bool;
-    fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool;
-}
-
-trait Float: Sized+FuzzyEq<Self> {
-    fn two_pi() -> Self;
-}
-
-impl FuzzyEq<f32> for f32 {
-    fn fuzzy_eq(&self, other: &f32) -> bool {
-        self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32))
-    }
-
-    fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool {
-        (*self - *other).abs() < *epsilon
-    }
-}
-
-impl Float for f32 {
-    fn two_pi() -> f32 { 6.28318530717958647692528676655900576_f32 }
-}
-
-impl FuzzyEq<f64> for f64 {
-    fn fuzzy_eq(&self, other: &f64) -> bool {
-        self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64))
-    }
-
-    fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool {
-        (*self - *other).abs() < *epsilon
-    }
-}
-
-impl Float for f64 {
-    fn two_pi() -> f64 { 6.28318530717958647692528676655900576_f64 }
-}
-
-fn compare<F:Float>(f1: F) -> bool {
-    let f2 = Float::two_pi();
-    f1.fuzzy_eq(&f2)
-}
-
-pub fn main() {
-    assert!(compare::<f32>(6.28318530717958647692528676655900576));
-    assert!(compare::<f32>(6.29));
-    assert!(compare::<f32>(6.3));
-    assert!(compare::<f32>(6.19));
-    assert!(!compare::<f32>(7.28318530717958647692528676655900576));
-    assert!(!compare::<f32>(6.18));
-
-    assert!(compare::<f64>(6.28318530717958647692528676655900576));
-    assert!(compare::<f64>(6.29));
-    assert!(compare::<f64>(6.3));
-    assert!(compare::<f64>(6.19));
-    assert!(!compare::<f64>(7.28318530717958647692528676655900576));
-    assert!(!compare::<f64>(6.18));
-}
diff --git a/src/test/ui/traits/trait-inheritance-self.rs b/src/test/ui/traits/trait-inheritance-self.rs
deleted file mode 100644 (file)
index 5f2559f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// run-pass
-trait Foo<T> {
-    fn f(&self, x: &T);
-}
-
-trait Bar : Sized + Foo<Self> {
-    fn g(&self);
-}
-
-struct S {
-    x: isize
-}
-
-impl Foo<S> for S {
-    fn f(&self, x: &S) {
-        println!("{}", x.x);
-    }
-}
-
-impl Bar for S {
-    fn g(&self) {
-        self.f(self);
-    }
-}
-
-pub fn main() {
-    let s = S { x: 1 };
-    s.g();
-}
diff --git a/src/test/ui/traits/trait-inheritance-simple.rs b/src/test/ui/traits/trait-inheritance-simple.rs
deleted file mode 100644 (file)
index ca3a284..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait Foo { fn f(&self) -> isize; }
-trait Bar : Foo { fn g(&self) -> isize; }
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-
-fn ff<T:Foo>(a: &T) -> isize {
-    a.f()
-}
-
-fn gg<T:Bar>(a: &T) -> isize {
-    a.g()
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    assert_eq!(ff(a), 10);
-    assert_eq!(gg(a), 20);
-}
diff --git a/src/test/ui/traits/trait-inheritance-static.rs b/src/test/ui/traits/trait-inheritance-static.rs
deleted file mode 100644 (file)
index 16218fb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// run-pass
-
-pub trait MyNum {
-    fn from_int(_: isize) -> Self;
-}
-
-pub trait NumExt: MyNum { }
-
-struct S { v: isize }
-
-impl MyNum for S {
-    fn from_int(i: isize) -> S {
-        S {
-            v: i
-        }
-    }
-}
-
-impl NumExt for S { }
-
-fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
-
-pub fn main() {
-    let v: S = greater_than_one();
-    assert_eq!(v.v, 1);
-}
diff --git a/src/test/ui/traits/trait-inheritance-static2.rs b/src/test/ui/traits/trait-inheritance-static2.rs
deleted file mode 100644 (file)
index bc78e1e..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// run-pass
-pub trait MyEq {}
-
-pub trait MyNum {
-    fn from_int(_: isize) -> Self;
-}
-
-pub trait NumExt: MyEq + MyNum { }
-
-struct S { v: isize }
-
-impl MyEq for S { }
-
-impl MyNum for S {
-    fn from_int(i: isize) -> S {
-        S {
-            v: i
-        }
-    }
-}
-
-impl NumExt for S { }
-
-fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
-
-pub fn main() {
-    let v: S = greater_than_one();
-    assert_eq!(v.v, 1);
-}
diff --git a/src/test/ui/traits/trait-inheritance-subst.rs b/src/test/ui/traits/trait-inheritance-subst.rs
deleted file mode 100644 (file)
index b2b6503..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// run-pass
-
-pub trait Add<RHS,Result> {
-    fn add(&self, rhs: &RHS) -> Result;
-}
-
-trait MyNum : Sized + Add<Self,Self> { }
-
-struct MyInt { val: isize }
-
-impl Add<MyInt, MyInt> for MyInt {
-    fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
-}
-
-impl MyNum for MyInt {}
-
-fn f<T:MyNum>(x: T, y: T) -> T {
-    return x.add(&y);
-}
-
-fn mi(v: isize) -> MyInt { MyInt { val: v } }
-
-pub fn main() {
-    let (x, y) = (mi(3), mi(5));
-    let z = f(x, y);
-    assert_eq!(z.val, 8)
-}
diff --git a/src/test/ui/traits/trait-inheritance-subst2.rs b/src/test/ui/traits/trait-inheritance-subst2.rs
deleted file mode 100644 (file)
index ccc9628..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// run-pass
-
-trait Panda<T> {
-    fn chomp(&self, bamboo: &T) -> T;
-}
-
-trait Add<RHS,Result>: Panda<RHS> {
-    fn add(&self, rhs: &RHS) -> Result;
-}
-
-trait MyNum : Sized + Add<Self,Self> { }
-
-struct MyInt { val: isize }
-
-impl Panda<MyInt> for MyInt {
-    fn chomp(&self, bamboo: &MyInt) -> MyInt {
-        mi(self.val + bamboo.val)
-    }
-}
-
-impl Add<MyInt, MyInt> for MyInt {
-    fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) }
-}
-
-impl MyNum for MyInt {}
-
-fn f<T:MyNum>(x: T, y: T) -> T {
-    return x.add(&y).chomp(&y);
-}
-
-fn mi(v: isize) -> MyInt { MyInt { val: v } }
-
-pub fn main() {
-    let (x, y) = (mi(3), mi(5));
-    let z = f(x, y);
-    assert_eq!(z.val, 13);
-}
diff --git a/src/test/ui/traits/trait-inheritance-visibility.rs b/src/test/ui/traits/trait-inheritance-visibility.rs
deleted file mode 100644 (file)
index 6ad8649..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-
-mod traits {
-    pub trait Foo { fn f(&self) -> isize; }
-
-    impl Foo for isize { fn f(&self) -> isize { 10 } }
-}
-
-trait Quux: traits::Foo { }
-impl<T:traits::Foo> Quux for T { }
-
-// Foo is not in scope but because Quux is we can still access
-// Foo's methods on a Quux bound typaram
-fn f<T:Quux>(x: &T) {
-    assert_eq!(x.f(), 10);
-}
-
-pub fn main() {
-    f(&0)
-}
diff --git a/src/test/ui/traits/trait-inheritance2.rs b/src/test/ui/traits/trait-inheritance2.rs
deleted file mode 100644 (file)
index 5bfa60b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-trait Foo { fn f(&self) -> isize; }
-trait Bar { fn g(&self) -> isize; }
-trait Baz { fn h(&self) -> isize; }
-
-trait Quux: Foo + Bar + Baz { }
-
-struct A { x: isize }
-
-impl Foo for A { fn f(&self) -> isize { 10 } }
-impl Bar for A { fn g(&self) -> isize { 20 } }
-impl Baz for A { fn h(&self) -> isize { 30 } }
-impl Quux for A {}
-
-fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
-    assert_eq!(a.f(), 10);
-    assert_eq!(a.g(), 20);
-    assert_eq!(a.h(), 30);
-}
-
-pub fn main() {
-    let a = &A { x: 3 };
-    f(a);
-}
diff --git a/src/test/ui/traits/trait-item-inside-macro.rs b/src/test/ui/traits/trait-item-inside-macro.rs
deleted file mode 100644 (file)
index 54bf872..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// run-pass
-// Issue #34183
-
-macro_rules! foo {
-    () => {
-        fn foo() { }
-    }
-}
-
-macro_rules! bar {
-    () => {
-        fn bar();
-    }
-}
-
-trait Bleh {
-    foo!();
-    bar!();
-}
-
-struct Test;
-
-impl Bleh for Test {
-    fn bar() {}
-}
-
-fn main() {
-    Test::bar();
-    Test::foo();
-}
diff --git a/src/test/ui/traits/trait-item-privacy.rs b/src/test/ui/traits/trait-item-privacy.rs
deleted file mode 100644 (file)
index 1ea1d65..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#![feature(associated_type_defaults)]
-
-struct S;
-
-mod method {
-    trait A {
-        fn a(&self) { }
-    }
-
-    pub trait B {
-        fn b(&self) { }
-    }
-
-    pub trait C: A + B {
-        fn c(&self) { }
-    }
-
-    impl A for ::S {}
-    impl B for ::S {}
-    impl C for ::S {}
-}
-
-mod assoc_const {
-    trait A {
-        const A: u8 = 0;
-    }
-
-    pub trait B {
-        const B: u8 = 0;
-    }
-
-    pub trait C: A + B {
-        const C: u8 = 0;
-    }
-
-    impl A for ::S {}
-    impl B for ::S {}
-    impl C for ::S {}
-}
-
-mod assoc_ty {
-    trait A {
-        type A = u8;
-    }
-
-    pub trait B {
-        type B = u8;
-    }
-
-    pub trait C: A + B {
-        type C = u8;
-    }
-
-    impl A for ::S {}
-    impl B for ::S {}
-    impl C for ::S {}
-}
-
-fn check_method() {
-    // A is private
-    // B is pub, not in scope
-    // C : A + B is pub, in scope
-    use method::C;
-
-    // Methods, method call
-    // a, b, c are resolved as trait items, their traits need to be in scope
-    S.a(); //~ ERROR no method named `a` found
-    S.b(); //~ ERROR no method named `b` found
-    S.c(); // OK
-    // a, b, c are resolved as inherent items, their traits don't need to be in scope
-    let c = &S as &dyn C;
-    c.a(); //~ ERROR associated function `a` is private
-    c.b(); // OK
-    c.c(); // OK
-
-    // Methods, UFCS
-    // a, b, c are resolved as trait items, their traits need to be in scope
-    S::a(&S);
-    //~^ ERROR no function or associated item named `a` found
-    S::b(&S);
-    //~^ ERROR no function or associated item named `b` found
-    S::c(&S); // OK
-    // a, b, c are resolved as inherent items, their traits don't need to be in scope
-    C::a(&S); //~ ERROR associated function `a` is private
-    C::b(&S); // OK
-    C::c(&S); // OK
-}
-
-fn check_assoc_const() {
-    // A is private
-    // B is pub, not in scope
-    // C : A + B is pub, in scope
-    use assoc_const::C;
-
-    // Associated constants
-    // A, B, C are resolved as trait items, their traits need to be in scope
-    S::A; //~ ERROR no associated item named `A` found
-    S::B; //~ ERROR no associated item named `B` found
-    S::C; // OK
-    // A, B, C are resolved as inherent items, their traits don't need to be in scope
-    C::A; //~ ERROR associated constant `A` is private
-          //~^ ERROR the trait `assoc_const::C` cannot be made into an object
-    C::B; // ERROR the trait `assoc_const::C` cannot be made into an object
-    C::C; // OK
-}
-
-fn check_assoc_ty<T: assoc_ty::C>() {
-    // A is private
-    // B is pub, not in scope
-    // C : A + B is pub, in scope
-    use assoc_ty::C;
-
-    // Associated types
-    // A, B, C are resolved as trait items, their traits need to be in scope, not implemented yet
-    let _: S::A; //~ ERROR ambiguous associated type
-    let _: S::B; //~ ERROR ambiguous associated type
-    let _: S::C; //~ ERROR ambiguous associated type
-    // A, B, C are resolved as inherent items, their traits don't need to be in scope
-    let _: T::A; //~ ERROR associated type `A` is private
-    let _: T::B; // OK
-    let _: T::C; // OK
-
-    // Associated types, bindings
-    let _: dyn assoc_ty::B<
-        B = u8, // OK
-    >;
-    let _: dyn C<
-        A = u8, //~ ERROR associated type `A` is private
-        B = u8, // OK
-        C = u8, // OK
-    >;
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr
deleted file mode 100644 (file)
index 4d97d93..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-error[E0599]: no method named `a` found for struct `S` in the current scope
-  --> $DIR/trait-item-privacy.rs:67:7
-   |
-LL | struct S;
-   | --------- method `a` not found for this
-...
-LL |     S.a();
-   |       ^ method not found in `S`
-   |
-   = help: items from traits can only be used if the trait is implemented and in scope
-note: `method::A` defines an item `a`, perhaps you need to implement it
-  --> $DIR/trait-item-privacy.rs:6:5
-   |
-LL |     trait A {
-   |     ^^^^^^^
-
-error[E0599]: no method named `b` found for struct `S` in the current scope
-  --> $DIR/trait-item-privacy.rs:68:7
-   |
-LL | struct S;
-   | --------- method `b` not found for this
-...
-LL |     S.b();
-   |       ^ method not found in `S`
-   |
-   = help: items from traits can only be used if the trait is in scope
-help: the following trait is implemented but not in scope; perhaps add a `use` for it:
-   |
-LL | use method::B;
-   |
-
-error[E0624]: associated function `a` is private
-  --> $DIR/trait-item-privacy.rs:72:7
-   |
-LL |     c.a();
-   |       ^ private associated function
-
-error[E0599]: no function or associated item named `a` found for struct `S` in the current scope
-  --> $DIR/trait-item-privacy.rs:78:8
-   |
-LL | struct S;
-   | --------- function or associated item `a` not found for this
-...
-LL |     S::a(&S);
-   |        ^ function or associated item not found in `S`
-   |
-   = help: items from traits can only be used if the trait is implemented and in scope
-note: `method::A` defines an item `a`, perhaps you need to implement it
-  --> $DIR/trait-item-privacy.rs:6:5
-   |
-LL |     trait A {
-   |     ^^^^^^^
-
-error[E0599]: no function or associated item named `b` found for struct `S` in the current scope
-  --> $DIR/trait-item-privacy.rs:80:8
-   |
-LL | struct S;
-   | --------- function or associated item `b` not found for this
-...
-LL |     S::b(&S);
-   |        ^ function or associated item not found in `S`
-   |
-   = help: items from traits can only be used if the trait is in scope
-help: the following trait is implemented but not in scope; perhaps add a `use` for it:
-   |
-LL | use method::B;
-   |
-
-error[E0624]: associated function `a` is private
-  --> $DIR/trait-item-privacy.rs:84:8
-   |
-LL |     C::a(&S);
-   |        ^ private associated function
-
-error[E0599]: no associated item named `A` found for struct `S` in the current scope
-  --> $DIR/trait-item-privacy.rs:97:8
-   |
-LL | struct S;
-   | --------- associated item `A` not found for this
-...
-LL |     S::A;
-   |        ^ associated item not found in `S`
-   |
-   = help: items from traits can only be used if the trait is implemented and in scope
-note: `assoc_const::A` defines an item `A`, perhaps you need to implement it
-  --> $DIR/trait-item-privacy.rs:24:5
-   |
-LL |     trait A {
-   |     ^^^^^^^
-
-error[E0599]: no associated item named `B` found for struct `S` in the current scope
-  --> $DIR/trait-item-privacy.rs:98:8
-   |
-LL | struct S;
-   | --------- associated item `B` not found for this
-...
-LL |     S::B;
-   |        ^ associated item not found in `S`
-   |
-   = help: items from traits can only be used if the trait is in scope
-help: the following trait is implemented but not in scope; perhaps add a `use` for it:
-   |
-LL | use assoc_const::B;
-   |
-
-error[E0624]: associated constant `A` is private
-  --> $DIR/trait-item-privacy.rs:101:8
-   |
-LL |     C::A;
-   |        ^ private associated constant
-
-error[E0038]: the trait `assoc_const::C` cannot be made into an object
-  --> $DIR/trait-item-privacy.rs:101:5
-   |
-LL |     C::A;
-   |     ^^^^ `assoc_const::C` cannot be made into an object
-   |
-   = help: consider moving `C` to another trait
-   = help: consider moving `B` to another trait
-   = help: consider moving `A` to another trait
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $DIR/trait-item-privacy.rs:25:15
-   |
-LL |         const A: u8 = 0;
-   |               ^ ...because it contains this associated `const`
-...
-LL |         const B: u8 = 0;
-   |               ^ ...because it contains this associated `const`
-...
-LL |     pub trait C: A + B {
-   |               - this trait cannot be made into an object...
-LL |         const C: u8 = 0;
-   |               ^ ...because it contains this associated `const`
-
-error[E0223]: ambiguous associated type
-  --> $DIR/trait-item-privacy.rs:115:12
-   |
-LL |     let _: S::A;
-   |            ^^^^ help: use fully-qualified syntax: `<S as Trait>::A`
-
-error[E0223]: ambiguous associated type
-  --> $DIR/trait-item-privacy.rs:116:12
-   |
-LL |     let _: S::B;
-   |            ^^^^ help: use fully-qualified syntax: `<S as Trait>::B`
-
-error[E0223]: ambiguous associated type
-  --> $DIR/trait-item-privacy.rs:117:12
-   |
-LL |     let _: S::C;
-   |            ^^^^ help: use fully-qualified syntax: `<S as Trait>::C`
-
-error: associated type `A` is private
-  --> $DIR/trait-item-privacy.rs:119:12
-   |
-LL |     let _: T::A;
-   |            ^^^^ private associated type
-
-error: associated type `A` is private
-  --> $DIR/trait-item-privacy.rs:128:9
-   |
-LL |         A = u8,
-   |         ^^^^^^ private associated type
-
-error: aborting due to 15 previous errors
-
-Some errors have detailed explanations: E0038, E0223, E0599, E0624.
-For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/trait-matching-lifetimes.rs b/src/test/ui/traits/trait-matching-lifetimes.rs
deleted file mode 100644 (file)
index 1430dc6..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Tests that the trait matching code takes lifetime parameters into account.
-// (Issue #15517.)
-
-struct Foo<'a,'b> {
-    x: &'a isize,
-    y: &'b isize,
-}
-
-trait Tr : Sized {
-    fn foo(x: Self) {}
-}
-
-impl<'a,'b> Tr for Foo<'a,'b> {
-    fn foo(x: Foo<'b,'a>) {
-        //~^ ERROR method not compatible with trait
-        //~^^ ERROR method not compatible with trait
-    }
-}
-
-fn main(){}
diff --git a/src/test/ui/traits/trait-matching-lifetimes.stderr b/src/test/ui/traits/trait-matching-lifetimes.stderr
deleted file mode 100644 (file)
index 17ebdb7..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-error[E0308]: method not compatible with trait
-  --> $DIR/trait-matching-lifetimes.rs:14:5
-   |
-LL |     fn foo(x: Foo<'b,'a>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
-   |
-   = note: expected fn pointer `fn(Foo<'a, 'b>)`
-              found fn pointer `fn(Foo<'b, 'a>)`
-note: the lifetime `'b` as defined on the impl at 13:9...
-  --> $DIR/trait-matching-lifetimes.rs:13:9
-   |
-LL | impl<'a,'b> Tr for Foo<'a,'b> {
-   |         ^^
-note: ...does not necessarily outlive the lifetime `'a` as defined on the impl at 13:6
-  --> $DIR/trait-matching-lifetimes.rs:13:6
-   |
-LL | impl<'a,'b> Tr for Foo<'a,'b> {
-   |      ^^
-
-error[E0308]: method not compatible with trait
-  --> $DIR/trait-matching-lifetimes.rs:14:5
-   |
-LL |     fn foo(x: Foo<'b,'a>) {
-   |     ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
-   |
-   = note: expected fn pointer `fn(Foo<'a, 'b>)`
-              found fn pointer `fn(Foo<'b, 'a>)`
-note: the lifetime `'a` as defined on the impl at 13:6...
-  --> $DIR/trait-matching-lifetimes.rs:13:6
-   |
-LL | impl<'a,'b> Tr for Foo<'a,'b> {
-   |      ^^
-note: ...does not necessarily outlive the lifetime `'b` as defined on the impl at 13:9
-  --> $DIR/trait-matching-lifetimes.rs:13:9
-   |
-LL | impl<'a,'b> Tr for Foo<'a,'b> {
-   |         ^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/trait-method-private.rs b/src/test/ui/traits/trait-method-private.rs
deleted file mode 100644 (file)
index 4cd1848..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-mod inner {
-    pub trait Bar {
-        fn method(&self);
-    }
-
-    pub struct Foo;
-
-    impl Foo {
-        fn method(&self) {}
-    }
-
-    impl Bar for Foo {
-        fn method(&self) {}
-    }
-}
-
-fn main() {
-    let foo = inner::Foo;
-    foo.method(); //~ ERROR is private
-}
diff --git a/src/test/ui/traits/trait-method-private.stderr b/src/test/ui/traits/trait-method-private.stderr
deleted file mode 100644 (file)
index c33673a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0624]: associated function `method` is private
-  --> $DIR/trait-method-private.rs:19:9
-   |
-LL |     foo.method();
-   |         ^^^^^^ private associated function
-   |
-   = help: items from traits can only be used if the trait is in scope
-help: the following trait is implemented but not in scope; perhaps add a `use` for it:
-   |
-LL | use inner::Bar;
-   |
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0624`.
diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs
deleted file mode 100644 (file)
index 85698f1..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Checks to make sure that `dyn Trait + Send` and `dyn Trait + Send + Send` are the same type.
-// Issue: #47010
-
-struct Struct;
-impl Trait for Struct {}
-trait Trait {}
-
-type Send1 = dyn Trait + Send;
-type Send2 = dyn Trait + Send + Send;
-
-fn main () {}
-
-impl dyn Trait + Send {
-    fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test`
-}
-
-impl dyn Trait + Send + Send {
-    fn test(&self) { println!("two"); }
-}
diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr b/src/test/ui/traits/trait-object-auto-dedup-in-impl.stderr
deleted file mode 100644 (file)
index d10e586..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0592]: duplicate definitions with name `test`
-  --> $DIR/trait-object-auto-dedup-in-impl.rs:14:5
-   |
-LL |     fn test(&self) { println!("one"); }
-   |     ^^^^^^^^^^^^^^ duplicate definitions for `test`
-...
-LL |     fn test(&self) { println!("two"); }
-   |     -------------- other definition for `test`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0592`.
diff --git a/src/test/ui/traits/trait-object-auto-dedup.rs b/src/test/ui/traits/trait-object-auto-dedup.rs
deleted file mode 100644 (file)
index 39d25eb..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// run-pass
-
-#![allow(unused_assignments)]
-
-// Test that duplicate auto trait bounds in trait objects don't create new types.
-#[allow(unused_assignments)]
-use std::marker::Send as SendAlias;
-
-// A dummy trait for the non-auto trait.
-trait Trait {}
-
-// A dummy struct to implement `Trait` and `Send`.
-struct Struct;
-
-impl Trait for Struct {}
-
-// These three functions should be equivalent.
-fn takes_dyn_trait_send(_: Box<dyn Trait + Send>) {}
-fn takes_dyn_trait_send_send(_: Box<dyn Trait + Send + Send>) {}
-fn takes_dyn_trait_send_sendalias(_: Box<dyn Trait + Send + SendAlias>) {}
-
-impl dyn Trait + Send + Send {
-    fn do_nothing(&self) {}
-}
-
-fn main() {
-    // 1. Moving into a variable with more `Send`s and back.
-    let mut dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
-    let dyn_trait_send_send: Box<dyn Trait + Send + Send> = dyn_trait_send;
-    dyn_trait_send = dyn_trait_send_send;
-
-    // 2. Calling methods with different number of `Send`s.
-    let dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
-    takes_dyn_trait_send_send(dyn_trait_send);
-
-    let dyn_trait_send_send = Box::new(Struct) as Box<dyn Trait + Send + Send>;
-    takes_dyn_trait_send(dyn_trait_send_send);
-
-    // 3. Aliases to the trait are transparent.
-    let dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
-    takes_dyn_trait_send_sendalias(dyn_trait_send);
-
-    // 4. Calling an impl that duplicates an auto trait.
-    let dyn_trait_send = Box::new(Struct) as Box<dyn Trait + Send>;
-    dyn_trait_send.do_nothing();
-}
diff --git a/src/test/ui/traits/trait-object-bounds-cycle-1.rs b/src/test/ui/traits/trait-object-bounds-cycle-1.rs
deleted file mode 100644 (file)
index 3146764..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Check that we don't have a cycle when we try to normalize `Self::U` in the
-// bound below.
-
-// check-pass
-
-trait Is {
-    type T;
-}
-
-impl<U> Is for U {
-    type T = U;
-}
-
-trait Obj {
-    type U: Is<T = Self::U>;
-}
-
-fn is_obj<T: ?Sized + Obj>(_: &T) {}
-
-fn f(x: &dyn Obj<U = i32>) {
-    is_obj(x)
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-object-bounds-cycle-2.rs b/src/test/ui/traits/trait-object-bounds-cycle-2.rs
deleted file mode 100644 (file)
index 4c1df38..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Check that we don't have a cycle when we try to normalize `Self::V` in the
-// bound below.
-
-// check-pass
-
-trait Is {
-    type T;
-}
-
-impl<U> Is for U {
-    type T = U;
-}
-
-trait Super {
-    type V;
-}
-
-trait Obj: Super {
-    type U: Is<T = Self::V>;
-}
-
-fn is_obj<T: ?Sized + Obj>(_: &T) {}
-
-fn f(x: &dyn Obj<U = i32, V = i32>) {
-    is_obj(x)
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-object-bounds-cycle-3.rs b/src/test/ui/traits/trait-object-bounds-cycle-3.rs
deleted file mode 100644 (file)
index 55726a5..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Check that we don't have a cycle when we try to normalize `Self::V` in the
-// bound below.
-
-// check-pass
-
-trait Is {
-    type T;
-}
-
-impl<U> Is for U {
-    type T = U;
-}
-
-trait Obj {
-    type U: Is<T = Self::V>;
-    type V;
-}
-
-fn is_obj<T: ?Sized + Obj>(_: &T) {}
-
-fn f(x: &dyn Obj<U = i32, V = i32>) {
-    is_obj(x)
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-object-bounds-cycle-4.rs b/src/test/ui/traits/trait-object-bounds-cycle-4.rs
deleted file mode 100644 (file)
index f83cb75..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Check that we don't have a cycle when we try to normalize `Self::U` in the
-// bound below. Make sure that having a lifetime on the trait object doesn't break things
-
-// check-pass
-
-trait Is {
-    type T;
-}
-
-impl<U> Is for U {
-    type T = U;
-}
-
-trait Obj<'a> {
-    type U: Is<T = Self::V>;
-    type V;
-}
-
-fn is_obj<'a, T: ?Sized + Obj<'a>>(_: &T) {}
-
-fn f<'a>(x: &dyn Obj<'a, U = i32, V = i32>) {
-    is_obj(x)
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-object-exclusion.rs b/src/test/ui/traits/trait-object-exclusion.rs
deleted file mode 100644 (file)
index 0b8b0e2..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-trait Future: 'static {
-    // The requirement for Self: Sized must prevent instantiation of
-    // Future::forget in vtables, otherwise there's an infinite type
-    // recursion through <Map<...> as Future>::forget.
-    fn forget(self) where Self: Sized {
-        Box::new(Map(self)) as Box<dyn Future>;
-    }
-}
-
-struct Map<A>(A);
-impl<A: Future> Future for Map<A> {}
-
-pub struct Promise;
-impl Future for Promise {}
-
-fn main() {
-    Promise.forget();
-}
diff --git a/src/test/ui/traits/trait-object-generics.rs b/src/test/ui/traits/trait-object-generics.rs
deleted file mode 100644 (file)
index c187543..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// run-pass
-// test for #8664
-
-#![feature(box_syntax)]
-
-use std::marker;
-
-pub trait Trait2<A> {
-    fn doit(&self) -> A;
-}
-
-pub struct Impl<A1, A2, A3> {
-    m1: marker::PhantomData<(A1,A2,A3)>,
-    /*
-     * With A2 we get the ICE:
-     * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1',
-     * src/librustc/middle/subst.rs:58
-     */
-    t: Box<dyn Trait2<A2>+'static>
-}
-
-impl<A1, A2, A3> Impl<A1, A2, A3> {
-    pub fn step(&self) {
-        self.t.doit();
-    }
-}
-
-// test for #8601
-
-enum Type<T> { Constant(T) }
-
-trait Trait<K,V> {
-    fn method(&self, _: Type<(K,V)>) -> isize;
-}
-
-impl<V> Trait<u8,V> for () {
-    fn method(&self, _x: Type<(u8,V)>) -> isize { 0 }
-}
-
-pub fn main() {
-    let a = box () as Box<dyn Trait<u8, u8>>;
-    assert_eq!(a.method(Type::Constant((1, 2))), 0);
-}
diff --git a/src/test/ui/traits/trait-object-lifetime-first.rs b/src/test/ui/traits/trait-object-lifetime-first.rs
deleted file mode 100644 (file)
index 33757cb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// run-pass
-use std::fmt::Display;
-
-static BYTE: u8 = 33;
-
-fn main() {
-    let x: &(dyn 'static + Display) = &BYTE;
-    let y: Box<dyn 'static + Display> = Box::new(BYTE);
-    let xstr = format!("{}", x);
-    let ystr = format!("{}", y);
-    assert_eq!(xstr, "33");
-    assert_eq!(ystr, "33");
-}
diff --git a/src/test/ui/traits/trait-object-macro-matcher.rs b/src/test/ui/traits/trait-object-macro-matcher.rs
deleted file mode 100644 (file)
index 9109787..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// `ty` matcher accepts trait object types
-
-macro_rules! m {
-    ($t: ty) => ( let _: $t; )
-}
-
-fn main() {
-    m!(dyn Copy + Send + 'static);
-    //~^ ERROR the trait `Copy` cannot be made into an object
-    m!(dyn 'static + Send);
-    m!(dyn 'static +); //~ ERROR at least one trait is required for an object type
-}
diff --git a/src/test/ui/traits/trait-object-macro-matcher.stderr b/src/test/ui/traits/trait-object-macro-matcher.stderr
deleted file mode 100644 (file)
index 335eeb8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/trait-object-macro-matcher.rs:11:8
-   |
-LL |     m!(dyn 'static +);
-   |        ^^^^^^^^^^^^^
-
-error[E0038]: the trait `Copy` cannot be made into an object
-  --> $DIR/trait-object-macro-matcher.rs:8:8
-   |
-LL |     m!(dyn Copy + Send + 'static);
-   |        ^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` cannot be made into an object
-   |
-   = note: the trait cannot be made into an object because it requires `Self: Sized`
-   = note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0038, E0224.
-For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/trait-object-safety.rs b/src/test/ui/traits/trait-object-safety.rs
deleted file mode 100644 (file)
index f43d332..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Check that static methods are not object-safe.
-
-trait Tr {
-    fn foo();
-    fn bar(&self) { }
-}
-
-struct St;
-
-impl Tr for St {
-    fn foo() {}
-}
-
-fn main() {
-    let _: &dyn Tr = &St; //~ ERROR E0038
-    //~^ ERROR E0038
-}
diff --git a/src/test/ui/traits/trait-object-safety.stderr b/src/test/ui/traits/trait-object-safety.stderr
deleted file mode 100644 (file)
index 16f6096..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-error[E0038]: the trait `Tr` cannot be made into an object
-  --> $DIR/trait-object-safety.rs:15:22
-   |
-LL |     let _: &dyn Tr = &St;
-   |                      ^^^ `Tr` cannot be made into an object
-   |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $DIR/trait-object-safety.rs:4:8
-   |
-LL | trait Tr {
-   |       -- this trait cannot be made into an object...
-LL |     fn foo();
-   |        ^^^ ...because associated function `foo` has no `self` parameter
-   = note: required because of the requirements on the impl of `CoerceUnsized<&dyn Tr>` for `&St`
-   = note: required by cast to type `&dyn Tr`
-help: consider turning `foo` into a method by giving it a `&self` argument
-   |
-LL |     fn foo(&self);
-   |            ^^^^^
-help: alternatively, consider constraining `foo` so it does not apply to trait objects
-   |
-LL |     fn foo() where Self: Sized;
-   |              ^^^^^^^^^^^^^^^^^
-
-error[E0038]: the trait `Tr` cannot be made into an object
-  --> $DIR/trait-object-safety.rs:15:12
-   |
-LL |     let _: &dyn Tr = &St;
-   |            ^^^^^^^ `Tr` cannot be made into an object
-   |
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $DIR/trait-object-safety.rs:4:8
-   |
-LL | trait Tr {
-   |       -- this trait cannot be made into an object...
-LL |     fn foo();
-   |        ^^^ ...because associated function `foo` has no `self` parameter
-help: consider turning `foo` into a method by giving it a `&self` argument
-   |
-LL |     fn foo(&self);
-   |            ^^^^^
-help: alternatively, consider constraining `foo` so it does not apply to trait objects
-   |
-LL |     fn foo() where Self: Sized;
-   |              ^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/trait-object-supertrait-lifetime-bound.rs b/src/test/ui/traits/trait-object-supertrait-lifetime-bound.rs
deleted file mode 100644 (file)
index 9d83472..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// check-pass
-
-use std::any::Any;
-
-trait A<T>: Any {
-    fn m(&self) {}
-}
-
-impl<S, T: 'static> A<S> for T {}
-
-fn call_obj<'a>() {
-    let obj: &dyn A<&'a ()> = &();
-    obj.m();
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-object-vs-lifetime-2.rs b/src/test/ui/traits/trait-object-vs-lifetime-2.rs
deleted file mode 100644 (file)
index 0b33dc7..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// A few contrived examples where lifetime should (or should not) be parsed as an object type.
-// Lifetimes parsed as types are still rejected later by semantic checks.
-
-// `'static` is a lifetime, `'static +` is a type, `'a` is a type
-fn g() where
-    'static: 'static,
-    dyn 'static +: 'static + Copy,
-    //~^ ERROR at least one trait is required for an object type
-{}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-object-vs-lifetime-2.stderr b/src/test/ui/traits/trait-object-vs-lifetime-2.stderr
deleted file mode 100644 (file)
index 28b8e11..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/trait-object-vs-lifetime-2.rs:7:5
-   |
-LL |     dyn 'static +: 'static + Copy,
-   |     ^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0224`.
diff --git a/src/test/ui/traits/trait-object-vs-lifetime.rs b/src/test/ui/traits/trait-object-vs-lifetime.rs
deleted file mode 100644 (file)
index e49d276..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// A few contrived examples where lifetime should (or should not) be parsed as an object type.
-// Lifetimes parsed as types are still rejected later by semantic checks.
-
-struct S<'a, T>(&'a u8, T);
-
-fn main() {
-    // `'static` is a lifetime argument, `'static +` is a type argument
-    let _: S<'static, u8>;
-    let _: S<'static, dyn 'static +>;
-    //~^ at least one trait is required for an object type
-    let _: S<'static, 'static>;
-    //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
-    //~| ERROR this struct takes 1 type argument but 0 type arguments were supplied
-    let _: S<dyn 'static +, 'static>;
-    //~^ ERROR type provided when a lifetime was expected
-    //~| ERROR at least one trait is required for an object type
-}
diff --git a/src/test/ui/traits/trait-object-vs-lifetime.stderr b/src/test/ui/traits/trait-object-vs-lifetime.stderr
deleted file mode 100644 (file)
index 620c816..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/trait-object-vs-lifetime.rs:9:23
-   |
-LL |     let _: S<'static, dyn 'static +>;
-   |                       ^^^^^^^^^^^^^
-
-error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
-  --> $DIR/trait-object-vs-lifetime.rs:11:12
-   |
-LL |     let _: S<'static, 'static>;
-   |            ^        --------- help: remove this lifetime argument
-   |            |
-   |            expected 1 lifetime argument
-   |
-note: struct defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/trait-object-vs-lifetime.rs:4:8
-   |
-LL | struct S<'a, T>(&'a u8, T);
-   |        ^ --
-
-error[E0107]: this struct takes 1 type argument but 0 type arguments were supplied
-  --> $DIR/trait-object-vs-lifetime.rs:11:12
-   |
-LL |     let _: S<'static, 'static>;
-   |            ^ expected 1 type argument
-   |
-note: struct defined here, with 1 type parameter: `T`
-  --> $DIR/trait-object-vs-lifetime.rs:4:8
-   |
-LL | struct S<'a, T>(&'a u8, T);
-   |        ^     -
-help: add missing type argument
-   |
-LL |     let _: S<'static, 'static, T>;
-   |                              ^^^
-
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/trait-object-vs-lifetime.rs:14:14
-   |
-LL |     let _: S<dyn 'static +, 'static>;
-   |              ^^^^^^^^^^^^^
-
-error[E0747]: type provided when a lifetime was expected
-  --> $DIR/trait-object-vs-lifetime.rs:14:14
-   |
-LL |     let _: S<dyn 'static +, 'static>;
-   |              ^^^^^^^^^^^^^
-
-error: aborting due to 5 previous errors
-
-Some errors have detailed explanations: E0107, E0224, E0747.
-For more information about an error, try `rustc --explain E0107`.
diff --git a/src/test/ui/traits/trait-object-with-lifetime-bound.rs b/src/test/ui/traits/trait-object-with-lifetime-bound.rs
deleted file mode 100644 (file)
index 05aab5e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// run-pass
-// Uncovered during work on new scoping rules for safe destructors
-// as an important use case to support properly.
-
-
-pub struct E<'a> {
-    pub f: &'a u8,
-}
-impl<'b> E<'b> {
-    pub fn m(&self) -> &'b u8 { self.f }
-}
-
-pub struct P<'c> {
-    pub g: &'c u8,
-}
-pub trait M {
-    fn n(&self) -> u8;
-}
-impl<'d> M for P<'d> {
-    fn n(&self) -> u8 { *self.g }
-}
-
-fn extension<'e>(x: &'e E<'e>) -> Box<dyn M+'e> {
-    loop {
-        let p = P { g: x.m() };
-        return Box::new(p) as Box<dyn M+'e>;
-    }
-}
-
-fn main() {
-    let w = E { f: &10 };
-    let o = extension(&w);
-    assert_eq!(o.n(), 10);
-}
diff --git a/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs b/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.rs
deleted file mode 100644 (file)
index f34fa80..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// Regression test for #56288. Checks that if a supertrait defines an associated type
-// projection that references `Self`, then that associated type must still be explicitly
-// specified in the `dyn Trait` variant, since we don't know what `Self` is anymore.
-
-trait Base {
-    type Output;
-}
-
-trait Helper: Base<Output=<Self as Helper>::Target> {
-    type Target;
-}
-
-impl Base for u32
-{
-    type Output = i32;
-}
-
-impl Helper for u32
-{
-    type Target = i32;
-}
-
-trait ConstI32 {
-    type Out;
-}
-
-impl<T: ?Sized> ConstI32 for T {
-    type Out = i32;
-}
-
-// Test that you still need to manually give a projection type if the Output type
-// is normalizable.
-trait NormalizableHelper:
-    Base<Output=<Self as ConstI32>::Out>
-{
-    type Target;
-}
-
-impl NormalizableHelper for u32
-{
-    type Target = i32;
-}
-
-fn main() {
-    let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32);
-    //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
-
-    let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
-    //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified
-}
diff --git a/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr b/src/test/ui/traits/trait-object-with-self-in-projection-output-bad.stderr
deleted file mode 100644 (file)
index 79eb27e..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified
-  --> $DIR/trait-object-with-self-in-projection-output-bad.rs:45:21
-   |
-LL |     type Output;
-   |     ------------ `Output` defined here
-...
-LL |     let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32);
-   |                     ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper<Target=i32, Output = Type>`
-
-error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified
-  --> $DIR/trait-object-with-self-in-projection-output-bad.rs:48:21
-   |
-LL |     type Output;
-   |     ------------ `Output` defined here
-...
-LL |     let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32);
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: specify the associated type: `NormalizableHelper<Target=i32, Output = Type>`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0191`.
diff --git a/src/test/ui/traits/trait-object-with-self-in-projection-output-good.rs b/src/test/ui/traits/trait-object-with-self-in-projection-output-good.rs
deleted file mode 100644 (file)
index d1b7bf6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// build-pass (FIXME(62277): could be check-pass?)
-
-// Regression test related to #56288. Check that a supertrait projection (of
-// `Output`) that references `Self` can be ok if it is referencing a projection (of
-// `Self::Target`, in this case). Note that we still require the user to manually
-// specify both `Target` and `Output` for now.
-
-trait Base {
-    type Output;
-}
-
-trait Helper: Base<Output=<Self as Helper>::Target> {
-    type Target;
-}
-
-impl Base for u32
-{
-    type Output = i32;
-}
-
-impl Helper for u32
-{
-    type Target = i32;
-}
-
-fn main() {
-    let _x: Box<dyn Helper<Target=i32, Output=i32>> = Box::new(2u32);
-}
diff --git a/src/test/ui/traits/trait-object-with-self-in-projection-output-repeated-supertrait.rs b/src/test/ui/traits/trait-object-with-self-in-projection-output-repeated-supertrait.rs
deleted file mode 100644 (file)
index 39e8171..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// build-pass (FIXME(62277): could be check-pass?)
-
-// FIXME(eddyb) shorten the name so windows doesn't choke on it.
-#![crate_name = "trait_test"]
-
-// Regression test related to #56288. Check that a supertrait projection (of
-// `Output`) that references `Self` is ok if there is another occurrence of
-// the same supertrait that specifies the projection explicitly, even if
-// the projection's associated type is not explicitly specified in the object type.
-//
-// Note that in order for this to compile, we need the `Self`-referencing projection
-// to normalize fairly directly to a concrete type, otherwise the trait resolver
-// will hate us.
-//
-// There is a test in `trait-object-with-self-in-projection-output-bad.rs` that
-// having a normalizing, but `Self`-containing projection does not *by itself*
-// allow you to avoid writing the projected type (`Output`, in this example)
-// explicitly.
-
-trait ConstI32 {
-    type Out;
-}
-
-impl<T: ?Sized> ConstI32 for T {
-    type Out = i32;
-}
-
-trait Base {
-    type Output;
-}
-
-trait NormalizingHelper: Base<Output=<Self as ConstI32>::Out> + Base<Output=i32> {
-    type Target;
-}
-
-impl Base for u32
-{
-    type Output = i32;
-}
-
-impl NormalizingHelper for u32
-{
-    type Target = i32;
-}
-
-fn main() {
-    // Make sure this works both with and without the associated type
-    // being specified.
-    let _x: Box<dyn NormalizingHelper<Target=i32>> = Box::new(2u32);
-    let _y: Box<dyn NormalizingHelper<Target=i32, Output=i32>> = Box::new(2u32);
-}
diff --git a/src/test/ui/traits/trait-param-without-lifetime-constraint.rs b/src/test/ui/traits/trait-param-without-lifetime-constraint.rs
deleted file mode 100644 (file)
index a79b74d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-struct Article {
-    proof_reader: ProofReader,
-}
-
-struct ProofReader {
-    name: String,
-}
-
-pub trait HaveRelationship<To> {
-    fn get_relation(&self) -> To;
-}
-
-impl HaveRelationship<&ProofReader> for Article {
-    fn get_relation(&self) -> &ProofReader {
-    //~^ ERROR `impl` item signature doesn't match `trait` item signature
-        &self.proof_reader
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-param-without-lifetime-constraint.stderr b/src/test/ui/traits/trait-param-without-lifetime-constraint.stderr
deleted file mode 100644 (file)
index 4942dbe..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-error: `impl` item signature doesn't match `trait` item signature
-  --> $DIR/trait-param-without-lifetime-constraint.rs:14:5
-   |
-LL |     fn get_relation(&self) -> To;
-   |     ----------------------------- expected `fn(&Article) -> &ProofReader`
-...
-LL |     fn get_relation(&self) -> &ProofReader {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
-   |
-   = note: expected `fn(&Article) -> &ProofReader`
-              found `fn(&Article) -> &ProofReader`
-help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
-  --> $DIR/trait-param-without-lifetime-constraint.rs:10:31
-   |
-LL |     fn get_relation(&self) -> To;
-   |                               ^^ consider borrowing this type parameter in the trait
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/traits/trait-privacy.rs b/src/test/ui/traits/trait-privacy.rs
deleted file mode 100644 (file)
index 17a2e05..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// build-pass (FIXME(62277): could be check-pass?)
-#![allow(dead_code)]
-mod foo {
-    pub use self::bar::T;
-    mod bar {
-        pub trait T {
-            fn f(&self) {}
-        }
-        impl T for () {}
-    }
-}
-
-fn g() {
-    use foo::T;
-    ().f(); // Check that this does not trigger a privacy error
-}
-
-fn f() {
-    let error = ::std::thread::spawn(|| {}).join().unwrap_err();
-    error.type_id(); // Regression test for #21670
-}
-
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-region-pointer-simple.rs b/src/test/ui/traits/trait-region-pointer-simple.rs
deleted file mode 100644 (file)
index 0456ca9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// run-pass
-trait Foo {
-    fn f(&self) -> isize;
-}
-
-struct A {
-    x: isize
-}
-
-impl Foo for A {
-    fn f(&self) -> isize {
-        println!("Today's number is {}", self.x);
-        return self.x;
-    }
-}
-
-pub fn main() {
-    let a = A { x: 3 };
-    let b = (&a) as &dyn Foo;
-    assert_eq!(b.f(), 3);
-}
diff --git a/src/test/ui/traits/trait-resolution-in-overloaded-op.rs b/src/test/ui/traits/trait-resolution-in-overloaded-op.rs
deleted file mode 100644 (file)
index a9bacc3..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// #12402 Operator overloading only considers the method name, not which trait is implemented
-
-trait MyMul<Rhs, Res> {
-    fn mul(&self, rhs: &Rhs) -> Res;
-}
-
-fn foo<T: MyMul<f64, f64>>(a: &T, b: f64) -> f64 {
-    a * b //~ ERROR cannot multiply `&T` by `f64`
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr b/src/test/ui/traits/trait-resolution-in-overloaded-op.stderr
deleted file mode 100644 (file)
index ada76cd..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0369]: cannot multiply `&T` by `f64`
-  --> $DIR/trait-resolution-in-overloaded-op.rs:8:7
-   |
-LL |     a * b
-   |     - ^ - f64
-   |     |
-   |     &T
-   |
-help: consider further restricting this bound
-   |
-LL | fn foo<T: MyMul<f64, f64> + std::ops::Mul<Output = f64>>(a: &T, b: f64) -> f64 {
-   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0369`.
diff --git a/src/test/ui/traits/trait-safety-fn-body.rs b/src/test/ui/traits/trait-safety-fn-body.rs
deleted file mode 100644 (file)
index df52774..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Check that an unsafe impl does not imply that unsafe actions are
-// legal in the methods.
-
-unsafe trait UnsafeTrait : Sized {
-    fn foo(self) { }
-}
-
-unsafe impl UnsafeTrait for *mut isize {
-    fn foo(self) {
-        // Unsafe actions are not made legal by taking place in an unsafe trait:
-        *self += 1;
-        //~^ ERROR E0133
-    }
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-safety-fn-body.stderr b/src/test/ui/traits/trait-safety-fn-body.stderr
deleted file mode 100644 (file)
index a27cd86..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
-  --> $DIR/trait-safety-fn-body.rs:11:9
-   |
-LL |         *self += 1;
-   |         ^^^^^^^^^^ dereference of raw pointer
-   |
-   = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/traits/trait-safety-inherent-impl.rs b/src/test/ui/traits/trait-safety-inherent-impl.rs
deleted file mode 100644 (file)
index 50e15f0..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// Check that inherent impls cannot be unsafe.
-
-struct SomeStruct;
-
-unsafe impl SomeStruct { //~ ERROR inherent impls cannot be unsafe
-    fn foo(self) { }
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-safety-inherent-impl.stderr b/src/test/ui/traits/trait-safety-inherent-impl.stderr
deleted file mode 100644 (file)
index 0738d29..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0197]: inherent impls cannot be unsafe
-  --> $DIR/trait-safety-inherent-impl.rs:5:13
-   |
-LL | unsafe impl SomeStruct {
-   | ------      ^^^^^^^^^^ inherent impl for this type
-   | |
-   | unsafe because of this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0197`.
diff --git a/src/test/ui/traits/trait-safety-ok-cc.rs b/src/test/ui/traits/trait-safety-ok-cc.rs
deleted file mode 100644 (file)
index 099ba80..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// run-pass
-// aux-build:trait_safety_lib.rs
-
-// Simple smoke test that unsafe traits can be compiled across crates.
-
-
-extern crate trait_safety_lib as lib;
-
-use lib::Foo;
-
-struct Bar { x: isize }
-unsafe impl Foo for Bar {
-    fn foo(&self) -> isize { self.x }
-}
-
-fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
-
-fn main() {
-    let x: isize = 22;
-    assert_eq!(22, take_foo(&x));
-
-    let x: Bar = Bar { x: 23 };
-    assert_eq!(23, take_foo(&x));
-}
diff --git a/src/test/ui/traits/trait-safety-ok.rs b/src/test/ui/traits/trait-safety-ok.rs
deleted file mode 100644 (file)
index d456a78..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-pass
-// Simple smoke test that unsafe traits can be compiled etc.
-
-
-unsafe trait Foo {
-    fn foo(&self) -> isize;
-}
-
-unsafe impl Foo for isize {
-    fn foo(&self) -> isize { *self }
-}
-
-fn take_foo<F:Foo>(f: &F) -> isize { f.foo() }
-
-fn main() {
-    let x: isize = 22;
-    assert_eq!(22, take_foo(&x));
-}
diff --git a/src/test/ui/traits/trait-safety-trait-impl-cc.rs b/src/test/ui/traits/trait-safety-trait-impl-cc.rs
deleted file mode 100644 (file)
index 6f125e5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// aux-build:trait_safety_lib.rs
-
-// Check that unsafe traits require unsafe impls and that inherent
-// impls cannot be unsafe.
-
-extern crate trait_safety_lib as lib;
-
-struct Bar;
-impl lib::Foo for Bar { //~ ERROR requires an `unsafe impl` declaration
-    fn foo(&self) -> isize {
-        panic!();
-    }
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-safety-trait-impl-cc.stderr b/src/test/ui/traits/trait-safety-trait-impl-cc.stderr
deleted file mode 100644 (file)
index 2fcedc5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0200]: the trait `Foo` requires an `unsafe impl` declaration
-  --> $DIR/trait-safety-trait-impl-cc.rs:9:1
-   |
-LL | / impl lib::Foo for Bar {
-LL | |     fn foo(&self) -> isize {
-LL | |         panic!();
-LL | |     }
-LL | | }
-   | |_^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0200`.
diff --git a/src/test/ui/traits/trait-safety-trait-impl.rs b/src/test/ui/traits/trait-safety-trait-impl.rs
deleted file mode 100644 (file)
index 45258b7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Check that unsafe traits require unsafe impls and that inherent
-// impls cannot be unsafe.
-
-trait SafeTrait {
-    fn foo(&self) { }
-}
-
-unsafe trait UnsafeTrait {
-    fn foo(&self) { }
-}
-
-unsafe impl UnsafeTrait for u8 { } // OK
-
-impl UnsafeTrait for u16 { } //~ ERROR requires an `unsafe impl` declaration
-
-unsafe impl SafeTrait for u32 { } //~ ERROR the trait `SafeTrait` is not unsafe
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-safety-trait-impl.stderr b/src/test/ui/traits/trait-safety-trait-impl.stderr
deleted file mode 100644 (file)
index 5b29fd1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0200]: the trait `UnsafeTrait` requires an `unsafe impl` declaration
-  --> $DIR/trait-safety-trait-impl.rs:14:1
-   |
-LL | impl UnsafeTrait for u16 { }
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0199]: implementing the trait `SafeTrait` is not unsafe
-  --> $DIR/trait-safety-trait-impl.rs:16:1
-   |
-LL | unsafe impl SafeTrait for u32 { }
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0199, E0200.
-For more information about an error, try `rustc --explain E0199`.
diff --git a/src/test/ui/traits/trait-static-method-generic-inference.rs b/src/test/ui/traits/trait-static-method-generic-inference.rs
deleted file mode 100644 (file)
index 759416d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Issue #3902. We are (at least currently) unable to infer `Self`
-// based on `T`, even though there is only a single impl, because of
-// the possibility of associated types and other things (basically: no
-// constraints on `Self` here at all).
-
-mod base {
-    pub trait HasNew<T> {
-        fn new() -> T;
-        fn dummy(&self) { }
-    }
-
-    pub struct Foo {
-        dummy: (),
-    }
-
-    impl HasNew<Foo> for Foo {
-        fn new() -> Foo {
-            Foo { dummy: () }
-        }
-    }
-}
-
-pub fn foo() {
-    let _f: base::Foo = base::HasNew::new();
-    //~^ ERROR type annotations needed
-}
-
-fn main() { }
diff --git a/src/test/ui/traits/trait-static-method-generic-inference.stderr b/src/test/ui/traits/trait-static-method-generic-inference.stderr
deleted file mode 100644 (file)
index 6a7e8f5..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0283]: type annotations needed
-  --> $DIR/trait-static-method-generic-inference.rs:24:25
-   |
-LL |         fn new() -> T;
-   |         -------------- required by `HasNew::new`
-...
-LL |     let _f: base::Foo = base::HasNew::new();
-   |                         ^^^^^^^^^^^^^^^^^ cannot infer type
-   |
-   = note: cannot satisfy `_: HasNew<Foo>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0283`.
diff --git a/src/test/ui/traits/trait-static-method-overwriting.rs b/src/test/ui/traits/trait-static-method-overwriting.rs
deleted file mode 100644 (file)
index f669ffa..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-mod base {
-    pub trait HasNew {
-        fn new() -> Self;
-    }
-
-    pub struct Foo {
-        dummy: (),
-    }
-
-    impl ::base::HasNew for Foo {
-        fn new() -> Foo {
-            println!("Foo");
-            Foo { dummy: () }
-        }
-    }
-
-    pub struct Bar {
-        dummy: (),
-    }
-
-    impl ::base::HasNew for Bar {
-        fn new() -> Bar {
-            println!("Bar");
-            Bar { dummy: () }
-        }
-    }
-}
-
-pub fn main() {
-    let _f: base::Foo = base::HasNew::new();
-    let _b: base::Bar = base::HasNew::new();
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-issue-39029.fixed b/src/test/ui/traits/trait-suggest-deferences-issue-39029.fixed
deleted file mode 100644 (file)
index a1abf66..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-rustfix
-use std::net::TcpListener;
-
-struct NoToSocketAddrs(String);
-
-impl std::ops::Deref for NoToSocketAddrs {
-    type Target = String;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-
-fn main() {
-    let _works = TcpListener::bind("some string");
-    let bad = NoToSocketAddrs("bad".to_owned());
-    let _errors = TcpListener::bind(&*bad);
-    //~^ ERROR the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-issue-39029.rs b/src/test/ui/traits/trait-suggest-deferences-issue-39029.rs
deleted file mode 100644 (file)
index 90d0971..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-rustfix
-use std::net::TcpListener;
-
-struct NoToSocketAddrs(String);
-
-impl std::ops::Deref for NoToSocketAddrs {
-    type Target = String;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-
-fn main() {
-    let _works = TcpListener::bind("some string");
-    let bad = NoToSocketAddrs("bad".to_owned());
-    let _errors = TcpListener::bind(&bad);
-    //~^ ERROR the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-issue-39029.stderr b/src/test/ui/traits/trait-suggest-deferences-issue-39029.stderr
deleted file mode 100644 (file)
index 4273b8e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0277]: the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied
-  --> $DIR/trait-suggest-deferences-issue-39029.rs:16:37
-   |
-LL |     let _errors = TcpListener::bind(&bad);
-   |                                     ^^^^
-   |                                     |
-   |                                     the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs`
-   |                                     help: consider adding dereference here: `&*bad`
-   | 
-  ::: $SRC_DIR/std/src/net/tcp.rs:LL:COL
-   |
-LL |     pub fn bind<A: ToSocketAddrs>(addr: A) -> io::Result<TcpListener> {
-   |                    ------------- required by this bound in `TcpListener::bind`
-   |
-   = note: required because of the requirements on the impl of `ToSocketAddrs` for `&NoToSocketAddrs`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-suggest-deferences-issue-62530.fixed b/src/test/ui/traits/trait-suggest-deferences-issue-62530.fixed
deleted file mode 100644 (file)
index 406caaa..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-rustfix
-fn takes_str(_x: &str) {}
-
-fn takes_type_parameter<T>(_x: T) where T: SomeTrait {}
-
-trait SomeTrait {}
-impl SomeTrait for &'_ str {}
-impl SomeTrait for char {}
-
-fn main() {
-    let string = String::new();
-    takes_str(&string);             // Ok
-    takes_type_parameter(&*string);  // Error
-    //~^ ERROR the trait bound `&String: SomeTrait` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-issue-62530.rs b/src/test/ui/traits/trait-suggest-deferences-issue-62530.rs
deleted file mode 100644 (file)
index 53846be..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-rustfix
-fn takes_str(_x: &str) {}
-
-fn takes_type_parameter<T>(_x: T) where T: SomeTrait {}
-
-trait SomeTrait {}
-impl SomeTrait for &'_ str {}
-impl SomeTrait for char {}
-
-fn main() {
-    let string = String::new();
-    takes_str(&string);             // Ok
-    takes_type_parameter(&string);  // Error
-    //~^ ERROR the trait bound `&String: SomeTrait` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-issue-62530.stderr b/src/test/ui/traits/trait-suggest-deferences-issue-62530.stderr
deleted file mode 100644 (file)
index eaec87d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0277]: the trait bound `&String: SomeTrait` is not satisfied
-  --> $DIR/trait-suggest-deferences-issue-62530.rs:13:26
-   |
-LL | fn takes_type_parameter<T>(_x: T) where T: SomeTrait {}
-   |                                            --------- required by this bound in `takes_type_parameter`
-...
-LL |     takes_type_parameter(&string);  // Error
-   |                          ^^^^^^^
-   |                          |
-   |                          the trait `SomeTrait` is not implemented for `&String`
-   |                          help: consider adding dereference here: `&*string`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-suggest-deferences-multiple-0.fixed b/src/test/ui/traits/trait-suggest-deferences-multiple-0.fixed
deleted file mode 100644 (file)
index b7160b7..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// run-rustfix
-use std::ops::Deref;
-
-trait Happy {}
-struct LDM;
-impl Happy for &LDM {}
-
-struct Foo(LDM);
-struct Bar(Foo);
-struct Baz(Bar);
-impl Deref for Foo {
-    type Target = LDM;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl Deref for Bar {
-    type Target = Foo;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl Deref for Baz {
-    type Target = Bar;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-
-fn foo<T>(_: T) where T: Happy {}
-
-fn main() {
-    let baz = Baz(Bar(Foo(LDM)));
-    foo(&***baz);
-    //~^ ERROR the trait bound `&Baz: Happy` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-multiple-0.rs b/src/test/ui/traits/trait-suggest-deferences-multiple-0.rs
deleted file mode 100644 (file)
index 9ac5517..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// run-rustfix
-use std::ops::Deref;
-
-trait Happy {}
-struct LDM;
-impl Happy for &LDM {}
-
-struct Foo(LDM);
-struct Bar(Foo);
-struct Baz(Bar);
-impl Deref for Foo {
-    type Target = LDM;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl Deref for Bar {
-    type Target = Foo;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl Deref for Baz {
-    type Target = Bar;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-
-fn foo<T>(_: T) where T: Happy {}
-
-fn main() {
-    let baz = Baz(Bar(Foo(LDM)));
-    foo(&baz);
-    //~^ ERROR the trait bound `&Baz: Happy` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-multiple-0.stderr b/src/test/ui/traits/trait-suggest-deferences-multiple-0.stderr
deleted file mode 100644 (file)
index add34a5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0277]: the trait bound `&Baz: Happy` is not satisfied
-  --> $DIR/trait-suggest-deferences-multiple-0.rs:34:9
-   |
-LL | fn foo<T>(_: T) where T: Happy {}
-   |                          ----- required by this bound in `foo`
-...
-LL |     foo(&baz);
-   |         ^^^^
-   |         |
-   |         the trait `Happy` is not implemented for `&Baz`
-   |         help: consider adding dereference here: `&***baz`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-suggest-deferences-multiple-1.rs b/src/test/ui/traits/trait-suggest-deferences-multiple-1.rs
deleted file mode 100644 (file)
index 91c6c79..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-use std::ops::{Deref, DerefMut};
-
-trait Happy {}
-struct LDM;
-impl Happy for &mut LDM {}
-
-struct Foo(LDM);
-struct Bar(Foo);
-struct Baz(Bar);
-impl Deref for Foo {
-    type Target = LDM;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl Deref for Bar {
-    type Target = Foo;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl Deref for Baz {
-    type Target = Bar;
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
-impl DerefMut for Foo {
-    fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self.0
-    }
-}
-impl DerefMut for Bar {
-    fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self.0
-    }
-}
-impl DerefMut for Baz {
-    fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self.0
-    }
-}
-
-
-fn foo<T>(_: T) where T: Happy {}
-
-fn main() {
-    // Currently the compiler doesn't try to suggest dereferences for situations
-    // where DerefMut involves. So this test is meant to ensure compiler doesn't
-    // generate incorrect help message.
-    let mut baz = Baz(Bar(Foo(LDM)));
-    foo(&mut baz);
-    //~^ ERROR the trait bound `&mut Baz: Happy` is not satisfied
-}
diff --git a/src/test/ui/traits/trait-suggest-deferences-multiple-1.stderr b/src/test/ui/traits/trait-suggest-deferences-multiple-1.stderr
deleted file mode 100644 (file)
index e90278f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0277]: the trait bound `&mut Baz: Happy` is not satisfied
-  --> $DIR/trait-suggest-deferences-multiple-1.rs:52:9
-   |
-LL | fn foo<T>(_: T) where T: Happy {}
-   |                          ----- required by this bound in `foo`
-...
-LL |     foo(&mut baz);
-   |         ^^^^^^^^ the trait `Happy` is not implemented for `&mut Baz`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-suggest-where-clause.rs b/src/test/ui/traits/trait-suggest-where-clause.rs
deleted file mode 100644 (file)
index 46d047a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-use std::mem;
-
-struct Misc<T:?Sized>(T);
-
-fn check<T: Iterator, U: ?Sized>() {
-    // suggest a where-clause, if needed
-    mem::size_of::<U>();
-    //~^ ERROR the size for values of type
-
-    mem::size_of::<Misc<U>>();
-    //~^ ERROR the size for values of type
-
-    // ... even if T occurs as a type parameter
-
-    <u64 as From<T>>::from;
-    //~^ ERROR `u64: From<T>` is not satisfied
-
-    <u64 as From<<T as Iterator>::Item>>::from;
-    //~^ ERROR `u64: From<<T as Iterator>::Item>` is not satisfied
-
-    // ... but not if there are inference variables
-
-    <Misc<_> as From<T>>::from;
-    //~^ ERROR `Misc<_>: From<T>` is not satisfied
-
-    // ... and also not if the error is not related to the type
-
-    mem::size_of::<[T]>();
-    //~^ ERROR the size for values of type
-
-    mem::size_of::<[&U]>();
-    //~^ ERROR the size for values of type
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr
deleted file mode 100644 (file)
index 0f6f8d7..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-error[E0277]: the size for values of type `U` cannot be known at compilation time
-  --> $DIR/trait-suggest-where-clause.rs:7:20
-   |
-LL | fn check<T: Iterator, U: ?Sized>() {
-   |                       - this type parameter needs to be `Sized`
-LL |     // suggest a where-clause, if needed
-LL |     mem::size_of::<U>();
-   |                    ^ doesn't have a size known at compile-time
-   | 
-  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
-   |
-LL | pub const fn size_of<T>() -> usize {
-   |                      - required by this bound in `std::mem::size_of`
-
-error[E0277]: the size for values of type `U` cannot be known at compilation time
-  --> $DIR/trait-suggest-where-clause.rs:10:5
-   |
-LL | fn check<T: Iterator, U: ?Sized>() {
-   |                       - this type parameter needs to be `Sized`
-...
-LL |     mem::size_of::<Misc<U>>();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
-   | 
-  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
-   |
-LL | pub const fn size_of<T>() -> usize {
-   |                      - required by this bound in `std::mem::size_of`
-   |
-   = note: required because it appears within the type `Misc<U>`
-
-error[E0277]: the trait bound `u64: From<T>` is not satisfied
-  --> $DIR/trait-suggest-where-clause.rs:15:5
-   |
-LL |     <u64 as From<T>>::from;
-   |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `u64`
-   |
-   = note: required by `from`
-
-error[E0277]: the trait bound `u64: From<<T as Iterator>::Item>` is not satisfied
-  --> $DIR/trait-suggest-where-clause.rs:18:5
-   |
-LL |     <u64 as From<<T as Iterator>::Item>>::from;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<<T as Iterator>::Item>` is not implemented for `u64`
-   |
-   = note: required by `from`
-
-error[E0277]: the trait bound `Misc<_>: From<T>` is not satisfied
-  --> $DIR/trait-suggest-where-clause.rs:23:5
-   |
-LL |     <Misc<_> as From<T>>::from;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<T>` is not implemented for `Misc<_>`
-   |
-   = note: required by `from`
-
-error[E0277]: the size for values of type `[T]` cannot be known at compilation time
-  --> $DIR/trait-suggest-where-clause.rs:28:20
-   |
-LL |     mem::size_of::<[T]>();
-   |                    ^^^ doesn't have a size known at compile-time
-   | 
-  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
-   |
-LL | pub const fn size_of<T>() -> usize {
-   |                      - required by this bound in `std::mem::size_of`
-   |
-   = help: the trait `Sized` is not implemented for `[T]`
-
-error[E0277]: the size for values of type `[&U]` cannot be known at compilation time
-  --> $DIR/trait-suggest-where-clause.rs:31:5
-   |
-LL |     mem::size_of::<[&U]>();
-   |     ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
-   | 
-  ::: $SRC_DIR/core/src/mem/mod.rs:LL:COL
-   |
-LL | pub const fn size_of<T>() -> usize {
-   |                      - required by this bound in `std::mem::size_of`
-   |
-   = help: the trait `Sized` is not implemented for `[&U]`
-
-error: aborting due to 7 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/trait-test-2.rs b/src/test/ui/traits/trait-test-2.rs
deleted file mode 100644 (file)
index a337731..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#![feature(box_syntax)]
-
-#[allow(non_camel_case_types)]
-trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
-impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah<X>(&self) {} }
-impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} }
-
-fn main() {
-    10.dup::<i32>();
-    //~^ ERROR this associated function takes 0 type arguments but 1 type argument was supplied
-    10.blah::<i32, i32>();
-    //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied
-    (box 10 as Box<dyn bar>).dup();
-    //~^ ERROR E0038
-    //~| ERROR E0038
-}
diff --git a/src/test/ui/traits/trait-test-2.stderr b/src/test/ui/traits/trait-test-2.stderr
deleted file mode 100644 (file)
index a38d338..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
-  --> $DIR/trait-test-2.rs:9:8
-   |
-LL |     10.dup::<i32>();
-   |        ^^^------- help: remove these generics
-   |        |
-   |        expected 0 type arguments
-   |
-note: associated function defined here, with 0 type parameters
-  --> $DIR/trait-test-2.rs:4:16
-   |
-LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
-   |                ^^^
-
-error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied
-  --> $DIR/trait-test-2.rs:11:8
-   |
-LL |     10.blah::<i32, i32>();
-   |        ^^^^      ----- help: remove this type argument
-   |        |
-   |        expected 1 type argument
-   |
-note: associated function defined here, with 1 type parameter: `X`
-  --> $DIR/trait-test-2.rs:4:39
-   |
-LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
-   |                                       ^^^^ -
-
-error[E0038]: the trait `bar` cannot be made into an object
-  --> $DIR/trait-test-2.rs:13:16
-   |
-LL |     (box 10 as Box<dyn bar>).dup();
-   |                ^^^^^^^^^^^^ `bar` cannot be made into an object
-   |
-   = help: consider moving `dup` to another trait
-   = help: consider moving `blah` to another trait
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $DIR/trait-test-2.rs:4:30
-   |
-LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
-   |       ---                    ^^^^     ^^^^ ...because method `blah` has generic type parameters
-   |       |                      |
-   |       |                      ...because method `dup` references the `Self` type in its return type
-   |       this trait cannot be made into an object...
-
-error[E0038]: the trait `bar` cannot be made into an object
-  --> $DIR/trait-test-2.rs:13:6
-   |
-LL |     (box 10 as Box<dyn bar>).dup();
-   |      ^^^^^^ `bar` cannot be made into an object
-   |
-   = help: consider moving `dup` to another trait
-   = help: consider moving `blah` to another trait
-note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
-  --> $DIR/trait-test-2.rs:4:30
-   |
-LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
-   |       ---                    ^^^^     ^^^^ ...because method `blah` has generic type parameters
-   |       |                      |
-   |       |                      ...because method `dup` references the `Self` type in its return type
-   |       this trait cannot be made into an object...
-   = note: required because of the requirements on the impl of `CoerceUnsized<Box<dyn bar>>` for `Box<{integer}>`
-   = note: required by cast to type `Box<dyn bar>`
-
-error: aborting due to 4 previous errors
-
-Some errors have detailed explanations: E0038, E0107.
-For more information about an error, try `rustc --explain E0038`.
diff --git a/src/test/ui/traits/trait-test.rs b/src/test/ui/traits/trait-test.rs
deleted file mode 100644 (file)
index 72fc66f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#[allow(non_camel_case_types)]
-trait foo { fn foo(&self); }
-
-impl isize for usize { fn foo(&self) {} } //~ ERROR trait
-
-fn main() {}
diff --git a/src/test/ui/traits/trait-test.stderr b/src/test/ui/traits/trait-test.stderr
deleted file mode 100644 (file)
index f5e47e5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0404]: expected trait, found builtin type `isize`
-  --> $DIR/trait-test.rs:4:6
-   |
-LL | impl isize for usize { fn foo(&self) {} }
-   |      ^^^^^ not a trait
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0404`.
diff --git a/src/test/ui/traits/trait-to-str.rs b/src/test/ui/traits/trait-to-str.rs
deleted file mode 100644 (file)
index 9670edb..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-
-trait to_str {
-    fn to_string_(&self) -> String;
-}
-
-impl to_str for isize {
-    fn to_string_(&self) -> String { self.to_string() }
-}
-
-impl<T:to_str> to_str for Vec<T> {
-    fn to_string_(&self) -> String {
-        format!("[{}]",
-                self.iter()
-                    .map(|e| e.to_string_())
-                    .collect::<Vec<String>>()
-                    .join(", "))
-    }
-}
-
-pub fn main() {
-    assert_eq!(1.to_string_(), "1".to_string());
-    assert_eq!((vec![2, 3, 4]).to_string_(), "[2, 3, 4]".to_string());
-
-    fn indirect<T:to_str>(x: T) -> String {
-        format!("{}!", x.to_string_())
-    }
-    assert_eq!(indirect(vec![10, 20]), "[10, 20]!".to_string());
-
-    fn indirect2<T:to_str>(x: T) -> String {
-        indirect(x)
-    }
-    assert_eq!(indirect2(vec![1]), "[1]!".to_string());
-}
diff --git a/src/test/ui/traits/trait-where-clause-vs-impl.rs b/src/test/ui/traits/trait-where-clause-vs-impl.rs
deleted file mode 100644 (file)
index 7cfee27..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-#![allow(unused_variables)]
-// Test that when there is a conditional (but blanket) impl and a
-// where clause, we don't get confused in trait resolution.
-//
-// Issue #18453.
-
-// pretty-expanded FIXME #23616
-
-use std::rc::Rc;
-
-pub trait Foo<M> {
-    fn foo(&mut self, msg: M);
-}
-
-pub trait Bar<M> {
-    fn dummy(&self) -> M;
-}
-
-impl<M, F: Bar<M>> Foo<M> for F {
-    fn foo(&mut self, msg: M) {
-    }
-}
-
-pub struct Both<M, F> {
-    inner: Rc<(M, F)>,
-}
-
-impl<M, F: Foo<M>> Clone for Both<M, F> {
-    fn clone(&self) -> Both<M, F> {
-        Both { inner: self.inner.clone() }
-    }
-}
-
-fn repro1<M, F: Foo<M>>(_both: Both<M, F>) {
-}
-
-fn repro2<M, F: Foo<M>>(msg: M, foo: F) {
-    let both = Both { inner: Rc::new((msg, foo)) };
-    repro1(both.clone()); // <--- This clone causes problem
-}
-
-pub fn main() {
-}
diff --git a/src/test/ui/traits/trait-with-bounds-default.rs b/src/test/ui/traits/trait-with-bounds-default.rs
deleted file mode 100644 (file)
index 31f73d7..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// run-pass
-
-pub trait Clone2 {
-    /// Returns a copy of the value. The contents of boxes
-    /// are copied to maintain uniqueness, while the contents of
-    /// managed pointers are not copied.
-    fn clone(&self) -> Self;
-}
-
-trait Getter<T: Clone> {
-    fn do_get(&self) -> T;
-
-    fn do_get2(&self) -> (T, T) {
-        let x = self.do_get();
-        (x.clone(), x.clone())
-    }
-
-}
-
-impl Getter<isize> for isize {
-    fn do_get(&self) -> isize { *self }
-}
-
-impl<T: Clone> Getter<T> for Option<T> {
-    fn do_get(&self) -> T { self.as_ref().unwrap().clone() }
-}
-
-
-pub fn main() {
-    assert_eq!(3.do_get2(), (3, 3));
-    assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
-}
diff --git a/src/test/ui/traits/trait-with-dst.rs b/src/test/ui/traits/trait-with-dst.rs
deleted file mode 100644 (file)
index a3e3b31..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// build-pass (FIXME(62277): could be check-pass?)
-// #55266
-
-struct VTable<DST: ?Sized> {
-    _to_dst_ptr: fn(*mut ()) -> *mut DST,
-}
-
-trait HasVTableFor<DST: ?Sized + 'static> {
-    const VTABLE: &'static VTable<DST>;
-}
-
-impl<T, DST: ?Sized + 'static> HasVTableFor<DST> for T {
-    const VTABLE: &'static VTable<DST> = &VTable {
-        _to_dst_ptr: |_: *mut ()| unsafe { std::mem::zeroed() },
-    };
-}
-
-pub fn push<DST: ?Sized + 'static, T>() {
-    <T as HasVTableFor<DST>>::VTABLE;
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.rs
deleted file mode 100644 (file)
index 579ce7c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// Test case where an associated type is referenced from within the
-// supertrait definition, and the impl makes the wrong
-// associations. Issue #20220.
-
-use std::vec::IntoIter;
-
-pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
-    type Key;
-}
-
-impl Foo for IntoIter<i32> {
-    type Key = u32; //~ ERROR type mismatch
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr b/src/test/ui/traits/traits-assoc-type-in-supertrait-bad.stderr
deleted file mode 100644 (file)
index 5ac7b08..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0271]: type mismatch resolving `<std::vec::IntoIter<i32> as Iterator>::Item == u32`
-  --> $DIR/traits-assoc-type-in-supertrait-bad.rs:12:16
-   |
-LL |     type Key = u32;
-   |                ^^^ expected `i32`, found `u32`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0271`.
diff --git a/src/test/ui/traits/traits-assoc-type-in-supertrait.rs b/src/test/ui/traits/traits-assoc-type-in-supertrait.rs
deleted file mode 100644 (file)
index 7d6a754..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-// Test case where an associated type is referenced from within the
-// supertrait definition. Issue #20220.
-
-
-use std::vec::IntoIter;
-
-pub trait Foo: Iterator<Item=<Self as Foo>::Key> {
-    type Key;
-}
-
-impl Foo for IntoIter<i32> {
-    type Key = i32;
-}
-
-fn sum_foo<F:Foo<Key=i32>>(f: F) -> i32 {
-    f.fold(0, |a,b| a + b)
-}
-
-fn main() {
-    let x = sum_foo(vec![11, 10, 1].into_iter());
-    assert_eq!(x, 22);
-}
diff --git a/src/test/ui/traits/traits-conditional-dispatch.rs b/src/test/ui/traits/traits-conditional-dispatch.rs
deleted file mode 100644 (file)
index a9c1944..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// run-pass
-// Test that we are able to resolve conditional dispatch.  Here, the
-// blanket impl for T:Copy coexists with an impl for Box<T>, because
-// Box does not impl Copy.
-
-#![feature(box_syntax)]
-
-trait Get {
-    fn get(&self) -> Self;
-}
-
-trait MyCopy { fn copy(&self) -> Self; }
-impl MyCopy for u16 { fn copy(&self) -> Self { *self } }
-impl MyCopy for u32 { fn copy(&self) -> Self { *self } }
-impl MyCopy for i32 { fn copy(&self) -> Self { *self } }
-impl<T:Copy> MyCopy for Option<T> { fn copy(&self) -> Self { *self } }
-
-impl<T:MyCopy> Get for T {
-    fn get(&self) -> T { self.copy() }
-}
-
-impl Get for Box<i32> {
-    fn get(&self) -> Box<i32> { box get_it(&**self) }
-}
-
-fn get_it<T:Get>(t: &T) -> T {
-    (*t).get()
-}
-
-fn main() {
-    assert_eq!(get_it(&1_u32), 1_u32);
-    assert_eq!(get_it(&1_u16), 1_u16);
-    assert_eq!(get_it(&Some(1_u16)), Some(1_u16));
-    assert_eq!(get_it(&Box::new(1)), Box::new(1));
-}
diff --git a/src/test/ui/traits/traits-conditional-model-fn.rs b/src/test/ui/traits/traits-conditional-model-fn.rs
deleted file mode 100644 (file)
index ba88670..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// run-pass
-#![allow(unused_imports)]
-// A model for how the `Fn` traits could work. You can implement at
-// most one of `Go`, `GoMut`, or `GoOnce`, and then the others follow
-// automatically.
-
-// aux-build:go_trait.rs
-
-extern crate go_trait;
-
-use go_trait::{Go, GoMut, GoOnce, go, go_mut, go_once};
-
-use std::rc::Rc;
-use std::cell::Cell;
-
-struct SomeGoableThing {
-    counter: Rc<Cell<isize>>
-}
-
-impl Go for SomeGoableThing {
-    fn go(&self, arg: isize) {
-        self.counter.set(self.counter.get() + arg);
-    }
-}
-
-struct SomeGoOnceableThing {
-    counter: Rc<Cell<isize>>
-}
-
-impl GoOnce for SomeGoOnceableThing {
-    fn go_once(self, arg: isize) {
-        self.counter.set(self.counter.get() + arg);
-    }
-}
-
-fn main() {
-    let counter = Rc::new(Cell::new(0));
-    let mut x = SomeGoableThing { counter: counter.clone() };
-
-    go(&x, 10);
-    assert_eq!(counter.get(), 10);
-
-    go_mut(&mut x, 100);
-    assert_eq!(counter.get(), 110);
-
-    go_once(x, 1_000);
-    assert_eq!(counter.get(), 1_110);
-
-    let x = SomeGoOnceableThing { counter: counter.clone() };
-
-    go_once(x, 10_000);
-    assert_eq!(counter.get(), 11_110);
-}
diff --git a/src/test/ui/traits/traits-default-method-macro.rs b/src/test/ui/traits/traits-default-method-macro.rs
deleted file mode 100644 (file)
index 2b50ee9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-
-
-trait Foo {
-    fn bar(&self) -> String {
-        format!("test")
-    }
-}
-
-enum Baz {
-    Quux
-}
-
-impl Foo for Baz {
-}
-
-pub fn main() {
-    let q = Baz::Quux;
-    assert_eq!(q.bar(), "test".to_string());
-}
diff --git a/src/test/ui/traits/traits-default-method-mut.rs b/src/test/ui/traits/traits-default-method-mut.rs
deleted file mode 100644 (file)
index 5f8e983..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// run-pass
-#![allow(unused_assignments)]
-// pretty-expanded FIXME #23616
-
-#![allow(unused_variables)]
-
-trait Foo {
-    fn foo(&self, mut v: isize) { v = 1; }
-}
-
-pub fn main() {}
diff --git a/src/test/ui/traits/traits-default-method-self.rs b/src/test/ui/traits/traits-default-method-self.rs
deleted file mode 100644 (file)
index cdf4d1e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-pass
-
-
-trait Cat {
-    fn meow(&self) -> bool;
-    fn scratch(&self) -> bool { self.purr() }
-    fn purr(&self) -> bool { true }
-}
-
-impl Cat for isize {
-    fn meow(&self) -> bool {
-        self.scratch()
-    }
-}
-
-pub fn main() {
-    assert!(5.meow());
-}
diff --git a/src/test/ui/traits/traits-default-method-trivial.rs b/src/test/ui/traits/traits-default-method-trivial.rs
deleted file mode 100644 (file)
index dc41938..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// run-pass
-
-
-trait Cat {
-    fn meow(&self) -> bool;
-    fn scratch(&self) -> bool;
-    fn purr(&self) -> bool { true }
-}
-
-impl Cat for isize {
-    fn meow(&self) -> bool {
-        self.scratch()
-    }
-    fn scratch(&self) -> bool {
-        self.purr()
-    }
-}
-
-pub fn main() {
-    assert!(5.meow());
-}
diff --git a/src/test/ui/traits/traits-elaborate-type-region.rs b/src/test/ui/traits/traits-elaborate-type-region.rs
deleted file mode 100644 (file)
index 03aef01..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-
-// Test that we elaborate `Type: 'region` constraints and infer various important things.
-
-trait Master<'a, T: ?Sized> {
-    fn foo() where T: 'a;
-}
-
-// [U]: 'a => U: 'a
-impl<'a, U> Master<'a, [U]> for () {
-    fn foo() where U: 'a { }
-}
-
-// &'b U: 'a => 'b: 'a, U: 'a
-impl<'a, 'b, U> Master<'a, &'b U> for () {
-    fn foo() where 'b: 'a, U: 'a { }
-}
-
-// &'b [U]: 'a => 'b: 'a, U: 'a
-impl<'a, 'b, U> Master<'a, &'b [U]> for () {
-    fn foo() where 'b: 'a, U: 'a { }
-}
-
-// Foo<'b>: 'a => 'b: 'a
-struct Foo<'a> { x: &'a () }
-impl<'a, 'b> Master<'a, Foo<'b>> for () {
-    fn foo() where 'b: 'a { }
-}
-
-// Bar<'b, T>: 'a => 'b: 'a, T: 'a
-struct Bar<'a, T: 'a> { x: &'a T }
-impl<'a, 'b, T> Master<'a, Bar<'b, T>> for () {
-    fn foo() where 'b: 'a, T: 'a { }
-}
-
-// fn(T): 'a => T: 'a
-impl<'a, T> Master<'a, fn(T)> for () {
-    fn foo() where T: 'a { }
-}
-
-// fn() -> T: 'a => T: 'a
-impl<'a, T> Master<'a, fn() -> T> for () {
-    fn foo() where T: 'a { }
-}
-
-fn main() {
-    println!("Hello, world!");
-}
diff --git a/src/test/ui/traits/traits-impl-object-overlap-issue-23853.rs b/src/test/ui/traits/traits-impl-object-overlap-issue-23853.rs
deleted file mode 100644 (file)
index e490967..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-pass
-// Test that we are able to compile the case where both a blanket impl
-// and the object type itself supply the required trait obligation.
-// In this case, the blanket impl for `Foo` applies to any type,
-// including `Bar`, but the object type `Bar` also implicitly supplies
-// this context.
-
-trait Foo { fn dummy(&self) { } }
-
-trait Bar: Foo { }
-
-impl<T:?Sized> Foo for T { }
-
-fn want_foo<B:?Sized+Foo>() { }
-
-fn main() {
-    want_foo::<dyn Bar>();
-}
diff --git a/src/test/ui/traits/traits-inductive-overflow-lifetime.rs b/src/test/ui/traits/traits-inductive-overflow-lifetime.rs
deleted file mode 100644 (file)
index 205d50a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Test that we don't hit the recursion limit for short cycles involving lifetimes.
-
-// Shouldn't hit this, we should realize that we're in a cycle sooner.
-#![recursion_limit="20"]
-
-trait NotAuto {}
-trait Y {
-    type P;
-}
-
-impl<'a> Y for C<'a> {
-    type P = Box<X<C<'a>>>;
-}
-
-struct C<'a>(&'a ());
-struct X<T: Y>(T::P);
-
-impl<T: NotAuto> NotAuto for Box<T> {}
-impl<T: Y> NotAuto for X<T> where T::P: NotAuto {}
-impl<'a> NotAuto for C<'a> {}
-
-fn is_send<S: NotAuto>() {}
-//~^ NOTE: required
-
-fn main() {
-    // Should only be a few notes.
-    is_send::<X<C<'static>>>();
-    //~^ ERROR overflow evaluating
-    //~| NOTE: required
-}
diff --git a/src/test/ui/traits/traits-inductive-overflow-lifetime.stderr b/src/test/ui/traits/traits-inductive-overflow-lifetime.stderr
deleted file mode 100644 (file)
index b904826..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0275]: overflow evaluating the requirement `Box<X<C<'_>>>: NotAuto`
-  --> $DIR/traits-inductive-overflow-lifetime.rs:27:5
-   |
-LL | fn is_send<S: NotAuto>() {}
-   |               ------- required by this bound in `is_send`
-...
-LL |     is_send::<X<C<'static>>>();
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: required because of the requirements on the impl of `NotAuto` for `X<C<'static>>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/traits-inductive-overflow-simultaneous.rs b/src/test/ui/traits/traits-inductive-overflow-simultaneous.rs
deleted file mode 100644 (file)
index 40ac921..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Regression test for #33344, initial version. This example allowed
-// arbitrary trait bounds to be synthesized.
-
-trait Tweedledum: IntoIterator {}
-trait Tweedledee: IntoIterator {}
-
-impl<T: Tweedledum> Tweedledee for T {}
-impl<T: Tweedledee> Tweedledum for T {}
-
-trait Combo: IntoIterator {}
-impl<T: Tweedledee + Tweedledum> Combo for T {}
-
-fn is_ee<T: Combo>(t: T) {
-    t.into_iter();
-}
-
-fn main() {
-    is_ee(4);
-    //~^ ERROR overflow evaluating the requirement `{integer}: Tweedle
-}
diff --git a/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr b/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr
deleted file mode 100644 (file)
index a0d2d13..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum`
-  --> $DIR/traits-inductive-overflow-simultaneous.rs:18:5
-   |
-LL | fn is_ee<T: Combo>(t: T) {
-   |             ----- required by this bound in `is_ee`
-...
-LL |     is_ee(4);
-   |     ^^^^^
-   |
-   = note: required because of the requirements on the impl of `Combo` for `{integer}`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait-auto-trait.rs b/src/test/ui/traits/traits-inductive-overflow-supertrait-auto-trait.rs
deleted file mode 100644 (file)
index 5fea47a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Auto-trait-based version of #29859, supertrait version. Test that using
-// a simple auto trait `..` impl alone still doesn't allow arbitrary bounds
-// to be synthesized.
-
-#![feature(auto_traits)]
-#![feature(negative_impls)]
-
-auto trait Magic: Copy {} //~ ERROR E0568
-
-fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
-
-#[derive(Debug)]
-struct NoClone;
-
-fn main() {
-    let (a, b) = copy(NoClone); //~ ERROR
-    println!("{:?} {:?}", a, b);
-}
diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait-auto-trait.stderr b/src/test/ui/traits/traits-inductive-overflow-supertrait-auto-trait.stderr
deleted file mode 100644 (file)
index 140ffa4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0568]: auto traits cannot have super traits
-  --> $DIR/traits-inductive-overflow-supertrait-auto-trait.rs:8:19
-   |
-LL | auto trait Magic: Copy {}
-   |            -----  ^^^^ help: remove the super traits
-   |            |
-   |            auto trait cannot have super traits
-
-error[E0277]: the trait bound `NoClone: Copy` is not satisfied
-  --> $DIR/traits-inductive-overflow-supertrait-auto-trait.rs:16:23
-   |
-LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
-   |            ----- required by this bound in `copy`
-...
-LL |     let (a, b) = copy(NoClone);
-   |                       ^^^^^^^ the trait `Copy` is not implemented for `NoClone`
-   |
-   = note: required because of the requirements on the impl of `Magic` for `NoClone`
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0277, E0568.
-For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait.rs b/src/test/ui/traits/traits-inductive-overflow-supertrait.rs
deleted file mode 100644 (file)
index c7aa4d9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Regression test for #29859, supertrait version. This example
-// allowed arbitrary trait bounds to be synthesized.
-
-trait Magic: Copy {}
-impl<T: Magic> Magic for T {}
-
-fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
-
-#[derive(Debug)]
-struct NoClone;
-
-fn main() {
-    let (a, b) = copy(NoClone); //~ ERROR E0275
-    println!("{:?} {:?}", a, b);
-}
diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr b/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr
deleted file mode 100644 (file)
index a86648d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0275]: overflow evaluating the requirement `NoClone: Magic`
-  --> $DIR/traits-inductive-overflow-supertrait.rs:13:18
-   |
-LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
-   |            ----- required by this bound in `copy`
-...
-LL |     let (a, b) = copy(NoClone);
-   |                  ^^^^
-   |
-   = note: required because of the requirements on the impl of `Magic` for `NoClone`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.rs b/src/test/ui/traits/traits-inductive-overflow-two-traits.rs
deleted file mode 100644 (file)
index 463b55d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Regression test for #29859, initial version. This example allowed
-// arbitrary trait bounds to be synthesized.
-
-// Trait that you want all types to implement.
-use std::marker::{Sync as Trait};
-
-pub trait Magic {
-    type X: Trait;
-}
-impl<T: Magic> Magic for T {
-    type X = Self;
-    //~^ ERROR E0277
-}
-
-fn check<T: Trait>() {}
-
-fn wizard<T: Magic>() { check::<<T as Magic>::X>(); }
-
-fn main() {
-    wizard::<*mut ()>(); //~ ERROR E0275
-    // check::<*mut ()>();
-}
diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr
deleted file mode 100644 (file)
index 996544a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0277]: `T` cannot be shared between threads safely
-  --> $DIR/traits-inductive-overflow-two-traits.rs:11:5
-   |
-LL |     type X: Trait;
-   |             ----- required by this bound in `Magic::X`
-...
-LL |     type X = Self;
-   |     ^^^^^^^^^^^^^^ `T` cannot be shared between threads safely
-   |
-help: consider further restricting this bound
-   |
-LL | impl<T: Magic + Sync> Magic for T {
-   |               ^^^^^^
-
-error[E0275]: overflow evaluating the requirement `*mut (): Magic`
-  --> $DIR/traits-inductive-overflow-two-traits.rs:20:5
-   |
-LL | fn wizard<T: Magic>() { check::<<T as Magic>::X>(); }
-   |              ----- required by this bound in `wizard`
-...
-LL |     wizard::<*mut ()>();
-   |     ^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0275, E0277.
-For more information about an error, try `rustc --explain E0275`.
diff --git a/src/test/ui/traits/traits-issue-22019.rs b/src/test/ui/traits/traits-issue-22019.rs
deleted file mode 100644 (file)
index 1a887f0..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-// run-pass
-// Test an issue where global caching was causing free regions from
-// distinct scopes to be compared (`'g` and `'h`). The only important
-// thing is that compilation succeeds here.
-
-// pretty-expanded FIXME #23616
-
-#![allow(missing_copy_implementations)]
-#![allow(unused_variables)]
-
-use std::borrow::ToOwned;
-
-pub struct CFGNode;
-
-pub type Node<'a> = &'a CFGNode;
-
-pub trait GraphWalk<'c, N> {
-    /// Returns all the nodes in this graph.
-    fn nodes(&'c self) where [N]:ToOwned<Owned=Vec<N>>;
-}
-
-impl<'g> GraphWalk<'g, Node<'g>> for u32
-{
-    fn nodes(&'g self) where [Node<'g>]:ToOwned<Owned=Vec<Node<'g>>>
-    { loop { } }
-}
-
-impl<'h> GraphWalk<'h, Node<'h>> for u64
-{
-    fn nodes(&'h self) where [Node<'h>]:ToOwned<Owned=Vec<Node<'h>>>
-    { loop { } }
-}
-
-fn main()  { }
diff --git a/src/test/ui/traits/traits-issue-22110.rs b/src/test/ui/traits/traits-issue-22110.rs
deleted file mode 100644 (file)
index bdbfee7..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// run-pass
-// Test an issue where we reported ambiguity between the where-clause
-// and the blanket impl. The only important thing is that compilation
-// succeeds here. Issue #22110.
-
-// pretty-expanded FIXME #23616
-
-#![allow(dead_code)]
-
-trait Foo<A> {
-    fn foo(&self, a: A);
-}
-
-impl<A,F:Fn(A)> Foo<A> for F {
-    fn foo(&self, _: A) { }
-}
-
-fn baz<A,F:for<'a> Foo<(&'a A,)>>(_: F) { }
-
-fn components<T,A>(t: fn(&A))
-    where fn(&A) : for<'a> Foo<(&'a A,)>,
-{
-    baz(t)
-}
-
-fn main() {
-}
diff --git a/src/test/ui/traits/traits-issue-22655.rs b/src/test/ui/traits/traits-issue-22655.rs
deleted file mode 100644 (file)
index bc08ca0..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-#![allow(dead_code)]
-// Regression test for issue #22655: This test should not lead to
-// infinite recursion.
-
-// pretty-expanded FIXME #23616
-
-unsafe impl<T: Send + ?Sized> Send for Unique<T> { }
-
-pub struct Unique<T:?Sized> {
-    pointer: *const T,
-}
-
-pub struct Node<V> {
-    vals: V,
-    edges: Unique<Node<V>>,
-}
-
-fn is_send<T: Send>() {}
-
-fn main() {
-    is_send::<Node<&'static ()>>();
-}
diff --git a/src/test/ui/traits/traits-issue-23003-overflow.rs b/src/test/ui/traits/traits-issue-23003-overflow.rs
deleted file mode 100644 (file)
index c5f471f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// A variant of traits-issue-23003 in which an infinite series of
-// types are required. This test now just compiles fine, since the
-// relevant rules that triggered the overflow were removed.
-
-// check-pass
-#![allow(dead_code)]
-
-use std::marker::PhantomData;
-
-trait Async {
-    type Cancel;
-}
-
-struct Receipt<A:Async> {
-    marker: PhantomData<A>,
-}
-
-struct Complete<B> {
-    core: Option<B>,
-}
-
-impl<B> Async for Complete<B> {
-    type Cancel = Receipt<Complete<Option<B>>>;
-}
-
-fn foo(_: Receipt<Complete<()>>) { }
-
-
-fn main() { }
diff --git a/src/test/ui/traits/traits-issue-23003.rs b/src/test/ui/traits/traits-issue-23003.rs
deleted file mode 100644 (file)
index 24c2b2a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// run-pass
-// Test stack overflow triggered by evaluating the implications. To be
-// WF, the type `Receipt<Complete>` would require that `<Complete as
-// Async>::Cancel` be WF. This normalizes to `Receipt<Complete>`
-// again, leading to an infinite cycle. Issue #23003.
-
-// pretty-expanded FIXME #23616
-
-#![allow(dead_code)]
-#![allow(unused_variables)]
-
-use std::marker::PhantomData;
-
-trait Async {
-    type Cancel;
-}
-
-struct Receipt<A:Async> {
-    marker: PhantomData<A>,
-}
-
-struct Complete {
-    core: Option<()>,
-}
-
-impl Async for Complete {
-    type Cancel = Receipt<Complete>;
-}
-
-fn foo(r: Receipt<Complete>) { }
-
-fn main() { }
diff --git a/src/test/ui/traits/traits-issue-26339.rs b/src/test/ui/traits/traits-issue-26339.rs
deleted file mode 100644 (file)
index bedd87c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// run-pass
-// Test that the right implementation is called through a trait
-// object when supertraits include multiple references to the
-// same trait, with different type parameters.
-
-trait A: PartialEq<Foo> + PartialEq<Bar> { }
-
-struct Foo;
-struct Bar;
-
-struct Aimpl;
-
-impl PartialEq<Foo> for Aimpl {
-    fn eq(&self, _rhs: &Foo) -> bool {
-        true
-    }
-}
-
-impl PartialEq<Bar> for Aimpl {
-    fn eq(&self, _rhs: &Bar) -> bool {
-        false
-    }
-}
-
-impl A for Aimpl { }
-
-fn main() {
-    let a = &Aimpl as &dyn A;
-
-    assert!(*a == Foo);
-}
diff --git a/src/test/ui/traits/traits-issue-71136.rs b/src/test/ui/traits/traits-issue-71136.rs
deleted file mode 100644 (file)
index b21756e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-struct Foo(u8);
-
-#[derive(Clone)]
-struct FooHolster {
-    the_foos: Vec<Foo>, //~ERROR Clone
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/traits-issue-71136.stderr b/src/test/ui/traits/traits-issue-71136.stderr
deleted file mode 100644 (file)
index 23a8040..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0277]: the trait bound `Foo: Clone` is not satisfied
-  --> $DIR/traits-issue-71136.rs:5:5
-   |
-LL |     the_foos: Vec<Foo>,
-   |     ^^^^^^^^^^^^^^^^^^ expected an implementor of trait `Clone`
-   |
-   = note: required because of the requirements on the impl of `Clone` for `Vec<Foo>`
-   = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/traits-multidispatch-bad.rs b/src/test/ui/traits/traits-multidispatch-bad.rs
deleted file mode 100644 (file)
index b625b96..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test that we detect an illegal combination of types.
-
-trait Convert<Target> {
-    fn convert(&self) -> Target;
-}
-
-impl Convert<u32> for i32 {
-    fn convert(&self) -> u32 {
-        *self as u32
-    }
-}
-
-fn test<T,U>(_: T, _: U)
-where T : Convert<U>
-{
-}
-
-fn a() {
-    test(22i32, 44i32); //~ ERROR mismatched types
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/traits-multidispatch-bad.stderr b/src/test/ui/traits/traits-multidispatch-bad.stderr
deleted file mode 100644 (file)
index 671faf4..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0308]: mismatched types
-  --> $DIR/traits-multidispatch-bad.rs:19:17
-   |
-LL |     test(22i32, 44i32);
-   |                 ^^^^^ expected `u32`, found `i32`
-   |
-help: change the type of the numeric literal from `i32` to `u32`
-   |
-LL |     test(22i32, 44u32);
-   |                 ^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.rs b/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.rs
deleted file mode 100644 (file)
index 58cb69a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Check that we get an error in a multidisptach scenario where the
-// set of impls is ambiguous.
-
-trait Convert<Target> {
-    fn convert(&self) -> Target;
-}
-
-impl Convert<i8> for i32 {
-    fn convert(&self) -> i8 {
-        *self as i8
-    }
-}
-
-impl Convert<i16> for i32 {
-    fn convert(&self) -> i16 {
-        *self as i16
-    }
-}
-
-fn test<T,U>(_: T, _: U)
-where T : Convert<U>
-{
-}
-
-fn a() {
-    test(22, std::default::Default::default());
-    //~^ ERROR type annotations needed [E0282]
-}
-
-fn main() {}
diff --git a/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr b/src/test/ui/traits/traits-multidispatch-convert-ambig-dest.stderr
deleted file mode 100644 (file)
index 338c8cb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0282]: type annotations needed
-  --> $DIR/traits-multidispatch-convert-ambig-dest.rs:26:5
-   |
-LL |     test(22, std::default::Default::default());
-   |     ^^^^ cannot infer type for type parameter `U` declared on the function `test`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/traits/traits-multidispatch-infer-convert-target.rs b/src/test/ui/traits/traits-multidispatch-infer-convert-target.rs
deleted file mode 100644 (file)
index 626e1ae..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// run-pass
-// Test that we can infer the Target based on the Self or vice versa.
-
-
-use std::mem;
-
-trait Convert<Target> {
-    fn convert(&self) -> Target;
-}
-
-impl Convert<u32> for i16 {
-    fn convert(&self) -> u32 {
-        *self as u32
-    }
-}
-
-impl Convert<i16> for u32 {
-    fn convert(&self) -> i16 {
-        *self as i16
-    }
-}
-
-fn test<T,U>(_: T, _: U, t_size: usize, u_size: usize)
-where T : Convert<U>
-{
-    assert_eq!(mem::size_of::<T>(), t_size);
-    assert_eq!(mem::size_of::<U>(), u_size);
-}
-
-fn main() {
-    // T = i16, U = u32
-    test(22_i16, Default::default(),  2, 4);
-
-    // T = u32, U = i16
-    test(22_u32, Default::default(), 4, 2);
-}
diff --git a/src/test/ui/traits/traits-repeated-supertrait-ambig.rs b/src/test/ui/traits/traits-repeated-supertrait-ambig.rs
deleted file mode 100644 (file)
index 6aaef8a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// Test a case of a trait which extends the same supertrait twice, but
-// with difference type parameters. Test then that when we don't give
-// enough information to pick between these, no selection is made. In
-// this particular case, the two choices are i64/u64 -- so when we use
-// an integer literal, we wind up falling this literal back to i32.
-// See also `run-pass/trait-repeated-supertrait.rs`.
-
-trait CompareTo<T> {
-    fn same_as(&self, t: T) -> bool;
-}
-
-trait CompareToInts : CompareTo<i64> + CompareTo<u64> {
-}
-
-impl CompareTo<i64> for i64 {
-    fn same_as(&self, t: i64) -> bool { *self == t }
-}
-
-impl CompareTo<u64> for i64 {
-    fn same_as(&self, t: u64) -> bool { *self == (t as i64) }
-}
-
-impl CompareToInts for i64 { }
-
-fn with_obj(c: &dyn CompareToInts) -> bool {
-    c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfied
-}
-
-fn with_trait<C:CompareToInts>(c: &C) -> bool {
-    c.same_as(22) //~ ERROR `C: CompareTo<i32>` is not satisfied
-}
-
-fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
-    CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfied
-}
-
-fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {
-    CompareTo::same_as(c, 22) //~ ERROR `C: CompareTo<i32>` is not satisfied
-}
-
-fn main() {
-    assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64: CompareTo<i32>` is not satisfied
-}
diff --git a/src/test/ui/traits/traits-repeated-supertrait-ambig.stderr b/src/test/ui/traits/traits-repeated-supertrait-ambig.stderr
deleted file mode 100644 (file)
index 4107c49..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied
-  --> $DIR/traits-repeated-supertrait-ambig.rs:26:7
-   |
-LL |     c.same_as(22)
-   |       ^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
-
-error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied
-  --> $DIR/traits-repeated-supertrait-ambig.rs:30:7
-   |
-LL |     c.same_as(22)
-   |       ^^^^^^^ the trait `CompareTo<i32>` is not implemented for `C`
-   |
-help: consider further restricting this bound
-   |
-LL | fn with_trait<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
-   |                               ^^^^^^^^^^^^^^^^
-
-error[E0277]: the trait bound `dyn CompareToInts: CompareTo<i32>` is not satisfied
-  --> $DIR/traits-repeated-supertrait-ambig.rs:34:5
-   |
-LL |     fn same_as(&self, t: T) -> bool;
-   |     -------------------------------- required by `CompareTo::same_as`
-...
-LL |     CompareToInts::same_as(c, 22)
-   |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `dyn CompareToInts`
-
-error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied
-  --> $DIR/traits-repeated-supertrait-ambig.rs:38:5
-   |
-LL |     fn same_as(&self, t: T) -> bool;
-   |     -------------------------------- required by `CompareTo::same_as`
-...
-LL |     CompareTo::same_as(c, 22)
-   |     ^^^^^^^^^^^^^^^^^^ the trait `CompareTo<i32>` is not implemented for `C`
-   |
-help: consider further restricting this bound
-   |
-LL | fn with_ufcs2<C:CompareToInts + CompareTo<i32>>(c: &C) -> bool {
-   |                               ^^^^^^^^^^^^^^^^
-
-error[E0277]: the trait bound `i64: CompareTo<i32>` is not satisfied
-  --> $DIR/traits-repeated-supertrait-ambig.rs:42:23
-   |
-LL |     assert_eq!(22_i64.same_as(22), true);
-   |                       ^^^^^^^ the trait `CompareTo<i32>` is not implemented for `i64`
-   |
-   = help: the following implementations were found:
-             <i64 as CompareTo<i64>>
-             <i64 as CompareTo<u64>>
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/traits/traits-repeated-supertrait.rs b/src/test/ui/traits/traits-repeated-supertrait.rs
deleted file mode 100644 (file)
index 339f9c3..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// run-pass
-// Test a case of a trait which extends the same supertrait twice, but
-// with difference type parameters. Test that we can invoke the
-// various methods in various ways successfully.
-// See also `ui/traits/trait-repeated-supertrait-ambig.rs`.
-
-
-trait CompareTo<T> {
-    fn same_as(&self, t: T) -> bool;
-}
-
-trait CompareToInts : CompareTo<i64> + CompareTo<u64> {
-}
-
-impl CompareTo<i64> for i64 {
-    fn same_as(&self, t: i64) -> bool { *self == t }
-}
-
-impl CompareTo<u64> for i64 {
-    fn same_as(&self, t: u64) -> bool { *self == (t as i64) }
-}
-
-impl CompareToInts for i64 { }
-
-fn with_obj(c: &dyn CompareToInts) -> bool {
-    c.same_as(22_i64) && c.same_as(22_u64)
-}
-
-fn with_trait<C:CompareToInts>(c: &C) -> bool {
-    c.same_as(22_i64) && c.same_as(22_u64)
-}
-
-fn with_ufcs1<C:CompareToInts>(c: &C) -> bool {
-    CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64)
-}
-
-fn with_ufcs2<C:CompareToInts>(c: &C) -> bool {
-    CompareTo::same_as(c, 22_i64) && CompareTo::same_as(c, 22_u64)
-}
-
-fn main() {
-    assert_eq!(22_i64.same_as(22_i64), true);
-    assert_eq!(22_i64.same_as(22_u64), true);
-    assert_eq!(with_trait(&22), true);
-    assert_eq!(with_obj(&22), true);
-    assert_eq!(with_ufcs1(&22), true);
-    assert_eq!(with_ufcs2(&22), true);
-}
diff --git a/src/test/ui/traits/traits-static-outlives-a-where-clause.rs b/src/test/ui/traits/traits-static-outlives-a-where-clause.rs
deleted file mode 100644 (file)
index f0c2c10..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-
-trait Foo<'a> {
-    fn xyz(self);
-}
-impl<'a, T> Foo<'a> for T where 'static: 'a {
-    fn xyz(self) {}
-}
-
-trait Bar {
-    fn uvw(self);
-}
-impl<T> Bar for T where for<'a> T: Foo<'a> {
-    fn uvw(self) { self.xyz(); }
-}
-
-fn foo<T>(t: T) where T: Bar {
-    t.uvw();
-}
-
-fn main() {
-    foo(0);
-}
diff --git a/src/test/ui/traits/ufcs-object.rs b/src/test/ui/traits/ufcs-object.rs
new file mode 100644 (file)
index 0000000..700488c
--- /dev/null
@@ -0,0 +1,17 @@
+// run-pass
+// Test that when you use ufcs form to invoke a trait method (on a
+// trait object) everything works fine.
+
+
+trait Foo {
+    fn test(&self) -> i32;
+}
+
+impl Foo for i32 {
+    fn test(&self) -> i32 { *self }
+}
+
+fn main() {
+    let a: &dyn Foo = &22;
+    assert_eq!(Foo::test(a), 22);
+}
diff --git a/src/test/ui/traits/ufcs-trait-object.rs b/src/test/ui/traits/ufcs-trait-object.rs
deleted file mode 100644 (file)
index 700488c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// run-pass
-// Test that when you use ufcs form to invoke a trait method (on a
-// trait object) everything works fine.
-
-
-trait Foo {
-    fn test(&self) -> i32;
-}
-
-impl Foo for i32 {
-    fn test(&self) -> i32 { *self }
-}
-
-fn main() {
-    let a: &dyn Foo = &22;
-    assert_eq!(Foo::test(a), 22);
-}
diff --git a/src/test/ui/traits/use-before-def.rs b/src/test/ui/traits/use-before-def.rs
new file mode 100644 (file)
index 0000000..1ee2b94
--- /dev/null
@@ -0,0 +1,10 @@
+// run-pass
+#![allow(non_camel_case_types)]
+
+// Issue #1761
+
+// pretty-expanded FIXME #23616
+
+impl foo for isize { fn foo(&self) -> isize { 10 } }
+trait foo { fn foo(&self) -> isize; }
+pub fn main() {}
diff --git a/src/test/ui/traits/use-trait-before-def.rs b/src/test/ui/traits/use-trait-before-def.rs
deleted file mode 100644 (file)
index 1ee2b94..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// run-pass
-#![allow(non_camel_case_types)]
-
-// Issue #1761
-
-// pretty-expanded FIXME #23616
-
-impl foo for isize { fn foo(&self) -> isize { 10 } }
-trait foo { fn foo(&self) -> isize; }
-pub fn main() {}
diff --git a/src/test/ui/traits/wf-object/maybe-bound.rs b/src/test/ui/traits/wf-object/maybe-bound.rs
new file mode 100644 (file)
index 0000000..17771e9
--- /dev/null
@@ -0,0 +1,18 @@
+// Test that `dyn ... + ?Sized + ...` is okay (though `?Sized` has no effect in trait objects).
+
+trait Foo {}
+
+type _0 = dyn ?Sized + Foo;
+//~^ ERROR `?Trait` is not permitted in trait object types
+
+type _1 = dyn Foo + ?Sized;
+//~^ ERROR `?Trait` is not permitted in trait object types
+
+type _2 = dyn Foo + ?Sized + ?Sized;
+//~^ ERROR `?Trait` is not permitted in trait object types
+//~| ERROR `?Trait` is not permitted in trait object types
+
+type _3 = dyn ?Sized + Foo;
+//~^ ERROR `?Trait` is not permitted in trait object types
+
+fn main() {}
diff --git a/src/test/ui/traits/wf-object/maybe-bound.stderr b/src/test/ui/traits/wf-object/maybe-bound.stderr
new file mode 100644 (file)
index 0000000..2fe3f0f
--- /dev/null
@@ -0,0 +1,32 @@
+error: `?Trait` is not permitted in trait object types
+  --> $DIR/maybe-bound.rs:5:15
+   |
+LL | type _0 = dyn ?Sized + Foo;
+   |               ^^^^^^
+
+error: `?Trait` is not permitted in trait object types
+  --> $DIR/maybe-bound.rs:8:21
+   |
+LL | type _1 = dyn Foo + ?Sized;
+   |                     ^^^^^^
+
+error: `?Trait` is not permitted in trait object types
+  --> $DIR/maybe-bound.rs:11:21
+   |
+LL | type _2 = dyn Foo + ?Sized + ?Sized;
+   |                     ^^^^^^
+
+error: `?Trait` is not permitted in trait object types
+  --> $DIR/maybe-bound.rs:11:30
+   |
+LL | type _2 = dyn Foo + ?Sized + ?Sized;
+   |                              ^^^^^^
+
+error: `?Trait` is not permitted in trait object types
+  --> $DIR/maybe-bound.rs:15:15
+   |
+LL | type _3 = dyn ?Sized + Foo;
+   |               ^^^^^^
+
+error: aborting due to 5 previous errors
+
diff --git a/src/test/ui/traits/wf-object/no-duplicates.rs b/src/test/ui/traits/wf-object/no-duplicates.rs
new file mode 100644 (file)
index 0000000..678ede5
--- /dev/null
@@ -0,0 +1,33 @@
+// The purpose of this test is to demonstrate that duplicating object safe traits
+// that are not auto-traits is rejected even though one could reasonably accept this.
+
+// Some arbitrary object-safe trait:
+trait Obj {}
+
+// Demonstrate that recursive expansion of trait aliases doesn't affect stable behavior:
+type _0 = dyn Obj + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+// Some variations:
+
+type _1 = dyn Send + Obj + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _2 = dyn Obj + Send + Obj;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+type _3 = dyn Obj + Send + Send; // But it is OK to duplicate auto traits.
+
+// Take higher ranked types into account.
+
+// Note that `'a` and `'b` are intentionally different to make sure we consider
+// them semantically the same.
+trait ObjL<'l> {}
+type _4 = dyn for<'a> ObjL<'a> + for<'b> ObjL<'b>;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+trait ObjT<T> {}
+type _5 = dyn ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)>;
+//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
+
+fn main() {}
diff --git a/src/test/ui/traits/wf-object/no-duplicates.stderr b/src/test/ui/traits/wf-object/no-duplicates.stderr
new file mode 100644 (file)
index 0000000..b950689
--- /dev/null
@@ -0,0 +1,58 @@
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:8:21
+   |
+LL | type _0 = dyn Obj + Obj;
+   |               ---   ^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:13:28
+   |
+LL | type _1 = dyn Send + Obj + Obj;
+   |                      ---   ^^^ additional non-auto trait
+   |                      |
+   |                      first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:16:28
+   |
+LL | type _2 = dyn Obj + Send + Obj;
+   |               ---          ^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:26:34
+   |
+LL | type _4 = dyn for<'a> ObjL<'a> + for<'b> ObjL<'b>;
+   |               ----------------   ^^^^^^^^^^^^^^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: for<'a> ObjL<'a> + for<'b> ObjL<'b> {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error[E0225]: only auto traits can be used as additional traits in a trait object
+  --> $DIR/no-duplicates.rs:30:42
+   |
+LL | type _5 = dyn ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)>;
+   |               ------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^ additional non-auto trait
+   |               |
+   |               first non-auto trait
+   |
+   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)> {}`
+   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
+
+error: aborting due to 5 previous errors
+
+For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/wf-object/only-maybe-bound.rs b/src/test/ui/traits/wf-object/only-maybe-bound.rs
new file mode 100644 (file)
index 0000000..3e6db3e
--- /dev/null
@@ -0,0 +1,7 @@
+// Test that `dyn ?Sized` (i.e., a trait object with only a maybe buond) is not allowed.
+
+type _0 = dyn ?Sized;
+//~^ ERROR at least one trait is required for an object type [E0224]
+//~| ERROR ?Trait` is not permitted in trait object types
+
+fn main() {}
diff --git a/src/test/ui/traits/wf-object/only-maybe-bound.stderr b/src/test/ui/traits/wf-object/only-maybe-bound.stderr
new file mode 100644 (file)
index 0000000..cbc41fe
--- /dev/null
@@ -0,0 +1,15 @@
+error: `?Trait` is not permitted in trait object types
+  --> $DIR/only-maybe-bound.rs:3:15
+   |
+LL | type _0 = dyn ?Sized;
+   |               ^^^^^^
+
+error[E0224]: at least one trait is required for an object type
+  --> $DIR/only-maybe-bound.rs:3:11
+   |
+LL | type _0 = dyn ?Sized;
+   |           ^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0224`.
diff --git a/src/test/ui/traits/wf-object/reverse-order.rs b/src/test/ui/traits/wf-object/reverse-order.rs
new file mode 100644 (file)
index 0000000..4f676cb
--- /dev/null
@@ -0,0 +1,15 @@
+// run-pass
+
+// Ensure that `dyn $($AutoTrait)+ ObjSafe` is well-formed.
+
+use std::marker::Unpin;
+
+// Some arbitrary object-safe trait:
+trait Obj {}
+
+type _0 = dyn Unpin;
+type _1 = dyn Send + Obj;
+type _2 = dyn Send + Unpin + Obj;
+type _3 = dyn Send + Unpin + Sync + Obj;
+
+fn main() {}
diff --git a/src/test/ui/traits/wf-trait-object-maybe-bound.rs b/src/test/ui/traits/wf-trait-object-maybe-bound.rs
deleted file mode 100644 (file)
index 17771e9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Test that `dyn ... + ?Sized + ...` is okay (though `?Sized` has no effect in trait objects).
-
-trait Foo {}
-
-type _0 = dyn ?Sized + Foo;
-//~^ ERROR `?Trait` is not permitted in trait object types
-
-type _1 = dyn Foo + ?Sized;
-//~^ ERROR `?Trait` is not permitted in trait object types
-
-type _2 = dyn Foo + ?Sized + ?Sized;
-//~^ ERROR `?Trait` is not permitted in trait object types
-//~| ERROR `?Trait` is not permitted in trait object types
-
-type _3 = dyn ?Sized + Foo;
-//~^ ERROR `?Trait` is not permitted in trait object types
-
-fn main() {}
diff --git a/src/test/ui/traits/wf-trait-object-maybe-bound.stderr b/src/test/ui/traits/wf-trait-object-maybe-bound.stderr
deleted file mode 100644 (file)
index 4a570ef..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/wf-trait-object-maybe-bound.rs:5:15
-   |
-LL | type _0 = dyn ?Sized + Foo;
-   |               ^^^^^^
-
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/wf-trait-object-maybe-bound.rs:8:21
-   |
-LL | type _1 = dyn Foo + ?Sized;
-   |                     ^^^^^^
-
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/wf-trait-object-maybe-bound.rs:11:21
-   |
-LL | type _2 = dyn Foo + ?Sized + ?Sized;
-   |                     ^^^^^^
-
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/wf-trait-object-maybe-bound.rs:11:30
-   |
-LL | type _2 = dyn Foo + ?Sized + ?Sized;
-   |                              ^^^^^^
-
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/wf-trait-object-maybe-bound.rs:15:15
-   |
-LL | type _3 = dyn ?Sized + Foo;
-   |               ^^^^^^
-
-error: aborting due to 5 previous errors
-
diff --git a/src/test/ui/traits/wf-trait-object-no-duplicates.rs b/src/test/ui/traits/wf-trait-object-no-duplicates.rs
deleted file mode 100644 (file)
index 678ede5..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// The purpose of this test is to demonstrate that duplicating object safe traits
-// that are not auto-traits is rejected even though one could reasonably accept this.
-
-// Some arbitrary object-safe trait:
-trait Obj {}
-
-// Demonstrate that recursive expansion of trait aliases doesn't affect stable behavior:
-type _0 = dyn Obj + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-// Some variations:
-
-type _1 = dyn Send + Obj + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _2 = dyn Obj + Send + Obj;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-type _3 = dyn Obj + Send + Send; // But it is OK to duplicate auto traits.
-
-// Take higher ranked types into account.
-
-// Note that `'a` and `'b` are intentionally different to make sure we consider
-// them semantically the same.
-trait ObjL<'l> {}
-type _4 = dyn for<'a> ObjL<'a> + for<'b> ObjL<'b>;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-trait ObjT<T> {}
-type _5 = dyn ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)>;
-//~^ ERROR only auto traits can be used as additional traits in a trait object [E0225]
-
-fn main() {}
diff --git a/src/test/ui/traits/wf-trait-object-no-duplicates.stderr b/src/test/ui/traits/wf-trait-object-no-duplicates.stderr
deleted file mode 100644 (file)
index ed5409d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/wf-trait-object-no-duplicates.rs:8:21
-   |
-LL | type _0 = dyn Obj + Obj;
-   |               ---   ^^^ additional non-auto trait
-   |               |
-   |               first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/wf-trait-object-no-duplicates.rs:13:28
-   |
-LL | type _1 = dyn Send + Obj + Obj;
-   |                      ---   ^^^ additional non-auto trait
-   |                      |
-   |                      first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/wf-trait-object-no-duplicates.rs:16:28
-   |
-LL | type _2 = dyn Obj + Send + Obj;
-   |               ---          ^^^ additional non-auto trait
-   |               |
-   |               first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Obj + Obj {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/wf-trait-object-no-duplicates.rs:26:34
-   |
-LL | type _4 = dyn for<'a> ObjL<'a> + for<'b> ObjL<'b>;
-   |               ----------------   ^^^^^^^^^^^^^^^^ additional non-auto trait
-   |               |
-   |               first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: for<'a> ObjL<'a> + for<'b> ObjL<'b> {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error[E0225]: only auto traits can be used as additional traits in a trait object
-  --> $DIR/wf-trait-object-no-duplicates.rs:30:42
-   |
-LL | type _5 = dyn ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)>;
-   |               ------------------------   ^^^^^^^^^^^^^^^^^^^^^^^^ additional non-auto trait
-   |               |
-   |               first non-auto trait
-   |
-   = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: ObjT<for<'a> fn(&'a u8)> + ObjT<for<'b> fn(&'b u8)> {}`
-   = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0225`.
diff --git a/src/test/ui/traits/wf-trait-object-only-maybe-bound.rs b/src/test/ui/traits/wf-trait-object-only-maybe-bound.rs
deleted file mode 100644 (file)
index 3e6db3e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// Test that `dyn ?Sized` (i.e., a trait object with only a maybe buond) is not allowed.
-
-type _0 = dyn ?Sized;
-//~^ ERROR at least one trait is required for an object type [E0224]
-//~| ERROR ?Trait` is not permitted in trait object types
-
-fn main() {}
diff --git a/src/test/ui/traits/wf-trait-object-only-maybe-bound.stderr b/src/test/ui/traits/wf-trait-object-only-maybe-bound.stderr
deleted file mode 100644 (file)
index 4824108..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-error: `?Trait` is not permitted in trait object types
-  --> $DIR/wf-trait-object-only-maybe-bound.rs:3:15
-   |
-LL | type _0 = dyn ?Sized;
-   |               ^^^^^^
-
-error[E0224]: at least one trait is required for an object type
-  --> $DIR/wf-trait-object-only-maybe-bound.rs:3:11
-   |
-LL | type _0 = dyn ?Sized;
-   |           ^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0224`.
diff --git a/src/test/ui/traits/wf-trait-object-reverse-order.rs b/src/test/ui/traits/wf-trait-object-reverse-order.rs
deleted file mode 100644 (file)
index 4f676cb..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-
-// Ensure that `dyn $($AutoTrait)+ ObjSafe` is well-formed.
-
-use std::marker::Unpin;
-
-// Some arbitrary object-safe trait:
-trait Obj {}
-
-type _0 = dyn Unpin;
-type _1 = dyn Send + Obj;
-type _2 = dyn Send + Unpin + Obj;
-type _3 = dyn Send + Unpin + Sync + Obj;
-
-fn main() {}
diff --git a/src/test/ui/traits/where-clause-vs-impl.rs b/src/test/ui/traits/where-clause-vs-impl.rs
new file mode 100644 (file)
index 0000000..7cfee27
--- /dev/null
@@ -0,0 +1,45 @@
+// run-pass
+#![allow(dead_code)]
+#![allow(unused_variables)]
+// Test that when there is a conditional (but blanket) impl and a
+// where clause, we don't get confused in trait resolution.
+//
+// Issue #18453.
+
+// pretty-expanded FIXME #23616
+
+use std::rc::Rc;
+
+pub trait Foo<M> {
+    fn foo(&mut self, msg: M);
+}
+
+pub trait Bar<M> {
+    fn dummy(&self) -> M;
+}
+
+impl<M, F: Bar<M>> Foo<M> for F {
+    fn foo(&mut self, msg: M) {
+    }
+}
+
+pub struct Both<M, F> {
+    inner: Rc<(M, F)>,
+}
+
+impl<M, F: Foo<M>> Clone for Both<M, F> {
+    fn clone(&self) -> Both<M, F> {
+        Both { inner: self.inner.clone() }
+    }
+}
+
+fn repro1<M, F: Foo<M>>(_both: Both<M, F>) {
+}
+
+fn repro2<M, F: Foo<M>>(msg: M, foo: F) {
+    let both = Both { inner: Rc::new((msg, foo)) };
+    repro1(both.clone()); // <--- This clone causes problem
+}
+
+pub fn main() {
+}
diff --git a/src/test/ui/traits/with-bounds-default.rs b/src/test/ui/traits/with-bounds-default.rs
new file mode 100644 (file)
index 0000000..31f73d7
--- /dev/null
@@ -0,0 +1,32 @@
+// run-pass
+
+pub trait Clone2 {
+    /// Returns a copy of the value. The contents of boxes
+    /// are copied to maintain uniqueness, while the contents of
+    /// managed pointers are not copied.
+    fn clone(&self) -> Self;
+}
+
+trait Getter<T: Clone> {
+    fn do_get(&self) -> T;
+
+    fn do_get2(&self) -> (T, T) {
+        let x = self.do_get();
+        (x.clone(), x.clone())
+    }
+
+}
+
+impl Getter<isize> for isize {
+    fn do_get(&self) -> isize { *self }
+}
+
+impl<T: Clone> Getter<T> for Option<T> {
+    fn do_get(&self) -> T { self.as_ref().unwrap().clone() }
+}
+
+
+pub fn main() {
+    assert_eq!(3.do_get2(), (3, 3));
+    assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
+}
diff --git a/src/test/ui/traits/with-dst.rs b/src/test/ui/traits/with-dst.rs
new file mode 100644 (file)
index 0000000..a3e3b31
--- /dev/null
@@ -0,0 +1,22 @@
+// build-pass (FIXME(62277): could be check-pass?)
+// #55266
+
+struct VTable<DST: ?Sized> {
+    _to_dst_ptr: fn(*mut ()) -> *mut DST,
+}
+
+trait HasVTableFor<DST: ?Sized + 'static> {
+    const VTABLE: &'static VTable<DST>;
+}
+
+impl<T, DST: ?Sized + 'static> HasVTableFor<DST> for T {
+    const VTABLE: &'static VTable<DST> = &VTable {
+        _to_dst_ptr: |_: *mut ()| unsafe { std::mem::zeroed() },
+    };
+}
+
+pub fn push<DST: ?Sized + 'static, T>() {
+    <T as HasVTableFor<DST>>::VTABLE;
+}
+
+fn main() {}